@wordpress/edit-site 6.8.7 → 6.8.9

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 (59) hide show
  1. package/build/components/editor/index.js +8 -1
  2. package/build/components/editor/index.js.map +1 -1
  3. package/build/components/global-styles/font-families.js +41 -25
  4. package/build/components/global-styles/font-families.js.map +1 -1
  5. package/build/components/global-styles/screen-style-variations.js +9 -2
  6. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  7. package/build/components/global-styles/shadows-edit-panel.js +17 -5
  8. package/build/components/global-styles/shadows-edit-panel.js.map +1 -1
  9. package/build/components/layout/index.js +3 -14
  10. package/build/components/layout/index.js.map +1 -1
  11. package/build/components/page-patterns/index.js +3 -2
  12. package/build/components/page-patterns/index.js.map +1 -1
  13. package/build/components/sidebar-button/index.js +1 -1
  14. package/build/components/sidebar-button/index.js.map +1 -1
  15. package/build/components/site-hub/index.js +3 -2
  16. package/build/components/site-hub/index.js.map +1 -1
  17. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +7 -0
  18. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  19. package/build/index.js +1 -3
  20. package/build/index.js.map +1 -1
  21. package/build-module/components/editor/index.js +8 -1
  22. package/build-module/components/editor/index.js.map +1 -1
  23. package/build-module/components/global-styles/font-families.js +43 -27
  24. package/build-module/components/global-styles/font-families.js.map +1 -1
  25. package/build-module/components/global-styles/screen-style-variations.js +9 -2
  26. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  27. package/build-module/components/global-styles/shadows-edit-panel.js +18 -6
  28. package/build-module/components/global-styles/shadows-edit-panel.js.map +1 -1
  29. package/build-module/components/layout/index.js +3 -14
  30. package/build-module/components/layout/index.js.map +1 -1
  31. package/build-module/components/page-patterns/index.js +3 -2
  32. package/build-module/components/page-patterns/index.js.map +1 -1
  33. package/build-module/components/sidebar-button/index.js +1 -1
  34. package/build-module/components/sidebar-button/index.js.map +1 -1
  35. package/build-module/components/site-hub/index.js +3 -2
  36. package/build-module/components/site-hub/index.js.map +1 -1
  37. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +7 -0
  38. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  39. package/build-module/index.js +1 -3
  40. package/build-module/index.js.map +1 -1
  41. package/build-style/posts-rtl.css +37 -37
  42. package/build-style/posts.css +37 -37
  43. package/build-style/style-rtl.css +41 -39
  44. package/build-style/style.css +41 -39
  45. package/package.json +16 -16
  46. package/src/components/editor/index.js +9 -1
  47. package/src/components/global-styles/font-families.js +51 -35
  48. package/src/components/global-styles/screen-style-variations.js +7 -2
  49. package/src/components/global-styles/shadows-edit-panel.js +21 -5
  50. package/src/components/layout/index.js +7 -23
  51. package/src/components/layout/style.scss +2 -2
  52. package/src/components/page-patterns/index.js +3 -2
  53. package/src/components/sidebar-button/index.js +1 -1
  54. package/src/components/sidebar-button/style.scss +2 -2
  55. package/src/components/sidebar-navigation-screen/style.scss +5 -1
  56. package/src/components/site-hub/index.js +2 -2
  57. package/src/components/site-hub/style.scss +4 -0
  58. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +6 -0
  59. package/src/index.js +1 -5
@@ -6,9 +6,11 @@ import {
6
6
  __experimentalText as Text,
7
7
  __experimentalItemGroup as ItemGroup,
8
8
  __experimentalVStack as VStack,
9
+ __experimentalHStack as HStack,
9
10
  Button,
10
11
  } from '@wordpress/components';
11
12
  import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
13
+ import { settings } from '@wordpress/icons';
12
14
  import { useContext } from '@wordpress/element';
13
15
 
