@wordpress/edit-site 4.13.1-next.957ca95e4c.0 → 4.14.1

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 (77) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-editor/index.js +20 -10
  3. package/build/components/block-editor/index.js.map +1 -1
  4. package/build/components/block-editor/resizable-editor.js +8 -1
  5. package/build/components/block-editor/resizable-editor.js.map +1 -1
  6. package/build/components/editor/index.js +9 -4
  7. package/build/components/editor/index.js.map +1 -1
  8. package/build/components/global-styles/gradients-palette-panel.js +6 -2
  9. package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
  10. package/build/components/global-styles/hooks.js +5 -3
  11. package/build/components/global-styles/hooks.js.map +1 -1
  12. package/build/components/global-styles/typography-panel.js +40 -4
  13. package/build/components/global-styles/typography-panel.js.map +1 -1
  14. package/build/components/global-styles/use-global-styles-output.js +41 -29
  15. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  16. package/build/components/header/document-actions/index.js +11 -8
  17. package/build/components/header/document-actions/index.js.map +1 -1
  18. package/build/components/header/index.js +41 -5
  19. package/build/components/header/index.js.map +1 -1
  20. package/build/components/list/header.js +15 -2
  21. package/build/components/list/header.js.map +1 -1
  22. package/build/components/navigation-sidebar/navigation-panel/index.js +10 -4
  23. package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
  24. package/build/components/sidebar/index.js +8 -3
  25. package/build/components/sidebar/index.js.map +1 -1
  26. package/build/components/template-part-converter/convert-to-template-part.js +16 -0
  27. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  28. package/build/index.js +4 -1
  29. package/build/index.js.map +1 -1
  30. package/build-module/components/block-editor/index.js +20 -9
  31. package/build-module/components/block-editor/index.js.map +1 -1
  32. package/build-module/components/block-editor/resizable-editor.js +9 -2
  33. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  34. package/build-module/components/editor/index.js +10 -5
  35. package/build-module/components/editor/index.js.map +1 -1
  36. package/build-module/components/global-styles/gradients-palette-panel.js +6 -2
  37. package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
  38. package/build-module/components/global-styles/hooks.js +6 -4
  39. package/build-module/components/global-styles/hooks.js.map +1 -1
  40. package/build-module/components/global-styles/typography-panel.js +41 -5
  41. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  42. package/build-module/components/global-styles/use-global-styles-output.js +42 -30
  43. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  44. package/build-module/components/header/document-actions/index.js +12 -9
  45. package/build-module/components/header/document-actions/index.js.map +1 -1
  46. package/build-module/components/header/index.js +42 -7
  47. package/build-module/components/header/index.js.map +1 -1
  48. package/build-module/components/list/header.js +14 -2
  49. package/build-module/components/list/header.js.map +1 -1
  50. package/build-module/components/navigation-sidebar/navigation-panel/index.js +11 -5
  51. package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
  52. package/build-module/components/sidebar/index.js +7 -3
  53. package/build-module/components/sidebar/index.js.map +1 -1
  54. package/build-module/components/template-part-converter/convert-to-template-part.js +16 -1
  55. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  56. package/build-module/index.js +4 -1
  57. package/build-module/index.js.map +1 -1
  58. package/build-style/style-rtl.css +28 -16
  59. package/build-style/style.css +28 -16
  60. package/package.json +29 -29
  61. package/src/components/block-editor/index.js +34 -16
  62. package/src/components/block-editor/resizable-editor.js +10 -3
  63. package/src/components/code-editor/style.scss +2 -3
  64. package/src/components/editor/index.js +12 -5
  65. package/src/components/global-styles/gradients-palette-panel.js +25 -12
  66. package/src/components/global-styles/hooks.js +5 -4
  67. package/src/components/global-styles/typography-panel.js +40 -6
  68. package/src/components/global-styles/use-global-styles-output.js +66 -57
  69. package/src/components/header/document-actions/index.js +16 -9
  70. package/src/components/header/index.js +61 -21
  71. package/src/components/header/style.scss +9 -0
  72. package/src/components/list/header.js +15 -5
  73. package/src/components/navigation-sidebar/navigation-panel/index.js +30 -24
  74. package/src/components/sidebar/index.js +23 -20
  75. package/src/components/template-part-converter/convert-to-template-part.js +14 -1
  76. package/src/index.js +4 -0
  77. package/src/style.scss +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/edit-site",
