@wordpress/edit-site 4.11.0 → 4.13.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 (180) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/add-new-template/add-custom-template-modal.js +4 -2
  3. package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
  4. package/build/components/add-new-template/new-template.js +29 -4
  5. package/build/components/add-new-template/new-template.js.map +1 -1
  6. package/build/components/add-new-template/utils.js +152 -28
  7. package/build/components/add-new-template/utils.js.map +1 -1
  8. package/build/components/block-editor/resizable-editor.js +26 -12
  9. package/build/components/block-editor/resizable-editor.js.map +1 -1
  10. package/build/components/global-styles/border-panel.js +3 -3
  11. package/build/components/global-styles/border-panel.js.map +1 -1
  12. package/build/components/global-styles/dimensions-panel.js +98 -8
  13. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  14. package/build/components/global-styles/hooks.js +4 -4
  15. package/build/components/global-styles/hooks.js.map +1 -1
  16. package/build/components/global-styles/screen-color-palette.js +1 -1
  17. package/build/components/global-styles/screen-color-palette.js.map +1 -1
  18. package/build/components/global-styles/screen-colors.js +51 -7
  19. package/build/components/global-styles/screen-colors.js.map +1 -1
  20. package/build/components/global-styles/screen-heading-color.js +157 -0
  21. package/build/components/global-styles/screen-heading-color.js.map +1 -0
  22. package/build/components/global-styles/screen-typography-element.js +4 -0
  23. package/build/components/global-styles/screen-typography-element.js.map +1 -1
  24. package/build/components/global-styles/screen-typography.js +5 -0
  25. package/build/components/global-styles/screen-typography.js.map +1 -1
  26. package/build/components/global-styles/typography-panel.js +82 -14
  27. package/build/components/global-styles/typography-panel.js.map +1 -1
  28. package/build/components/global-styles/typography-utils.js +217 -0
  29. package/build/components/global-styles/typography-utils.js.map +1 -0
  30. package/build/components/global-styles/ui.js +11 -0
  31. package/build/components/global-styles/ui.js.map +1 -1
  32. package/build/components/global-styles/use-global-styles-output.js +102 -49
  33. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  34. package/build/components/global-styles/utils.js +54 -5
  35. package/build/components/global-styles/utils.js.map +1 -1
  36. package/build/components/header/document-actions/index.js +1 -0
  37. package/build/components/header/document-actions/index.js.map +1 -1
  38. package/build/components/header/index.js +20 -6
  39. package/build/components/header/index.js.map +1 -1
  40. package/build/components/header/mode-switcher/index.js +0 -4
  41. package/build/components/header/mode-switcher/index.js.map +1 -1
  42. package/build/components/header/more-menu/index.js +13 -3
  43. package/build/components/header/more-menu/index.js.map +1 -1
  44. package/build/components/header/undo-redo/redo.js +2 -1
  45. package/build/components/header/undo-redo/redo.js.map +1 -1
  46. package/build/components/list/actions/index.js +1 -1
  47. package/build/components/list/actions/index.js.map +1 -1
  48. package/build/components/save-button/index.js +2 -3
  49. package/build/components/save-button/index.js.map +1 -1
  50. package/build/components/sidebar/default-sidebar.js +11 -1
  51. package/build/components/sidebar/default-sidebar.js.map +1 -1
  52. package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js +2 -2
  53. package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -1
  54. package/build/components/sidebar/plugin-sidebar/index.js +11 -1
  55. package/build/components/sidebar/plugin-sidebar/index.js.map +1 -1
  56. package/build/components/sidebar/template-card/template-actions.js +1 -1
  57. package/build/components/sidebar/template-card/template-actions.js.map +1 -1
  58. package/build/components/template-details/edit-template-title.js +1 -1
  59. package/build/components/template-details/edit-template-title.js.map +1 -1
  60. package/build/components/template-details/index.js +19 -9
  61. package/build/components/template-details/index.js.map +1 -1
  62. package/build/components/template-details/template-areas.js +1 -1
  63. package/build/components/template-details/template-areas.js.map +1 -1
  64. package/build/components/template-details/template-part-area-selector.js +47 -0
  65. package/build/components/template-details/template-part-area-selector.js.map +1 -0
  66. package/build/components/template-part-converter/convert-to-template-part.js +4 -1
  67. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  68. package/build/index.js +1 -1
  69. package/build/index.js.map +1 -1
  70. package/build-module/components/add-new-template/add-custom-template-modal.js +4 -2
  71. package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
  72. package/build-module/components/add-new-template/new-template.js +29 -6
  73. package/build-module/components/add-new-template/new-template.js.map +1 -1
  74. package/build-module/components/add-new-template/utils.js +147 -26
  75. package/build-module/components/add-new-template/utils.js.map +1 -1
  76. package/build-module/components/block-editor/resizable-editor.js +26 -12
  77. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  78. package/build-module/components/global-styles/border-panel.js +3 -3
  79. package/build-module/components/global-styles/border-panel.js.map +1 -1
  80. package/build-module/components/global-styles/dimensions-panel.js +96 -9
  81. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  82. package/build-module/components/global-styles/hooks.js +4 -4
  83. package/build-module/components/global-styles/hooks.js.map +1 -1
  84. package/build-module/components/global-styles/screen-color-palette.js +1 -1
  85. package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
  86. package/build-module/components/global-styles/screen-colors.js +51 -7
  87. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  88. package/build-module/components/global-styles/screen-heading-color.js +143 -0
  89. package/build-module/components/global-styles/screen-heading-color.js.map +1 -0
  90. package/build-module/components/global-styles/screen-typography-element.js +4 -0
  91. package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
  92. package/build-module/components/global-styles/screen-typography.js +5 -0
  93. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  94. package/build-module/components/global-styles/typography-panel.js +83 -15
  95. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  96. package/build-module/components/global-styles/typography-utils.js +204 -0
  97. package/build-module/components/global-styles/typography-utils.js.map +1 -0
  98. package/build-module/components/global-styles/ui.js +10 -0
  99. package/build-module/components/global-styles/ui.js.map +1 -1
  100. package/build-module/components/global-styles/use-global-styles-output.js +102 -53
  101. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  102. package/build-module/components/global-styles/utils.js +53 -5
  103. package/build-module/components/global-styles/utils.js.map +1 -1
  104. package/build-module/components/header/document-actions/index.js +1 -0
  105. package/build-module/components/header/document-actions/index.js.map +1 -1
  106. package/build-module/components/header/index.js +22 -8
  107. package/build-module/components/header/index.js.map +1 -1
  108. package/build-module/components/header/mode-switcher/index.js +0 -4
  109. package/build-module/components/header/mode-switcher/index.js.map +1 -1
  110. package/build-module/components/header/more-menu/index.js +13 -3
  111. package/build-module/components/header/more-menu/index.js.map +1 -1
  112. package/build-module/components/header/undo-redo/redo.js +3 -2
  113. package/build-module/components/header/undo-redo/redo.js.map +1 -1
  114. package/build-module/components/list/actions/index.js +1 -1
  115. package/build-module/components/list/actions/index.js.map +1 -1
  116. package/build-module/components/save-button/index.js +3 -4
  117. package/build-module/components/save-button/index.js.map +1 -1
  118. package/build-module/components/sidebar/default-sidebar.js +9 -1
  119. package/build-module/components/sidebar/default-sidebar.js.map +1 -1
  120. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js +3 -3
  121. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -1
  122. package/build-module/components/sidebar/plugin-sidebar/index.js +9 -1
  123. package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -1
  124. package/build-module/components/sidebar/template-card/template-actions.js +1 -1
  125. package/build-module/components/sidebar/template-card/template-actions.js.map +1 -1
  126. package/build-module/components/template-details/edit-template-title.js +1 -1
  127. package/build-module/components/template-details/edit-template-title.js.map +1 -1
  128. package/build-module/components/template-details/index.js +19 -10
  129. package/build-module/components/template-details/index.js.map +1 -1
  130. package/build-module/components/template-details/template-areas.js +1 -1
  131. package/build-module/components/template-details/template-areas.js.map +1 -1
  132. package/build-module/components/template-details/template-part-area-selector.js +35 -0
  133. package/build-module/components/template-details/template-part-area-selector.js.map +1 -0
  134. package/build-module/components/template-part-converter/convert-to-template-part.js +3 -1
  135. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  136. package/build-module/index.js +1 -1
  137. package/build-module/index.js.map +1 -1
  138. package/build-style/style-rtl.css +15 -8
  139. package/build-style/style.css +15 -8
  140. package/package.json +29 -29
  141. package/src/components/add-new-template/add-custom-template-modal.js +12 -3
  142. package/src/components/add-new-template/new-template.js +53 -24
  143. package/src/components/add-new-template/utils.js +145 -16
  144. package/src/components/block-editor/resizable-editor.js +28 -18
  145. package/src/components/editor/style.scss +1 -0
  146. package/src/components/global-styles/border-panel.js +3 -3
  147. package/src/components/global-styles/dimensions-panel.js +139 -33
  148. package/src/components/global-styles/hooks.js +4 -3
  149. package/src/components/global-styles/screen-color-palette.js +1 -1
  150. package/src/components/global-styles/screen-colors.js +46 -4
  151. package/src/components/global-styles/screen-heading-color.js +201 -0
  152. package/src/components/global-styles/screen-typography-element.js +4 -0
  153. package/src/components/global-styles/screen-typography.js +6 -0
  154. package/src/components/global-styles/style.scss +14 -6
  155. package/src/components/global-styles/test/typography-utils.js +130 -0
  156. package/src/components/global-styles/test/use-global-styles-output.js +79 -3
  157. package/src/components/global-styles/test/utils.js +68 -8
  158. package/src/components/global-styles/typography-panel.js +119 -48
  159. package/src/components/global-styles/typography-utils.js +228 -0
  160. package/src/components/global-styles/ui.js +13 -0
  161. package/src/components/global-styles/use-global-styles-output.js +119 -61
  162. package/src/components/global-styles/utils.js +39 -4
  163. package/src/components/header/document-actions/index.js +3 -0
  164. package/src/components/header/index.js +32 -4
  165. package/src/components/header/mode-switcher/index.js +0 -3
  166. package/src/components/header/more-menu/index.js +7 -2
  167. package/src/components/header/undo-redo/redo.js +6 -2
  168. package/src/components/list/actions/index.js +3 -1
  169. package/src/components/save-button/index.js +10 -13
  170. package/src/components/sidebar/default-sidebar.js +12 -0
  171. package/src/components/sidebar/navigation-menu-sidebar/navigation-menu.js +1 -5
  172. package/src/components/sidebar/plugin-sidebar/index.js +12 -0
  173. package/src/components/sidebar/template-card/template-actions.js +3 -1
  174. package/src/components/template-details/edit-template-title.js +7 -3
  175. package/src/components/template-details/index.js +23 -8
  176. package/src/components/template-details/style.scss +0 -5
  177. package/src/components/template-details/template-areas.js +3 -1
  178. package/src/components/template-details/template-part-area-selector.js +38 -0
  179. package/src/components/template-part-converter/convert-to-template-part.js +3 -1
  180. package/src/index.js +1 -1