14
16
  /**
@@ -25,6 +27,19 @@ import { unlock } from '../../lock-unlock';
25
27
 
26
28
  const { useGlobalSetting } = unlock( blockEditorPrivateApis );
27
29
 
30
+ /**
31
+ * Maps the fonts with the source, if available.
32
+ *
33
+ * @param {Array} fonts The fonts to map.
34
+ * @param {string} source The source of the fonts.
35
+ * @return {Array} The mapped fonts.
36
+ */
37
+ function mapFontsWithSource( fonts, source ) {
38
+ return fonts
39
+ ? fonts.map( ( f ) => setUIValuesNeeded( f, { source } ) )
40
+ : [];
41
+ }
42
+
28
43
  function FontFamilies() {
29
44
  const { baseCustomFonts, modalTabOpen, setModalTabOpen } =
30
45
  useContext( FontLibraryContext );
@@ -34,18 +49,12 @@ function FontFamilies() {
34
49
  undefined,
35
50
  'base'
36
51
  );
37
- const themeFonts = fontFamilies?.theme
38
- ? fontFamilies.theme
39
- .map( ( f ) => setUIValuesNeeded( f, { source: 'theme' } ) )
40
- .sort( ( a, b ) => a.name.localeCompare( b.name ) )
41
- : [];
42
- const customFonts = fontFamilies?.custom
43
- ? fontFamilies.custom
44
- .map( ( f ) => setUIValuesNeeded( f, { source: 'custom' } ) )
45
- .sort( ( a, b ) => a.name.localeCompare( b.name ) )
46
- : [];
47
- const hasFonts = 0 < customFonts.length || 0 < themeFonts.length;
48
-
52
+ const themeFonts = mapFontsWithSource( fontFamilies?.theme, 'theme' );
53
+ const customFonts = mapFontsWithSource( fontFamilies?.custom, 'custom' );
54
+ const activeFonts = [ ...themeFonts, ...customFonts ].sort( ( a, b ) =>
55
+ a.name.localeCompare( b.name )
56
+ );
57
+ const hasFonts = 0 < activeFonts.length;
49
58
  const hasInstalledFonts =
50
59
  hasFonts ||
51
60
  baseFontFamilies?.theme?.length > 0 ||
@@ -60,12 +69,20 @@ function FontFamilies() {
60
69
  />
61
70
  ) }
62
71
 