3
- "version": "4.13.1-next.957ca95e4c.0",
3
+ "version": "4.14.1",
4
4
  "description": "Edit Site Page module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -27,33 +27,33 @@
27
27
  "react-native": "src/index",
28
28
  "dependencies": {
29
29
  "@babel/runtime": "^7.16.0",
30
- "@wordpress/a11y": "^3.16.1-next.957ca95e4c.0",
31
- "@wordpress/api-fetch": "^6.13.1-next.957ca95e4c.0",
32
- "@wordpress/block-editor": "^9.8.1-next.957ca95e4c.0",
33
- "@wordpress/block-library": "^7.13.1-next.957ca95e4c.0",
34
- "@wordpress/blocks": "^11.15.1-next.957ca95e4c.0",
35
- "@wordpress/components": "^20.0.2-next.957ca95e4c.0",
36
- "@wordpress/compose": "^5.14.1-next.957ca95e4c.0",
37
- "@wordpress/core-data": "^5.0.1-next.957ca95e4c.0",
38
- "@wordpress/data": "^7.0.1-next.957ca95e4c.0",
39
- "@wordpress/deprecated": "^3.16.1-next.957ca95e4c.0",
40
- "@wordpress/editor": "^12.15.1-next.957ca95e4c.0",
41
- "@wordpress/element": "^4.14.1-next.957ca95e4c.0",
42
- "@wordpress/hooks": "^3.16.1-next.957ca95e4c.0",
43
- "@wordpress/html-entities": "^3.16.1-next.957ca95e4c.0",
44
- "@wordpress/i18n": "^4.16.1-next.957ca95e4c.0",
45
- "@wordpress/icons": "^9.7.1-next.957ca95e4c.0",
46
- "@wordpress/interface": "^4.15.1-next.957ca95e4c.0",
47
- "@wordpress/keyboard-shortcuts": "^3.14.1-next.957ca95e4c.0",
48
- "@wordpress/keycodes": "^3.16.1-next.957ca95e4c.0",
49
- "@wordpress/media-utils": "^4.7.1-next.957ca95e4c.0",
50
- "@wordpress/notices": "^3.16.1-next.957ca95e4c.0",
51
- "@wordpress/plugins": "^4.14.1-next.957ca95e4c.0",
52
- "@wordpress/preferences": "^2.8.1-next.957ca95e4c.0",
53
- "@wordpress/reusable-blocks": "^3.14.1-next.957ca95e4c.0",
54
- "@wordpress/style-engine": "^0.15.1-next.957ca95e4c.0",
55
- "@wordpress/url": "^3.17.1-next.957ca95e4c.0",
56
- "@wordpress/viewport": "^4.14.1-next.957ca95e4c.0",
30
+ "@wordpress/a11y": "^3.17.0",
31
+ "@wordpress/api-fetch": "^6.14.0",
32
+ "@wordpress/block-editor": "^10.0.1",
33
+ "@wordpress/block-library": "^7.14.1",
34
+ "@wordpress/blocks": "^11.16.1",
35
+ "@wordpress/components": "^21.0.1",
36
+ "@wordpress/compose": "^5.15.1",
37
+ "@wordpress/core-data": "^5.0.1",
38
+ "@wordpress/data": "^7.1.1",
39
+ "@wordpress/deprecated": "^3.17.0",
40
+ "@wordpress/editor": "^12.16.1",
41
+ "@wordpress/element": "^4.15.0",
42
+ "@wordpress/hooks": "^3.17.0",
43
+ "@wordpress/html-entities": "^3.17.0",
44
+ "@wordpress/i18n": "^4.17.0",
45
+ "@wordpress/icons": "^9.8.0",
46
+ "@wordpress/interface": "^4.16.1",
47
+ "@wordpress/keyboard-shortcuts": "^3.15.1",
48
+ "@wordpress/keycodes": "^3.17.0",
49
+ "@wordpress/media-utils": "^4.8.0",
50
+ "@wordpress/notices": "^3.17.1",
51
+ "@wordpress/plugins": "^4.15.1",
52
+ "@wordpress/preferences": "^2.9.1",
53
+ "@wordpress/reusable-blocks": "^3.15.1",
54
+ "@wordpress/style-engine": "^1.0.0",
55
+ "@wordpress/url": "^3.18.0",
56
+ "@wordpress/viewport": "^4.15.1",
57
57
  "classnames": "^2.3.1",
58
58
  "downloadjs": "^1.4.7",
59
59
  "history": "^5.1.0",
@@ -68,5 +68,5 @@
68
68
  "publishConfig": {
69
69
  "access": "public"
70
70
  },
71
- "gitHead": "272a74bbbaab10ee24424eafe9578e705fbfbbb4"
71
+ "gitHead": "56ef3f5a754e44155ee79e827c7a1d0efc1ee5aa"
72
72
  }