@@ -3,6 +3,11 @@
3
3
  */
4
4
  import { get, find } from 'lodash';
5
5
 
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { getTypographyFontSizeValue } from './typography-utils';
10
+
6
11
  /* Supporting data. */
7
12
  export const ROOT_BLOCK_NAME = 'root';
8
13
  export const ROOT_BLOCK_SELECTOR = 'body';
@@ -58,6 +63,8 @@ export const PRESET_METADATA = [
58
63
  },
59
64
  {
60
65
  path: [ 'typography', 'fontSizes' ],
66
+ valueFunc: ( preset, { typography: typographySettings } ) =>
67
+ getTypographyFontSizeValue( preset, typographySettings ),
61
68
  valueKey: 'size',
62
69
  cssVarInfix: 'font-size',
63
70
  classes: [ { classSuffix: 'font-size', propertyName: 'font-size' } ],
@@ -70,6 +77,13 @@ export const PRESET_METADATA = [
70
77
  { classSuffix: 'font-family', propertyName: 'font-family' },
71
78
  ],
72
79
  },
80
+ {
81
+ path: [ 'spacing', 'spacingSizes' ],
82
+ valueKey: 'spacingSizes',
83
+ cssVarInfix: 'spacing',
84
+ valueFunc: ( { size } ) => size,
85
+ classes: [],
86
+ },
73
87
  ];