63
- <VStack spacing={ 4 }>
64
- { [ ...themeFonts, ...customFonts ].length > 0 && (
72
+ <VStack spacing={ 2 }>
73
+ <HStack justify="space-between">
74
+ <Subtitle level={ 3 }>{ __( 'Fonts' ) }</Subtitle>
75
+ <Button
76
+ onClick={ () => setModalTabOpen( 'installed-fonts' ) }
77
+ label={ __( 'Manage fonts' ) }
78
+ icon={ settings }
79
+ size="small"
80
+ />
81
+ </HStack>
82
+ { activeFonts.length > 0 && (
65
83
  <>
66
- <Subtitle level={ 3 }>{ __( 'Fonts' ) }</Subtitle>
67
84
  <ItemGroup size="large" isBordered isSeparated>
68
- { themeFonts.map( ( font ) => (
85
+ { activeFonts.map( ( font ) => (
69
86
  <FontFamilyItem
70
87
  key={ font.slug }
71
88
  font={ font }
@@ -75,31 +92,30 @@ function FontFamilies() {
75
92
  </>
76
93
  ) }
77
94
  { ! hasFonts && (
78
- <VStack>
79
- <Subtitle level={ 3 }>{ __( 'Fonts' ) }</Subtitle>
95
+ <>
80
96
  <Text as="p">
81
97
  { hasInstalledFonts
82
98
  ? __( 'No fonts activated.' )
83
99
  : __( 'No fonts installed.' ) }
84
100
  </Text>
85
- </VStack>
101
+ <Button
102
+ className="edit-site-global-styles-font-families__manage-fonts"
103
+ variant="secondary"
104
+ __next40pxDefaultSize
105
+ onClick={ () => {
106
+ setModalTabOpen(
107
+ hasInstalledFonts
108
+ ? 'installed-fonts'
109
+ : 'upload-fonts'
110
+ );
111
+ } }
112
+ >
113
+ { hasInstalledFonts
114
+ ? __( 'Manage fonts' )
115
+ : __( 'Add fonts' ) }
116
+ </Button>
117
+ </>
86
118
  ) }
87
- <Button
88
- className="edit-site-global-styles-font-families__manage-fonts"
89
- variant="secondary"
90
- __next40pxDefaultSize
91
- onClick={ () => {
92
- setModalTabOpen(
93
- hasInstalledFonts
94
- ? 'installed-fonts'
95
- : 'upload-fonts'
96
- );
97
- } }
98
- >
99
- { hasInstalledFonts
100
- ? __( 'Manage fonts' )
101
- : __( 'Add fonts' ) }
102
- </Button>
103
119
  </VStack>
104
120
  </>
105
121
  );
@@ -4,6 +4,8 @@
4
4
  import { Card, CardBody } from '@wordpress/components';
5
5
  import { __ } from '@wordpress/i18n';
6
6
  import { useZoomOut } from '@wordpress/block-editor';
7
+ import { useDispatch } from '@wordpress/data';
8
+ import { store as editorStore } from '@wordpress/editor';
7
9
 
8
10
  /**
9
11
  * Internal dependencies
@@ -12,9 +14,12 @@ import ScreenHeader from './header';
12
14
  import SidebarNavigationScreenGlobalStylesContent from '../sidebar-navigation-screen-global-styles/content';
13
15
 
14
16
  function ScreenStyleVariations() {
15
- // Move to zoom out mode when this component is mounted
16
- // and back to the previous mode when unmounted.
17
+ // Style Variations should only be previewed in with
18
+ // - a "zoomed out" editor
19
+ // - "Desktop" device preview
20
+ const { setDeviceType } = useDispatch( editorStore );
17
21
  useZoomOut();
22
+ setDeviceType( 'desktop' );
18
23
 
19
24
  return (
20
25
  <>
@@ -35,7 +35,7 @@ import {
35
35
  reset,
36
36
  moreVertical,
37
37
  } from '@wordpress/icons';
38
- import { useState, useMemo } from '@wordpress/element';
38
+ import { useState, useMemo, useEffect } from '@wordpress/element';
39
39
 
40
40
  /**
41
41
  * Internal dependencies
@@ -73,12 +73,30 @@ const presetShadowMenuItems = [
73
73
 
74
74
  export default function ShadowsEditPanel() {
75
75
  const {
76
+ goBack,
76
77
  params: { category, slug },
77
- goTo,
78
78
  } = useNavigator();
79
79
  const [ shadows, setShadows ] = useGlobalSetting(
80
80
  `shadow.presets.${ category }`
81
81
  );
82
+
83
+ useEffect( () => {
84
+ const hasCurrentShadow = shadows?.some(
85
+ ( shadow ) => shadow.slug === slug
86
+ );
87
+ // If the shadow being edited doesn't exist anymore in the global styles setting, navigate back
88
+ // to prevent the user from editing a non-existent shadow entry.
89
+ // This can happen, for example:
90
+ // - when the user deletes the shadow
91
+ // - when the user resets the styles while editing a custom shadow
92
+ //
93
+ // The check on the slug is necessary to prevent a double back navigation when the user triggers
94
+ // a backward navigation by interacting with the screen's UI.
95
+ if ( !! slug && ! hasCurrentShadow ) {
96
+ goBack();
97
+ }
98
+ }, [ shadows, slug, goBack ] );
99
+
82
100
  const [ baseShadows ] = useGlobalSetting(
83
101
  `shadow.presets.${ category }`,
84
102
  undefined,
@@ -119,9 +137,7 @@ export default function ShadowsEditPanel() {
119
137
  };
120
138
 
121
139
  const handleShadowDelete = () => {
122
- const updatedShadows = shadows.filter( ( s ) => s.slug !== slug );
123
- setShadows( updatedShadows );
124
- goTo( `/shadows` );
140
+ setShadows( shadows.filter( ( s ) => s.slug !== slug ) );
125
141
  };
126
142
 
127
143
  const handleShadowRename = ( newName ) => {
@@ -20,7 +20,6 @@ import {
20
20
  } from '@wordpress/compose';
21
21
  import { __ } from '@wordpress/i18n';
22
22
  import { useState, useRef, useEffect } from '@wordpress/element';
23
- import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
24
23
  import { CommandMenu } from '@wordpress/commands';
25
24
  import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
26
25
  import {
@@ -57,28 +56,13 @@ export default function Layout( { route } ) {
57
56
  useCommands();
58
57
  const isMobileViewport = useViewportMatch( 'medium', '<' );
59
58
  const toggleRef = useRef();
60
- const { canvasMode, previousShortcut, nextShortcut } = useSelect(
61
- ( select ) => {
62
- const { getAllShortcutKeyCombinations } = select(
63
- keyboardShortcutsStore
64
- );
65
- const { getCanvasMode } = unlock( select( editSiteStore ) );
66
- return {
67
- canvasMode: getCanvasMode(),
68
- previousShortcut: getAllShortcutKeyCombinations(
69
- 'core/editor/previous-region'
70
- ),
71
- nextShortcut: getAllShortcutKeyCombinations(
72
- 'core/editor/next-region'
73
- ),
74
- };
75
- },
76
- []
77
- );
78
- const navigateRegionsProps = useNavigateRegions( {
79
- previous: previousShortcut,
80
- next: nextShortcut,
81
- } );
59
+ const { canvasMode } = useSelect( ( select ) => {
60
+ const { getCanvasMode } = unlock( select( editSiteStore ) );
61
+ return {
62
+ canvasMode: getCanvasMode(),
63
+ };
64
+ }, [] );
65
+ const navigateRegionsProps = useNavigateRegions();
82
66
  const disableMotion = useReducedMotion();
83
67
  const [ canvasResizer, canvasSize ] = useResizeObserver();
84
68
  const isEditorLoading = useIsSiteEditorLoading();
@@ -206,8 +206,8 @@ html.canvas-mode-edit-transition::view-transition-group(toggle) {
206
206
 
207
207
  .edit-site-layout__view-mode-toggle-icon {
208
208
  display: flex;
209
- height: $grid-unit-80;
210
- width: $grid-unit-80;
209
+ height: $header-height;
210
+ width: $header-height;
211
211
  justify-content: center;
212
212
  align-items: center;
213
213
  }
@@ -78,6 +78,7 @@ export default function DataviewsPatterns() {
78
78
  const categoryId = categoryIdFromURL || PATTERN_DEFAULT_CATEGORY;
79
79
  const [ view, setView ] = useState( DEFAULT_VIEW );
80
80
  const previousCategoryId = usePrevious( categoryId );
81
+ const previousPostType = usePrevious( type );
81
82
  const viewSyncStatus = view.filters?.find(
82
83
  ( { field } ) => field === 'sync-status'
83
84
  )?.value;
@@ -121,10 +122,10 @@ export default function DataviewsPatterns() {
121
122
 
122
123
  // Reset the page number when the category changes.
123
124
  useEffect( () => {
124
- if ( previousCategoryId !== categoryId ) {
125
+ if ( previousCategoryId !== categoryId || previousPostType !== type ) {
125
126
  setView( ( prevView ) => ( { ...prevView, page: 1 } ) );
126
127
  }
127
- }, [ categoryId, previousCategoryId ] );
128
+ }, [ categoryId, previousCategoryId, previousPostType, type ] );
128
129
  const { data, paginationInfo } = useMemo( () => {
129
130
  // Search is managed server-side as well as filters for patterns.
130
131
  // However, the author filter in template parts is done client-side.
@@ -11,7 +11,7 @@ import { Button } from '@wordpress/components';
11
11
  export default function SidebarButton( props ) {
12
12
  return (
13
13
  <Button
14
- __next40pxDefaultSize
14
+ size="compact"
15
15
  { ...props }
16
16
  className={ clsx( 'edit-site-sidebar-button', props.className ) }
17
17
  />
@@ -14,10 +14,10 @@
14
14
  outline: 3px solid transparent;
15
15
  }
16
16
 
17
- &:hover,
17
+ &:hover:not(:disabled,[aria-disabled="true"]),
18
18
  &:focus-visible,
19
19
  &:focus,
20
- &:not([aria-disabled="true"]):active,
20
+ &:not(:disabled,[aria-disabled="true"]):active,
21
21
  &[aria-expanded="true"] {
22
22
  color: $gray-100;
23
23
  }
@@ -68,7 +68,11 @@
68
68
  .edit-site-sidebar-navigation-screen__title {
69
69
  flex-grow: 1;
70
70
  overflow-wrap: break-word;
71
- padding: $grid-unit-05 * 0.5 0 0 0;
71
+
72
+ &#{&},
73
+ &#{&} .edit-site-sidebar-navigation-screen__title {
74
+ line-height: 32px;
75
+ }
72
76
  }
73
77
 
74
78
  .edit-site-sidebar-navigation-screen__actions {
@@ -68,7 +68,7 @@ const SiteHub = memo(
68
68
  label={ __( 'Go to the Dashboard' ) }
69
69
  className="edit-site-layout__view-mode-toggle"
70
70
  style={ {
71
- transform: 'scale(0.5)',
71
+ transform: 'scale(0.5333) translateX(-4px)', // Offset to position the icon 12px from viewport edge
72
72
  borderRadius: 4,
73
73
  } }
74
74
  >
@@ -99,7 +99,7 @@ const SiteHub = memo(
99
99
  className="edit-site-site-hub__actions"
100
100
  >
101
101
  <Button
102
- __next40pxDefaultSize
102
+ size="compact"
103
103
  className="edit-site-site-hub_toggle-command-center"
104
104
  icon={ search }
105
105
  onClick={ () => openCommandCenter() }
@@ -4,6 +4,7 @@
4
4
  justify-content: space-between;
5
5
  gap: $grid-unit-10;
6
6
  margin-right: $grid-unit-15;
7
+ height: $grid-unit-70;
7
8
  }
8
9
 
9
10
  .edit-site-site-hub__actions {
@@ -29,6 +30,9 @@
29
30
  overflow: hidden;
30
31
  // Add space for the ↗ to render.
31
32
  padding-right: $grid-unit-20;
33
+
34
+ // Create 12px gap between site icon and site title
35
+ margin-left: - $grid-unit-05;
32
36
  position: relative;
33
37
  text-decoration: none;
34
38
  text-overflow: ellipsis;
@@ -5,6 +5,7 @@ import { useEffect, useMemo } from '@wordpress/element';
5
5
  import { useSelect, useDispatch } from '@wordpress/data';
6
6
  import { store as coreDataStore } from '@wordpress/core-data';
7
7
  import { privateApis as routerPrivateApis } from '@wordpress/router';
8
+ import { store as blockEditorStore } from '@wordpress/block-editor';
8
9
 
9
10
  /**
10
11
  * Internal dependencies
@@ -248,9 +249,14 @@ export default function useInitEditedEntityFromURL() {
248
249
  useResolveEditedEntityAndContext( params );
249
250
 
250
251
  const { setEditedEntity } = useDispatch( editSiteStore );
252
+ const { __unstableSetEditorMode, resetZoomLevel } = unlock(
253
+ useDispatch( blockEditorStore )
254
+ );
251
255
 
252
256
  useEffect( () => {
253
257
  if ( isReady ) {
258
+ __unstableSetEditorMode( 'edit' );
259
+ resetZoomLevel();
254
260
  setEditedEntity( postType, postId, context );
255
261
  }
256
262
  }, [ isReady, postType, postId, context, setEditedEntity ] );
package/src/index.js CHANGED
@@ -28,10 +28,7 @@ import { store as editSiteStore } from './store';
28
28
  import { unlock } from './lock-unlock';
29
29
  import App from './components/app';
30
30
 
31
- const {
32
- registerCoreBlockBindingsSources,
33
- bootstrapBlockBindingsSourcesFromServer,
34
- } = unlock( editorPrivateApis );
31
+ const { registerCoreBlockBindingsSources } = unlock( editorPrivateApis );
35
32
 
36
33
  /**
37
34
  * Initializes the site editor screen.
@@ -48,7 +45,6 @@ export function initializeEditor( id, settings ) {
48
45
  ( { name } ) => name !== 'core/freeform'
49
46
  );
50
47
  registerCoreBlocks( coreBlocks );
51
- bootstrapBlockBindingsSourcesFromServer( settings?.blockBindingsSources );
52
48
  registerCoreBlockBindingsSources();
53
49
  dispatch( blocksStore ).setFreeformFallbackBlockName( 'core/html' );
54
50
  registerLegacyWidgetBlock( { inserter: false } );