@@ -2,7 +2,6 @@
2
2
  * External dependencies
3
3
  */
4
4
  import classnames from 'classnames';
5
- import { omit, unionBy } from 'lodash';
6
5
 
7
6
  /**
8
7
  * WordPress dependencies
@@ -80,31 +79,50 @@ export default function BlockEditor( { setIsInserterOpen } ) {
80
79
  );
81
80
 
82
81
  const blockPatterns = useMemo(
83
- () => unionBy( settingsBlockPatterns, restBlockPatterns, 'name' ),
84
- [ settingsBlockPatterns, restBlockPatterns ]
82
+ () =>
83
+ [
84
+ ...( settingsBlockPatterns || [] ),
85
+ ...( restBlockPatterns || [] ),
86
+ ]
87
+ .filter(
88
+ ( x, index, arr ) =>
89
+ index === arr.findIndex( ( y ) => x.name === y.name )
90
+ )
91
+ .filter( ( { postTypes } ) => {
92
+ return (
93
+ ! postTypes ||
94
+ ( Array.isArray( postTypes ) &&
95
+ postTypes.includes( templateType ) )
96
+ );
97
+ } ),
98
+ [ settingsBlockPatterns, restBlockPatterns, templateType ]
85
99
  );
86
100
 
87
101
  const blockPatternCategories = useMemo(
88
102
  () =>
89
- unionBy(
90
- settingsBlockPatternCategories,
91
- restBlockPatternCategories,
92
- 'name'
103
+ [
104
+ ...( settingsBlockPatternCategories || [] ),
105
+ ...( restBlockPatternCategories || [] ),
106
+ ].filter(
107
+ ( x, index, arr ) =>
108
+ index === arr.findIndex( ( y ) => x.name === y.name )
93
109
  ),
94
110
  [ settingsBlockPatternCategories, restBlockPatternCategories ]
95
111
  );
96
112
 
97
- const settings = useMemo(
98
- () => ( {
99
- ...omit( storedSettings, [
100
- '__experimentalAdditionalBlockPatterns',
101
- '__experimentalAdditionalBlockPatternCategories',
102
- ] ),
113
+ const settings = useMemo( () => {
114
+ const {
115
+ __experimentalAdditionalBlockPatterns,
116
+ __experimentalAdditionalBlockPatternCategories,
117
+ ...restStoredSettings
118
+ } = storedSettings;
119
+
120
+ return {
121
+ ...restStoredSettings,
103
122
  __experimentalBlockPatterns: blockPatterns,
104
123
  __experimentalBlockPatternCategories: blockPatternCategories,
105
- } ),
106
- [ storedSettings, blockPatterns, blockPatternCategories ]
107
- );
124
+ };
125
+ }, [ storedSettings, blockPatterns, blockPatternCategories ] );
108
126
 
109
127
  const [ blocks, onInput, onChange ] = useEntityBlockEditor(
110
128
  'postType',
@@ -8,6 +8,7 @@ import {
8
8
  __unstableEditorStyles as EditorStyles,
9
9
  __unstableIframe as Iframe,
10
10
  __unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,
11
+ store as blockEditorStore,
11
12
  } from '@wordpress/block-editor';
12
13
  import { useSelect } from '@wordpress/data';
13
14
  import { useMergeRefs } from '@wordpress/compose';
@@ -37,9 +38,14 @@ const HANDLE_STYLES_OVERRIDE = {
37
38
  };
38
39
 
39
40
  function ResizableEditor( { enableResizing, settings, children, ...props } ) {
40
- const deviceType = useSelect(
41
- ( select ) =>
42
- select( editSiteStore ).__experimentalGetPreviewDeviceType(),
41
+ const { deviceType, isZoomOutMode } = useSelect(
42
+ ( select ) => ( {
43
+ deviceType:
44
+ select( editSiteStore ).__experimentalGetPreviewDeviceType(),
45
+ isZoomOutMode:
46
+ select( blockEditorStore ).__unstableGetEditorMode() ===
47
+ 'zoom-out',
48
+ } ),
43
49
  []
44
50
  );
45
51
  const deviceStyles = useResizeCanvas( deviceType );
@@ -163,6 +169,7 @@ function ResizableEditor( { enableResizing, settings, children, ...props } ) {
163
169
  } }
164
170
  >
165
171
  <Iframe
172
+ isZoomedOut={ isZoomOutMode }
166
173
  style={ enableResizing ? { height } : deviceStyles }
167
174
  head={
168
175
  <>
@@ -6,14 +6,13 @@
6
6
 
7
7
  &__body {
8
8
  width: 100%;
9
- padding: 0 $grid-unit-15 $grid-unit-15 $grid-unit-15;
9
+ padding: $grid-unit-15;
10
10
  max-width: $break-xlarge;
11
11
  margin-left: auto;
12
12
  margin-right: auto;
13
13
 
14
14
  @include break-large() {
15
- padding: $grid-unit-20 $grid-unit-30 #{ $grid-unit-60 * 2 } $grid-unit-30;
16
- padding: 0 $grid-unit-30 $grid-unit-30 $grid-unit-30;
15
+ padding: $grid-unit-30;
17
16
  }
18
17
  }
19
18
 
@@ -9,6 +9,7 @@ import {
9
9
  BlockContextProvider,
10
10
  BlockBreadcrumb,
11
11
  BlockStyles,
12
+ store as blockEditorStore,
12
13
  } from '@wordpress/block-editor';
13
14
  import {
14
15
  InterfaceSkeleton,
@@ -77,6 +78,7 @@ function Editor( { onError } ) {
77
78
  nextShortcut,
78
79
  editorMode,
79
80
  showIconLabels,
81
+ blockEditorMode,
80
82
  } = useSelect( ( select ) => {
81
83
  const {
82
84
  isInserterOpened,
@@ -89,6 +91,7 @@ function Editor( { onError } ) {
89
91
  getEditorMode,
90
92
  } = select( editSiteStore );
91
93
  const { hasFinishedResolution, getEntityRecord } = select( coreStore );
94
+ const { __unstableGetEditorMode } = select( blockEditorStore );
92
95
  const postType = getEditedPostType();
93
96
  const postId = getEditedPostId();
94
97
 
@@ -125,6 +128,7 @@ function Editor( { onError } ) {
125
128
  'core/edit-site',
126
129
  'showIconLabels'
127
130
  ),
131
+ blockEditorMode: __unstableGetEditorMode(),
128
132
  };
129
133
  }, [] );
130
134
  const { setPage, setIsInserterOpened } = useDispatch( editSiteStore );
@@ -320,11 +324,14 @@ function Editor( { onError } ) {
320
324
  </>
321
325
  }
322
326
  footer={
323
- <BlockBreadcrumb
324
- rootLabelText={ __(
325
- 'Template'
326
- ) }
327
- />
327
+ blockEditorMode !==
328
+ 'zoom-out' ? (
329
+ <BlockBreadcrumb
330
+ rootLabelText={ __(
331
+ 'Template'
332
+ ) }
333
+ />
334
+ ) : undefined
328
335
  }
329
336
  shortcuts={ {
330
337
  previous: previousShortcut,
@@ -45,7 +45,18 @@ export default function GradientPalettePanel( { name } ) {
45
45
  'color.defaultGradients',
46
46
  name
47
47
  );
48
- const [ duotonePalette ] = useSetting( 'color.duotone' ) || [];
48
+
49
+ const [ customDuotone ] = useSetting( 'color.duotone.custom' ) || [];
50
+ const [ defaultDuotone ] = useSetting( 'color.duotone.default' ) || [];
51
+ const [ themeDuotone ] = useSetting( 'color.duotone.theme' ) || [];
52
+ const [ defaultDuotoneEnabled ] = useSetting( 'color.defaultDuotone' );
53
+
54
+ const duotonePalette = [
55
+ ...( customDuotone || [] ),
56
+ ...( themeDuotone || [] ),
57
+ ...( defaultDuotone && defaultDuotoneEnabled ? defaultDuotone : [] ),
58
+ ];
59
+
49
60
  return (
50
61
  <VStack
51
62
  className="edit-site-global-styles-gradient-palette-panel"
@@ -80,17 +91,19 @@ export default function GradientPalettePanel( { name } ) {
80
91
  ) }
81
92
  slugPrefix="custom-"
82
93
  />
83
- <div>
84
- <Subtitle>{ __( 'Duotone' ) }</Subtitle>
85
- <Spacer margin={ 3 } />
86
- <DuotonePicker
87
- duotonePalette={ duotonePalette }
88
- disableCustomDuotone={ true }
89
- disableCustomColors={ true }
90
- clearable={ false }
91
- onChange={ noop }
92
- />
93
- </div>
94
+ { !! duotonePalette && !! duotonePalette.length && (
95
+ <div>
96
+ <Subtitle>{ __( 'Duotone' ) }</Subtitle>
97
+ <Spacer margin={ 3 } />
98
+ <DuotonePicker
99
+ duotonePalette={ duotonePalette }
100
+ disableCustomDuotone={ true }
101
+ disableCustomColors={ true }
102
+ clearable={ false }
103
+ onChange={ noop }
104
+ />
105
+ </div>
106
+ ) }
94
107
  </VStack>
95
108
  );
96
109
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { get, cloneDeep, set, isEqual } from 'lodash';
4
+ import { get, set, isEqual } from 'lodash';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -48,7 +48,8 @@ export function useSetting( path, blockName, source = 'all' ) {
48
48
 
49
49
  const setSetting = ( newValue ) => {
50
50
  setUserConfig( ( currentConfig ) => {
51
- const newUserConfig = cloneDeep( currentConfig );
51
+ // Deep clone `currentConfig` to avoid mutating it later.
52
+ const newUserConfig = JSON.parse( JSON.stringify( currentConfig ) );
52
53
  const pathToSet = PATHS_WITH_MERGE[ path ]
53
54
  ? fullPath + '.custom'
54
55
  : fullPath;
@@ -109,7 +110,8 @@ export function useStyle( path, blockName, source = 'all' ) {
109
110
 
110
111
  const setStyle = ( newValue ) => {
111
112
  setUserConfig( ( currentConfig ) => {
112
- const newUserConfig = cloneDeep( currentConfig );
113
+ // Deep clone `currentConfig` to avoid mutating it later.
114
+ const newUserConfig = JSON.parse( JSON.stringify( currentConfig ) );
113
115
  set(
114
116
  newUserConfig,
115
117
  finalPath,
@@ -166,7 +168,6 @@ const ROOT_BLOCK_SUPPORTS = [
166
168
  'fontWeight',
167
169
  'lineHeight',
168
170
  'textDecoration',
169
- 'textTransform',
170
171
  'padding',
171
172
  'contentSize',
172
173
  'wideSize',
@@ -6,6 +6,7 @@ import {
6
6
  __experimentalFontFamilyControl as FontFamilyControl,
7
7
  __experimentalFontAppearanceControl as FontAppearanceControl,
8
8
  __experimentalLetterSpacingControl as LetterSpacingControl,
9
+ __experimentalTextTransformControl as TextTransformControl,
9
10
  } from '@wordpress/block-editor';
10
11
  import {
11
12
  PanelBody,
@@ -53,12 +54,28 @@ function useHasAppearanceControl( name ) {
53
54
  return hasFontStyles || hasFontWeights;
54
55
  }
55
56
 
56
- function useHasLetterSpacingControl( name ) {
57
+ function useHasLetterSpacingControl( name, element ) {
58
+ const setting = useSetting( 'typography.letterSpacing', name )[ 0 ];
59
+ if ( ! setting ) {
60
+ return false;
61
+ }
62
+ if ( ! name && element === 'heading' ) {
63
+ return true;
64
+ }
57
65
  const supports = getSupportedGlobalStylesPanels( name );
58
- return (
59
- useSetting( 'typography.letterSpacing', name )[ 0 ] &&
60
- supports.includes( 'letterSpacing' )
61
- );
66
+ return supports.includes( 'letterSpacing' );
67
+ }
68
+
69
+ function useHasTextTransformControl( name, element ) {
70
+ const setting = useSetting( 'typography.textTransform', name )[ 0 ];
71
+ if ( ! setting ) {
72
+ return false;
73
+ }
74
+ if ( ! name && element === 'heading' ) {
75
+ return true;
76
+ }
77
+ const supports = getSupportedGlobalStylesPanels( name );
78
+ return supports.includes( 'textTransform' );
62
79
  }
63
80
 
64
81
  export default function TypographyPanel( { name, element } ) {
@@ -84,7 +101,8 @@ export default function TypographyPanel( { name, element } ) {
84
101
  supports.includes( 'fontWeight' );
85
102
  const hasLineHeightEnabled = useHasLineHeightControl( name );
86
103
  const hasAppearanceControl = useHasAppearanceControl( name );
87
- const hasLetterSpacingControl = useHasLetterSpacingControl( name );
104
+ const hasLetterSpacingControl = useHasLetterSpacingControl( name, element );
105
+ const hasTextTransformControl = useHasTextTransformControl( name, element );
88
106
 
89
107
  /* Disable font size controls when the option to style all headings is selected. */