74
88
 
75
89
  const STYLE_PATH_TO_CSS_VAR_INFIX = {
@@ -78,6 +92,9 @@ const STYLE_PATH_TO_CSS_VAR_INFIX = {
78
92
  'elements.link.color.text': 'color',
79
93
  'elements.button.color.text': 'color',
80
94
  'elements.button.backgroundColor': 'background-color',
95
+ 'elements.heading.color': 'color',
96
+ 'elements.heading.backgroundColor': 'background-color',
97
+ 'elements.heading.gradient': 'gradient',
81
98
  'color.gradient': 'gradient',
82
99
  'typography.fontSize': 'font-size',
83
100
  'typography.fontFamily': 'font-family',
@@ -185,7 +202,7 @@ function getValueFromPresetVariable(
185
202
  }
186
203
 
187
204
  const presetObject = findInPresetsBy(
188
- features,
205
+ features.settings,
189
206
  blockName,
190
207
  metadata.path,
191
208
  'slug',
@@ -203,8 +220,8 @@ function getValueFromPresetVariable(
203
220
 
204
221
  function getValueFromCustomVariable( features, blockName, variable, path ) {
205
222
  const result =
206
- get( features, [ 'blocks', blockName, 'custom', ...path ] ) ??
207
- get( features, [ 'custom', ...path ] );
223
+ get( features.settings, [ 'blocks', blockName, 'custom', ...path ] ) ??
224
+ get( features.settings, [ 'custom', ...path ] );
208
225
  if ( ! result ) {
209
226
  return variable;
210
227
  }
@@ -212,9 +229,27 @@ function getValueFromCustomVariable( features, blockName, variable, path ) {
212
229
  return getValueFromVariable( features, blockName, result );
213
230
  }
214
231
 
232
+ /**
233
+ * Attempts to fetch the value of a theme.json CSS variable.
234
+ *
235
+ * @param {Object} features GlobalStylesContext config, e.g., user, base or merged. Represents the theme.json tree.
236
+ * @param {string} blockName The name of a block as represented in the styles property. E.g., 'root' for root-level, and 'core/${blockName}' for blocks.
237
+ * @param {string|*} variable An incoming style value. A CSS var value is expected, but it could be any value.
238
+ * @return {string|*|{ref}} The value of the CSS var, if found. If not found, the passed variable argument.
239
+ */
215
240
  export function getValueFromVariable( features, blockName, variable ) {
216
241
  if ( ! variable || typeof variable !== 'string' ) {
217
- return variable;
242
+ if ( variable?.ref && typeof variable?.ref === 'string' ) {
243
+ const refPath = variable.ref.split( '.' );
244
+ variable = get( features, refPath );
245
+ // Presence of another ref indicates a reference to another dynamic value.
246
+ // Pointing to another dynamic value is not supported.
247
+ if ( ! variable || !! variable?.ref ) {
248
+ return variable;
249
+ }
250
+ } else {
251
+ return variable;
252
+ }
218
253
  }
219
254
  const USER_VALUE_PREFIX = 'var:';
220
255
  const THEME_VALUE_PREFIX = 'var(--wp--';
@@ -141,6 +141,9 @@ export default function DocumentActions( {
141
141
  aria-expanded={ isOpen }
142
142
  aria-haspopup="true"
143
143
  onClick={ onToggle }
144
+ variant={
145
+ showIconLabels ? 'tertiary' : undefined
146
+ }
144
147
  label={ sprintf(
145
148
  /* translators: %s: the entity to see details about, like "template"*/
146
149
  __( 'Show %s details' ),
@@ -11,8 +11,14 @@ import {
11
11
  import { useSelect, useDispatch } from '@wordpress/data';
12
12
  import { PinnedItems } from '@wordpress/interface';
13
13
  import { _x, __ } from '@wordpress/i18n';
14
- import { listView, plus } from '@wordpress/icons';
15
- import { Button, ToolbarItem } from '@wordpress/components';
14
+ import { listView, plus, external } from '@wordpress/icons';
15
+ import {
16
+ Button,
17
+ ToolbarItem,
18
+ MenuGroup,
19
+ MenuItem,
20
+ VisuallyHidden,
21
+ } from '@wordpress/components';
16
22
  import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
17
23
  import { store as editorStore } from '@wordpress/editor';
18
24
  import { store as coreStore } from '@wordpress/core-data';
@@ -48,6 +54,7 @@ export default function Header( {
48
54
  listViewShortcut,
49
55
  isLoaded,
50
56
  isVisualMode,
57
+ settings,
51
58
  } = useSelect( ( select ) => {
52
59
  const {
53
60
  __experimentalGetPreviewDeviceType,
@@ -56,6 +63,7 @@ export default function Header( {
56
63
  isInserterOpened,
57
64
  isListViewOpened,
58
65
  getEditorMode,
66
+ getSettings,
59
67
  } = select( editSiteStore );
60
68
  const { getEditedEntityRecord } = select( coreStore );
61
69
  const { __experimentalGetTemplateInfo: getTemplateInfo } =
@@ -79,6 +87,7 @@ export default function Header( {
79
87
  'core/edit-site/toggle-list-view'
80
88
  ),
81
89
  isVisualMode: getEditorMode() === 'visual',
90
+ settings: getSettings(),
82
91
  };
83
92
  }, [] );
84
93
 
@@ -168,6 +177,9 @@ export default function Header( {
168
177
  onClick={ toggleListView }
169
178
  shortcut={ listViewShortcut }
170
179
  showTooltip={ ! showIconLabels }
180
+ variant={
181
+ showIconLabels ? 'tertiary' : undefined
182
+ }
171
183
  />
172
184
  </>
173
185
  ) }
@@ -200,14 +212,30 @@ export default function Header( {
200
212
  <PreviewOptions
201
213
  deviceType={ deviceType }
202
214
  setDeviceType={ setPreviewDeviceType }
203
- />
215
+ >
216
+ <MenuGroup>
217
+ <MenuItem
218
+ href={ settings?.siteUrl }
219
+ target="_blank"
220
+ icon={ external }
221
+ >
222
+ { __( 'View site' ) }
223
+ <VisuallyHidden as="span">
224
+ {
225
+ /* translators: accessibility text */
226
+ __( '(opens in a new tab)' )
227
+ }
228
+ </VisuallyHidden>
229
+ </MenuItem>
230
+ </MenuGroup>
231
+ </PreviewOptions>
204
232
  ) }
205
233
  <SaveButton
206
234
  openEntitiesSavedStates={ openEntitiesSavedStates }
207
235
  isEntitiesSavedStatesOpen={ isEntitiesSavedStatesOpen }
208
236
  />
209
237
  <PinnedItems.Slot scope="core/edit-site" />
210
- <MoreMenu />
238
+ <MoreMenu showIconLabels={ showIconLabels } />
211
239
  </div>
212
240
  </div>
213
241
  </div>
@@ -6,9 +6,6 @@ import { MenuItemsChoice, MenuGroup } from '@wordpress/components';
6
6
  import { useSelect, useDispatch } from '@wordpress/data';
7
7
  import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
8
8
 
9
- /**
10
- * Internal dependencies
11
- */
12
9
  /**
13
10
  * Internal dependencies
14
11
  */
@@ -21,7 +21,7 @@ import WelcomeGuideMenuItem from './welcome-guide-menu-item';
21
21
  import CopyContentMenuItem from './copy-content-menu-item';
22
22
  import ModeSwitcher from '../mode-switcher';
23
23
 
24
- export default function MoreMenu() {
24
+ export default function MoreMenu( { showIconLabels } ) {
25
25
  const [ isModalActive, toggleModal ] = useReducer(
26
26
  ( isActive ) => ! isActive,
27
27
  false
@@ -36,7 +36,12 @@ export default function MoreMenu() {
36
36
 
37
37
  return (
38
38
  <>
39
- <MoreMenuDropdown>
39
+ <MoreMenuDropdown
40
+ toggleProps={ {
41
+ showTooltip: ! showIconLabels,
42
+ ...( showIconLabels && { variant: 'tertiary' } ),
43
+ } }
44
+ >
40
45
  { ( { onClose } ) => (
41
46
  <>
42
47
  <MenuGroup label={ _x( 'View', 'noun' ) }>
@@ -5,11 +5,15 @@ import { __, isRTL } from '@wordpress/i18n';
5
5
  import { Button } from '@wordpress/components';
6
6
  import { useSelect, useDispatch } from '@wordpress/data';
7
7
  import { redo as redoIcon, undo as undoIcon } from '@wordpress/icons';
8
- import { displayShortcut } from '@wordpress/keycodes';
8
+ import { displayShortcut, isAppleOS } from '@wordpress/keycodes';
9
9
  import { store as coreStore } from '@wordpress/core-data';
10
10
  import { forwardRef } from '@wordpress/element';
11
11
 
12
12
  function RedoButton( props, ref ) {
13
+ const shortcut = isAppleOS()
14
+ ? displayShortcut.primaryShift( 'z' )
15
+ : displayShortcut.primary( 'y' );
16
+
13
17
  const hasRedo = useSelect(
14
18
  ( select ) => select( coreStore ).hasRedo(),
15
19
  []
@@ -21,7 +25,7 @@ function RedoButton( props, ref ) {
21
25
  ref={ ref }
22
26
  icon={ ! isRTL() ? redoIcon : undoIcon }
23
27
  label={ __( 'Redo' ) }
24
- shortcut={ displayShortcut.primaryShift( 'z' ) }
28
+ shortcut={ shortcut }
25
29
  // If there are no undo levels we don't want to actually disable this
26
30
  // button, because it will remove focus for keyboard users.
27
31
  // See: https://github.com/WordPress/gutenberg/issues/3486
@@ -79,7 +79,9 @@ export default function Actions( { template } ) {
79
79
  ) }
80
80
  { isRevertable && (
81
81
  <MenuItem
82
- info={ __( 'Restore to default state' ) }
82
+ info={ __(
83
+ 'Use the template as supplied by the theme.'
84
+ ) }
83
85
  onClick={ () => {
84
86
  revertAndSaveTemplate();
85
87
  onClose();
@@ -30,18 +30,15 @@ export default function SaveButton( {
30
30
  const disabled = ! isDirty || isSaving;
31
31
 
32
32
  return (
33
- <>
34
- <Button
35
- variant="primary"
36
- className="edit-site-save-button__button"
37
- aria-disabled={ disabled }
38
- aria-expanded={ isEntitiesSavedStatesOpen }
39
- disabled={ disabled }
40
- isBusy={ isSaving }
41
- onClick={ disabled ? undefined : openEntitiesSavedStates }
42
- >
43
- { __( 'Save' ) }
44
- </Button>
45
- </>
33
+ <Button
34
+ variant="primary"
35
+ className="edit-site-save-button__button"
36
+ aria-disabled={ disabled }
37
+ aria-expanded={ isEntitiesSavedStatesOpen }
38
+ isBusy={ isSaving }
39
+ onClick={ disabled ? undefined : openEntitiesSavedStates }
40
+ >
41
+ { __( 'Save' ) }
42
+ </Button>
46
43
  );
47
44
  }
@@ -5,6 +5,12 @@ import {
5
5
  ComplementaryArea,
6
6
  ComplementaryAreaMoreMenuItem,
7
7
  } from '@wordpress/interface';
8
+ import { useSelect } from '@wordpress/data';
9
+
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+ import { store as editSiteStore } from '../../store';
8
14
 
9
15
  export default function DefaultSidebar( {
10
16
  className,
@@ -17,6 +23,11 @@ export default function DefaultSidebar( {
17
23
  headerClassName,
18
24
  panelClassName,
19
25
  } ) {
26
+ const showIconLabels = useSelect(
27
+ ( select ) => select( editSiteStore ).getSettings().showIconLabels,
28
+ []
29
+ );
30
+
20
31
  return (
21
32
  <>
22
33
  <ComplementaryArea
@@ -29,6 +40,7 @@ export default function DefaultSidebar( {
29
40
  header={ header }
30
41
  headerClassName={ headerClassName }
31
42
  panelClassName={ panelClassName }
43
+ showIconLabels={ showIconLabels }
32
44
  >
33
45
  { children }
34
46
  </ComplementaryArea>
@@ -48,9 +48,5 @@ export default function NavigationMenu( { innerBlocks, id } ) {
48
48
  }
49
49
  } );
50
50
  }, [ updateBlockListSettings, innerBlocks ] );
51
- return (
52
- <>
53
- <ListView id={ id } />
54
- </>
55
- );
51
+ return <ListView id={ id } />;
56
52
  }
@@ -2,6 +2,12 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { ComplementaryArea } from '@wordpress/interface';
5
+ import { useSelect } from '@wordpress/data';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { store as editSiteStore } from '../../../store';
5
11
 
6
12
  /**
7
13
  * Renders a sidebar when activated. The contents within the `PluginSidebar` will appear as content within the sidebar.
@@ -69,11 +75,17 @@ import { ComplementaryArea } from '@wordpress/interface';
69
75
  * ```
70
76
  */
71
77
  export default function PluginSidebarEditSite( { className, ...props } ) {
78
+ const showIconLabels = useSelect(
79
+ ( select ) => select( editSiteStore ).getSettings().showIconLabels,
80
+ []
81
+ );
82
+
72
83
  return (
73
84
  <ComplementaryArea
74
85
  panelClassName={ className }
75
86
  className="edit-site-sidebar"
76
87
  scope="core/edit-site"
88
+ showIconLabels={ showIconLabels }
77
89
  { ...props }
78
90
  />
79
91
  );
@@ -28,7 +28,9 @@ export default function Actions( { template } ) {
28
28
  { ( { onClose } ) => (
29
29
  <MenuGroup>
30
30
  <MenuItem
31
- info={ __( 'Restore to default state' ) }
31
+ info={ __(
32
+ 'Use the template as supplied by the theme.'
33
+ ) }
32
34
  onClick={ () => {
33
35
  revertTemplate( template );
34
36
  onClose();
@@ -19,9 +19,13 @@ export default function EditTemplateTitle( { template } ) {
19
19
  <TextControl
20
20
  label={ __( 'Title' ) }
21
21
  value={ forceEmpty ? '' : title }
22
- help={ __(
23
- 'Give the template a title that indicates its purpose, e.g. "Full Width".'
24
- ) }
22
+ help={
23
+ template.type !== 'wp_template_part'
24
+ ? __(
25
+ 'Give the template a title that indicates its purpose, e.g. "Full Width".'
26
+ )
27
+ : null
28
+ }
25
29
  onChange={ ( newTitle ) => {
26
30
  if ( ! newTitle && ! forceEmpty ) {
27
31
  setForceEmpty( true );
@@ -6,7 +6,7 @@ import {
6
6
  Button,
7
7
  MenuGroup,
8
8
  MenuItem,
9
- __experimentalHeading as Heading,
9
+ __experimentalVStack as VStack,
10
10
  __experimentalText as Text,
11
11
  } from '@wordpress/components';
12
12
  import { useDispatch, useSelect } from '@wordpress/data';
@@ -20,6 +20,7 @@ import { store as editSiteStore } from '../../store';
20
20
  import TemplateAreas from './template-areas';
21
21
  import EditTemplateTitle from './edit-template-title';
22
22
  import { useLink } from '../routes/link';
23
+ import TemplatePartAreaSelector from './template-part-area-selector';
23
24
 
24
25
  export default function TemplateDetails( { template, onClose } ) {
25
26
  const { title, description } = useSelect(
@@ -35,8 +36,13 @@ export default function TemplateDetails( { template, onClose } ) {
35
36
  postId: undefined,
36
37
  } );
37
38
 
39
+ const isTemplatePart = template.type === 'wp_template_part';
40
+
38
41
  // Only user-created and non-default templates can change the name.
39
- const canEditTitle = template.is_custom && ! template.has_theme_file;
42
+ // But any user-created template part can be renamed.
43
+ const canEditTitle = isTemplatePart
44
+ ? ! template.has_theme_file
45
+ : template.is_custom && ! template.has_theme_file;
40
46
 
41
47
  if ( ! template ) {
42
48
  return null;
@@ -49,17 +55,18 @@ export default function TemplateDetails( { template, onClose } ) {
49
55
 
50
56
  return (
51
57
  <div className="edit-site-template-details">
52
- <div className="edit-site-template-details__group">
58
+ <VStack className="edit-site-template-details__group" spacing={ 3 }>
53
59
  { canEditTitle ? (
54
60
  <EditTemplateTitle template={ template } />
55
61
  ) : (
56
- <Heading
57
- level={ 4 }
62
+ <Text
63
+ size={ 16 }
58
64
  weight={ 600 }
59
65
  className="edit-site-template-details__title"
66
+ as="p"
60
67
  >
61
68
  { title }
62
- </Heading>
69
+ </Text>
63
70
  ) }
64
71
 
65
72
  { description && (
@@ -71,7 +78,13 @@ export default function TemplateDetails( { template, onClose } ) {
71
78
  { description }
72
79
  </Text>
73
80
  ) }
74
- </div>
81
+ </VStack>
82
+
83
+ { isTemplatePart && (
84
+ <div className="edit-site-template-details__group">
85
+ <TemplatePartAreaSelector id={ template.id } />
86
+ </div>
87
+ ) }
75
88
 
76
89
  <TemplateAreas closeTemplateDetailsDropdown={ onClose } />
77
90
 
@@ -79,7 +92,9 @@ export default function TemplateDetails( { template, onClose } ) {
79
92
  <MenuGroup className="edit-site-template-details__group edit-site-template-details__revert">
80
93
  <MenuItem
81
94
  className="edit-site-template-details__revert-button"
82
- info={ __( 'Restore template to default state' ) }
95
+ info={ __(
96
+ 'Use the template as supplied by the theme.'
97
+ ) }
83
98
  onClick={ revert }
84
99
  >
85
100
  { __( 'Clear customizations' ) }
@@ -8,12 +8,7 @@
8
8
  border-top: $border-width solid $gray-400;
9
9
  }
10
10
 
11
- .edit-site-template-details__title {
12
- margin: 0;
13
- }
14
-
15
11
  .edit-site-template-details__description {
16
- margin: $grid-unit-15 0 0;
17
12
  color: $gray-700;
18
13
  }
19
14
 
@@ -59,7 +59,9 @@ function TemplatePartItemMore( {
59
59
  { isTemplateRevertable( templatePart ) && (
60
60
  <MenuGroup>
61
61
  <MenuItem
62
- info={ __( 'Restore template to default state' ) }
62
+ info={ __(
63
+ 'Use the template part as supplied by the theme.'
64
+ ) }
63
65
  onClick={ clearCustomizations }
64
66
  >
65
67
  { __( 'Clear customizations' ) }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import { SelectControl } from '@wordpress/components';
6
+ import { useEntityProp } from '@wordpress/core-data';
7
+ import { useSelect } from '@wordpress/data';
8
+ import { store as editorStore } from '@wordpress/editor';
9
+
10
+ export default function TemplatePartAreaSelector( { id } ) {
11
+ const [ area, setArea ] = useEntityProp(
12
+ 'postType',
13
+ 'wp_template_part',
14
+ 'area',
15
+ id
16
+ );
17
+
18
+ const definedAreas = useSelect(
19
+ ( select ) =>
20
+ select( editorStore ).__experimentalGetDefaultTemplatePartAreas(),
21
+ []
22
+ );
23
+
24
+ const areaOptions = definedAreas.map( ( { label, area: _area } ) => ( {
25
+ label,
26
+ value: _area,
27
+ } ) );
28
+
29
+ return (
30
+ <SelectControl
31
+ label={ __( 'Area' ) }
32
+ labelPosition="top"
33
+ options={ areaOptions }
34
+ value={ area }
35
+ onChange={ setArea }
36
+ />
37
+ );
38
+ }
@@ -17,6 +17,7 @@ import { __ } from '@wordpress/i18n';
17
17
  import { useState } from '@wordpress/element';
18
18
  import { store as coreStore } from '@wordpress/core-data';
19
19
  import { store as noticesStore } from '@wordpress/notices';
20
+ import { symbolFilled } from '@wordpress/icons';
20
21
 
21
22
  /**
22
23
  * Internal dependencies
@@ -65,11 +66,12 @@ export default function ConvertToTemplatePart( { clientIds, blocks } ) {
65
66
  <BlockSettingsMenuControls>
66
67
  { () => (
67
68
  <MenuItem
69
+ icon={ symbolFilled }
68
70
  onClick={ () => {
69
71
  setIsModalOpen( true );
70
72
  } }
71
73
  >
72
- { __( 'Make template part' ) }
74
+ { __( 'Create Template part' ) }
73
75
  </MenuItem>
74
76
  ) }
75
77
  </BlockSettingsMenuControls>
package/src/index.js CHANGED
@@ -65,7 +65,7 @@ export function reinitializeEditor( target, settings ) {
65
65
  keepCaretInsideBlock: false,
66
66
  welcomeGuide: true,
67
67
  welcomeGuideStyles: true,
68
- shouldListViewOpenByDefault: false,
68
+ showListViewByDefault: false,
69
69
  } );
70
70
 
71
71
  // Check if the block list view should be open by default.