90
108
  let hasFontSizeEnabled = supports.includes( 'fontSize' );
@@ -117,6 +135,10 @@ export default function TypographyPanel( { name, element } ) {
117
135
  prefix + 'typography.letterSpacing',
118
136
  name
119
137
  );
138
+ const [ textTransform, setTextTransform ] = useStyle(
139
+ prefix + 'typography.textTransform',
140
+ name
141
+ );
120
142
  const [ backgroundColor ] = useStyle( prefix + 'color.background', name );
121
143
  const [ gradientValue ] = useStyle( prefix + 'color.gradient', name );
122
144
  const [ color ] = useStyle( prefix + 'color.text', name );
@@ -248,6 +270,18 @@ export default function TypographyPanel( { name, element } ) {
248
270
  __unstableInputWidth="auto"
249
271
  />
250
272
  ) }
273
+ { hasTextTransformControl && (
274
+ <div className="edit-site-typography-panel__full-width-control">
275
+ <TextTransformControl
276
+ value={ textTransform }
277
+ onChange={ setTextTransform }
278
+ showNone
279
+ isBlock
280
+ size="__unstable-large"
281
+ __nextHasNoMarginBottom
282
+ />
283
+ </div>
284
+ ) }
251
285
  </Grid>
252
286
  </PanelBody>
253
287
  );
@@ -1,16 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import {
5
- first,
6
- forEach,
7
- get,
8
- isEmpty,
9
- kebabCase,
10
- pickBy,
11
- reduce,
12
- set,
13
- } from 'lodash';
4
+ import { get, isEmpty, kebabCase, pickBy, reduce, set } from 'lodash';
14
5
 
15
6
  /**
16
7
  * WordPress dependencies
@@ -208,7 +199,7 @@ export function getStylesDeclarations(
208
199
  return declarations;
209
200
  }
210
201
  const pathToValue = value;
211
- if ( first( pathToValue ) === 'elements' || useEngine ) {
202
+ if ( pathToValue[ 0 ] === 'elements' || useEngine ) {
212
203
  return declarations;
213
204
  }
214
205
 
@@ -330,8 +321,8 @@ export function getLayoutStyles( {
330
321
  if ( gapValue && tree?.settings?.layout?.definitions ) {
331
322
  Object.values( tree.settings.layout.definitions ).forEach(
332
323
  ( { className, name, spacingStyles } ) => {
333
- // Allow skipping default layout for themes that opt-in to block styles, but opt-out of blockGap.
334
- if ( ! hasBlockGapSupport && 'default' === name ) {
324
+ // Allow outputting fallback gap styles for flex layout type when block gap support isn't available.
325
+ if ( ! hasBlockGapSupport && 'flex' !== name ) {
335
326
  return;
336
327
  }
337
328
 
@@ -457,7 +448,7 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
457
448
  } );
458
449
  }
459
450
 
460
- forEach( ELEMENTS, ( selector, name ) => {
451
+ Object.entries( ELEMENTS ).forEach( ( [ name, selector ] ) => {
461
452
  if ( !! tree.styles?.elements[ name ] ) {
462
453
  nodes.push( {
463
454
  styles: tree.styles?.elements[ name ],
@@ -467,42 +458,53 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
467
458
  } );
468
459
 
469
460
  // Iterate over blocks: they can have styles & elements.
470
- forEach( tree.styles?.blocks, ( node, blockName ) => {
471
- const blockStyles = pickStyleKeys( node );
472
- if ( !! blockStyles && !! blockSelectors?.[ blockName ]?.selector ) {
473
- nodes.push( {
474
- duotoneSelector: blockSelectors[ blockName ].duotoneSelector,
475
- fallbackGapValue: blockSelectors[ blockName ].fallbackGapValue,
476
- hasLayoutSupport: blockSelectors[ blockName ].hasLayoutSupport,
477
- selector: blockSelectors[ blockName ].selector,
478
- styles: blockStyles,
479
- featureSelectors: blockSelectors[ blockName ].featureSelectors,
480
- } );
481
- }
482
-
483
- forEach( node?.elements, ( value, elementName ) => {
461
+ Object.entries( tree.styles?.blocks ?? {} ).forEach(
462
+ ( [ blockName, node ] ) => {
463
+ const blockStyles = pickStyleKeys( node );
484
464
  if (
485
- !! value &&
486
- !! blockSelectors?.[ blockName ] &&
487
- !! ELEMENTS?.[ elementName ]
465
+ !! blockStyles &&
466
+ !! blockSelectors?.[ blockName ]?.selector
488
467
  ) {
489
468
  nodes.push( {
490
- styles: value,
491
- selector: blockSelectors[ blockName ].selector
492
- .split( ',' )
493
- .map( ( sel ) => {
494
- const elementSelectors =
495
- ELEMENTS[ elementName ].split( ',' );
496
- return elementSelectors.map(
497
- ( elementSelector ) =>
498
- sel + ' ' + elementSelector
499
- );
500
- } )
501
- .join( ',' ),
469
+ duotoneSelector:
470
+ blockSelectors[ blockName ].duotoneSelector,
471
+ fallbackGapValue:
472
+ blockSelectors[ blockName ].fallbackGapValue,
473
+ hasLayoutSupport:
474
+ blockSelectors[ blockName ].hasLayoutSupport,
475
+ selector: blockSelectors[ blockName ].selector,
476
+ styles: blockStyles,
477
+ featureSelectors:
478
+ blockSelectors[ blockName ].featureSelectors,
502
479
  } );
503
480
  }
504
- } );
505
- } );
481
+
482
+ Object.entries( node?.elements ?? {} ).forEach(
483
+ ( [ elementName, value ] ) => {
484
+ if (
485
+ !! value &&
486
+ !! blockSelectors?.[ blockName ] &&
487
+ !! ELEMENTS?.[ elementName ]
488
+ ) {
489
+ nodes.push( {
490
+ styles: value,
491
+ selector: blockSelectors[ blockName ].selector
492
+ .split( ',' )
493
+ .map( ( sel ) => {
494
+ const elementSelectors =
495
+ ELEMENTS[ elementName ].split( ',' );
496
+ return elementSelectors.map(
497
+ ( elementSelector ) =>
498
+ sel + ' ' + elementSelector
499
+ );
500
+ } )
501
+ .join( ',' ),
502
+ } );
503
+ }
504
+ }
505
+ );
506
+ }
507
+ );
506
508
 
507
509
  return nodes;
508
510
  };
@@ -537,17 +539,19 @@ export const getNodesWithSettings = ( tree, blockSelectors ) => {
537
539
  }
538
540
 
539
541
  // Blocks.
540
- forEach( tree.settings?.blocks, ( node, blockName ) => {
541
- const blockPresets = pickPresets( node );
542
- const blockCustom = node.custom;
543
- if ( ! isEmpty( blockPresets ) || !! blockCustom ) {
544
- nodes.push( {
545
- presets: blockPresets,
546
- custom: blockCustom,
547
- selector: blockSelectors[ blockName ].selector,
548
- } );
542
+ Object.entries( tree.settings?.blocks ?? {} ).forEach(
543
+ ( [ blockName, node ] ) => {
544
+ const blockPresets = pickPresets( node );
545
+ const blockCustom = node.custom;
546
+ if ( ! isEmpty( blockPresets ) || !! blockCustom ) {
547
+ nodes.push( {
548
+ presets: blockPresets,
549
+ custom: blockCustom,
550
+ selector: blockSelectors[ blockName ].selector,
551
+ } );
552
+ }
549
553
  }
550
- } );
554
+ );
551
555
 
552
556
  return nodes;
553
557
  };
@@ -601,8 +605,13 @@ export const toStyles = (
601
605
  }
602
606
 
603
607
  if ( useRootPaddingAlign ) {
604
- ruleset +=
605
- 'padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) } .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); } .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); } .has-global-padding > .alignfull > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left);';
608
+ ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
609
+ .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
610
+ .has-global-padding :where(.has-global-padding) { padding-right: 0; padding-left: 0; }
611
+ .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
612
+ .has-global-padding :where(.has-global-padding) > .alignfull { margin-right: 0; margin-left: 0; }
613
+ .has-global-padding > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
614
+ .has-global-padding :where(.has-global-padding) > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: 0; padding-left: 0;`;
606
615
  }
607
616
 
608
617
  ruleset += '}';
@@ -19,7 +19,7 @@ import {
19
19
  __experimentalText as Text,
20
20
  } from '@wordpress/components';
21
21
  import { chevronDown } from '@wordpress/icons';
22
- import { useRef } from '@wordpress/element';
22
+ import { useState, useMemo } from '@wordpress/element';
23
23
  import { store as blockEditorStore } from '@wordpress/block-editor';
24
24
 
25
25
  function getBlockDisplayText( block ) {
@@ -73,10 +73,19 @@ export default function DocumentActions( {
73
73
  } ) {
74
74
  const { label } = useSecondaryText();
75
75
 
76
- // The title ref is passed to the popover as the anchorRef so that the
77
- // dropdown is centered over the whole title area rather than just one
78
- // part of it.
79
- const titleRef = useRef();
76
+ // Use internal state instead of a ref to make sure that the component
77
+ // re-renders when the popover's anchor updates.
78
+ const [ popoverAnchor, setPopoverAnchor ] = useState( null );
79
+
80
+ // Memoize popoverProps to avoid returning a new object every time.
81
+ const popoverProps = useMemo(
82
+ () => ( {
83
+ // Use the title wrapper as the popover anchor so that the dropdown is
84
+ // centered over the whole title area rather than just one part of it.
85
+ anchor: popoverAnchor,
86
+ } ),
87
+ [ popoverAnchor ]
88
+ );
80
89
 
81
90
  // Return a simple loading indicator until we have information to show.
82
91
  if ( ! isLoaded ) {
@@ -103,7 +112,7 @@ export default function DocumentActions( {
103
112
  } ) }
104
113
  >
105
114
  <div
106
- ref={ titleRef }
115
+ ref={ setPopoverAnchor }
107
116
  className="edit-site-document-actions__title-wrapper"
108
117
  >
109
118
  <Text
@@ -130,9 +139,7 @@ export default function DocumentActions( {
130
139
 
131
140
  { dropdownContent && (
132
141
  <Dropdown
133
- popoverProps={ {
134
- anchorRef: titleRef.current,
135
- } }
142
+ popoverProps={ popoverProps }
136
143
  position="bottom center"
137
144
  renderToggle={ ( { isOpen, onToggle } ) => (
138
145
  <Button