@wordpress/edit-site 5.3.6 → 5.5.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 (217) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/add-new-template/new-template.js +1 -20
  3. package/build/components/add-new-template/new-template.js.map +1 -1
  4. package/build/components/app/index.js.map +1 -1
  5. package/build/components/block-editor/editor-canvas.js +1 -0
  6. package/build/components/block-editor/editor-canvas.js.map +1 -1
  7. package/build/components/editor/index.js +3 -1
  8. package/build/components/editor/index.js.map +1 -1
  9. package/build/components/global-styles/border-panel.js +5 -5
  10. package/build/components/global-styles/border-panel.js.map +1 -1
  11. package/build/components/global-styles/color-palette-panel.js +5 -2
  12. package/build/components/global-styles/color-palette-panel.js.map +1 -1
  13. package/build/components/global-styles/color-utils.js +1 -1
  14. package/build/components/global-styles/color-utils.js.map +1 -1
  15. package/build/components/global-styles/context-menu.js +22 -6
  16. package/build/components/global-styles/context-menu.js.map +1 -1
  17. package/build/components/global-styles/custom-css.js +1 -1
  18. package/build/components/global-styles/custom-css.js.map +1 -1
  19. package/build/components/global-styles/dimensions-panel.js +41 -486
  20. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  21. package/build/components/global-styles/duotone-panel.js +78 -0
  22. package/build/components/global-styles/duotone-panel.js.map +1 -0
  23. package/build/components/global-styles/filter-utils.js +17 -0
  24. package/build/components/global-styles/filter-utils.js.map +1 -0
  25. package/build/components/global-styles/gradients-palette-panel.js +8 -3
  26. package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
  27. package/build/components/global-styles/header.js +3 -1
  28. package/build/components/global-styles/header.js.map +1 -1
  29. package/build/components/global-styles/hooks.js +14 -51
  30. package/build/components/global-styles/hooks.js.map +1 -1
  31. package/build/components/global-styles/palette.js +3 -1
  32. package/build/components/global-styles/palette.js.map +1 -1
  33. package/build/components/global-styles/preview.js +9 -5
  34. package/build/components/global-styles/preview.js.map +1 -1
  35. package/build/components/global-styles/screen-background-color.js +3 -2
  36. package/build/components/global-styles/screen-background-color.js.map +1 -1
  37. package/build/components/global-styles/screen-block-list.js +13 -6
  38. package/build/components/global-styles/screen-block-list.js.map +1 -1
  39. package/build/components/global-styles/screen-button-color.js +7 -5
  40. package/build/components/global-styles/screen-button-color.js.map +1 -1
  41. package/build/components/global-styles/screen-colors.js +8 -6
  42. package/build/components/global-styles/screen-colors.js.map +1 -1
  43. package/build/components/global-styles/screen-filters.js +46 -0
  44. package/build/components/global-styles/screen-filters.js.map +1 -0
  45. package/build/components/global-styles/screen-heading-color.js +8 -6
  46. package/build/components/global-styles/screen-heading-color.js.map +1 -1
  47. package/build/components/global-styles/screen-layout.js +13 -5
  48. package/build/components/global-styles/screen-layout.js.map +1 -1
  49. package/build/components/global-styles/screen-link-color.js +3 -2
  50. package/build/components/global-styles/screen-link-color.js.map +1 -1
  51. package/build/components/global-styles/screen-text-color.js +3 -2
  52. package/build/components/global-styles/screen-text-color.js.map +1 -1
  53. package/build/components/global-styles/screen-typography.js +3 -1
  54. package/build/components/global-styles/screen-typography.js.map +1 -1
  55. package/build/components/global-styles/shadow-panel.js +2 -3
  56. package/build/components/global-styles/shadow-panel.js.map +1 -1
  57. package/build/components/global-styles/subtitle.js +3 -2
  58. package/build/components/global-styles/subtitle.js.map +1 -1
  59. package/build/components/global-styles/typography-panel.js +23 -303
  60. package/build/components/global-styles/typography-panel.js.map +1 -1
  61. package/build/components/global-styles/ui.js +6 -0
  62. package/build/components/global-styles/ui.js.map +1 -1
  63. package/build/components/keyboard-shortcut-help-modal/config.js +12 -0
  64. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  65. package/build/components/keyboard-shortcuts/index.js +67 -0
  66. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  67. package/build/components/navigation-inspector/index.js +0 -29
  68. package/build/components/navigation-inspector/index.js.map +1 -1
  69. package/build/components/navigation-inspector/navigation-menu.js +22 -5
  70. package/build/components/navigation-inspector/navigation-menu.js.map +1 -1
  71. package/build/components/sidebar-edit-mode/index.js +1 -1
  72. package/build/components/sidebar-edit-mode/index.js.map +1 -1
  73. package/build/components/sidebar-edit-mode/template-card/index.js +9 -2
  74. package/build/components/sidebar-edit-mode/template-card/index.js.map +1 -1
  75. package/build/components/sidebar-edit-mode/template-card/last-revision.js +84 -0
  76. package/build/components/sidebar-edit-mode/template-card/last-revision.js.map +1 -0
  77. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +9 -1
  78. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  79. package/build/components/start-template-options/index.js +175 -0
  80. package/build/components/start-template-options/index.js.map +1 -0
  81. package/build/hooks/push-changes-to-global-styles/index.js +5 -4
  82. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  83. package/build/store/actions.js +2 -2
  84. package/build/store/actions.js.map +1 -1
  85. package/build-module/components/add-new-template/new-template.js +1 -18
  86. package/build-module/components/add-new-template/new-template.js.map +1 -1
  87. package/build-module/components/app/index.js.map +1 -1
  88. package/build-module/components/block-editor/editor-canvas.js +1 -0
  89. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  90. package/build-module/components/editor/index.js +2 -1
  91. package/build-module/components/editor/index.js.map +1 -1
  92. package/build-module/components/global-styles/border-panel.js +6 -6
  93. package/build-module/components/global-styles/border-panel.js.map +1 -1
  94. package/build-module/components/global-styles/color-palette-panel.js +5 -2
  95. package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
  96. package/build-module/components/global-styles/color-utils.js +2 -2
  97. package/build-module/components/global-styles/color-utils.js.map +1 -1
  98. package/build-module/components/global-styles/context-menu.js +20 -6
  99. package/build-module/components/global-styles/context-menu.js.map +1 -1
  100. package/build-module/components/global-styles/custom-css.js +1 -1
  101. package/build-module/components/global-styles/custom-css.js.map +1 -1
  102. package/build-module/components/global-styles/dimensions-panel.js +43 -479
  103. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  104. package/build-module/components/global-styles/duotone-panel.js +67 -0
  105. package/build-module/components/global-styles/duotone-panel.js.map +1 -0
  106. package/build-module/components/global-styles/filter-utils.js +9 -0
  107. package/build-module/components/global-styles/filter-utils.js.map +1 -0
  108. package/build-module/components/global-styles/gradients-palette-panel.js +8 -3
  109. package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
  110. package/build-module/components/global-styles/header.js +3 -1
  111. package/build-module/components/global-styles/header.js.map +1 -1
  112. package/build-module/components/global-styles/hooks.js +12 -49
  113. package/build-module/components/global-styles/hooks.js.map +1 -1
  114. package/build-module/components/global-styles/palette.js +3 -1
  115. package/build-module/components/global-styles/palette.js.map +1 -1
  116. package/build-module/components/global-styles/preview.js +10 -6
  117. package/build-module/components/global-styles/preview.js.map +1 -1
  118. package/build-module/components/global-styles/screen-background-color.js +4 -3
  119. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  120. package/build-module/components/global-styles/screen-block-list.js +12 -5
  121. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  122. package/build-module/components/global-styles/screen-button-color.js +8 -6
  123. package/build-module/components/global-styles/screen-button-color.js.map +1 -1
  124. package/build-module/components/global-styles/screen-colors.js +9 -7
  125. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  126. package/build-module/components/global-styles/screen-filters.js +33 -0
  127. package/build-module/components/global-styles/screen-filters.js.map +1 -0
  128. package/build-module/components/global-styles/screen-heading-color.js +9 -7
  129. package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
  130. package/build-module/components/global-styles/screen-layout.js +11 -2
  131. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  132. package/build-module/components/global-styles/screen-link-color.js +4 -3
  133. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  134. package/build-module/components/global-styles/screen-text-color.js +4 -3
  135. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  136. package/build-module/components/global-styles/screen-typography.js +3 -1
  137. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  138. package/build-module/components/global-styles/shadow-panel.js +3 -4
  139. package/build-module/components/global-styles/shadow-panel.js.map +1 -1
  140. package/build-module/components/global-styles/subtitle.js +3 -2
  141. package/build-module/components/global-styles/subtitle.js.map +1 -1
  142. package/build-module/components/global-styles/typography-panel.js +24 -300
  143. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  144. package/build-module/components/global-styles/ui.js +5 -0
  145. package/build-module/components/global-styles/ui.js.map +1 -1
  146. package/build-module/components/keyboard-shortcut-help-modal/config.js +12 -0
  147. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  148. package/build-module/components/keyboard-shortcuts/index.js +65 -0
  149. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  150. package/build-module/components/navigation-inspector/index.js +0 -27
  151. package/build-module/components/navigation-inspector/index.js.map +1 -1
  152. package/build-module/components/navigation-inspector/navigation-menu.js +25 -8
  153. package/build-module/components/navigation-inspector/navigation-menu.js.map +1 -1
  154. package/build-module/components/sidebar-edit-mode/index.js +1 -1
  155. package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
  156. package/build-module/components/sidebar-edit-mode/template-card/index.js +9 -4
  157. package/build-module/components/sidebar-edit-mode/template-card/index.js.map +1 -1
  158. package/build-module/components/sidebar-edit-mode/template-card/last-revision.js +70 -0
  159. package/build-module/components/sidebar-edit-mode/template-card/last-revision.js.map +1 -0
  160. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +9 -1
  161. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  162. package/build-module/components/start-template-options/index.js +156 -0
  163. package/build-module/components/start-template-options/index.js.map +1 -0
  164. package/build-module/hooks/push-changes-to-global-styles/index.js +6 -5
  165. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  166. package/build-module/store/actions.js +2 -2
  167. package/build-module/store/actions.js.map +1 -1
  168. package/build-style/style-rtl.css +73 -4
  169. package/build-style/style.css +73 -4
  170. package/package.json +31 -31
  171. package/src/components/add-new-template/new-template.js +1 -16
  172. package/src/components/app/index.js +0 -1
  173. package/src/components/block-editor/editor-canvas.js +1 -0
  174. package/src/components/editor/index.js +2 -0
  175. package/src/components/global-styles/border-panel.js +6 -6
  176. package/src/components/global-styles/color-palette-panel.js +3 -0
  177. package/src/components/global-styles/color-utils.js +2 -3
  178. package/src/components/global-styles/context-menu.js +25 -4
  179. package/src/components/global-styles/custom-css.js +1 -1
  180. package/src/components/global-styles/dimensions-panel.js +43 -573
  181. package/src/components/global-styles/duotone-panel.js +82 -0
  182. package/src/components/global-styles/filter-utils.js +9 -0
  183. package/src/components/global-styles/gradients-palette-panel.js +4 -1
  184. package/src/components/global-styles/header.js +7 -1
  185. package/src/components/global-styles/hooks.js +17 -90
  186. package/src/components/global-styles/palette.js +1 -1
  187. package/src/components/global-styles/preview.js +155 -140
  188. package/src/components/global-styles/screen-background-color.js +3 -2
  189. package/src/components/global-styles/screen-block-list.js +16 -5
  190. package/src/components/global-styles/screen-button-color.js +8 -6
  191. package/src/components/global-styles/screen-colors.js +7 -7
  192. package/src/components/global-styles/screen-filters.js +27 -0
  193. package/src/components/global-styles/screen-heading-color.js +9 -7
  194. package/src/components/global-styles/screen-layout.js +9 -2
  195. package/src/components/global-styles/screen-link-color.js +3 -2
  196. package/src/components/global-styles/screen-text-color.js +3 -2
  197. package/src/components/global-styles/screen-typography.js +1 -1
  198. package/src/components/global-styles/shadow-panel.js +6 -3
  199. package/src/components/global-styles/style.scss +5 -0
  200. package/src/components/global-styles/subtitle.js +5 -2
  201. package/src/components/global-styles/typography-panel.js +29 -395
  202. package/src/components/global-styles/ui.js +5 -0
  203. package/src/components/keyboard-shortcut-help-modal/config.js +10 -0
  204. package/src/components/keyboard-shortcuts/index.js +70 -0
  205. package/src/components/navigation-inspector/index.js +0 -32
  206. package/src/components/navigation-inspector/navigation-menu.js +24 -6
  207. package/src/components/sidebar-edit-mode/index.js +1 -1
  208. package/src/components/sidebar-edit-mode/template-card/index.js +24 -14
  209. package/src/components/sidebar-edit-mode/template-card/last-revision.js +75 -0
  210. package/src/components/sidebar-edit-mode/template-card/style.scss +4 -0
  211. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +7 -1
  212. package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +0 -4
  213. package/src/components/start-template-options/index.js +171 -0
  214. package/src/components/start-template-options/style.scss +76 -0
  215. package/src/hooks/push-changes-to-global-styles/index.js +26 -21
  216. package/src/store/actions.js +2 -2
  217. package/src/style.scss +1 -0
@@ -1,186 +1,19 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import {
5
- LineHeightControl,
6
- __experimentalFontFamilyControl as FontFamilyControl,
7
- __experimentalFontAppearanceControl as FontAppearanceControl,
8
- __experimentalLetterSpacingControl as LetterSpacingControl,
9
- __experimentalTextTransformControl as TextTransformControl,
10
- __experimentalTextDecorationControl as TextDecorationControl,
11
- privateApis as blockEditorPrivateApis,
12
- } from '@wordpress/block-editor';
13
- import {
14
- FontSizePicker,
15
- __experimentalToolsPanel as ToolsPanel,
16
- __experimentalToolsPanelItem as ToolsPanelItem,
17
- } from '@wordpress/components';
18
- import { __ } from '@wordpress/i18n';
4
+ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
19
5
 
20
6
  /**
21
7
  * Internal dependencies
22
8
  */
23
- import { getSupportedGlobalStylesPanels } from './hooks';
24
9
  import { unlock } from '../../private-apis';
25
10
 
26
- const { useGlobalSetting, useGlobalStyle } = unlock( blockEditorPrivateApis );
27
-
28
- export function useHasTypographyPanel( name ) {
29
- const hasFontFamily = useHasFontFamilyControl( name );
30
- const hasLineHeight = useHasLineHeightControl( name );
31
- const hasFontAppearance = useHasAppearanceControl( name );
32
- const hasLetterSpacing = useHasLetterSpacingControl( name );
33
- const supports = getSupportedGlobalStylesPanels( name );
34
- return (
35
- hasFontFamily ||
36
- hasLineHeight ||
37
- hasFontAppearance ||
38
- hasLetterSpacing ||
39
- supports.includes( 'fontSize' )
40
- );
41
- }
42
-
43
- function useHasFontFamilyControl( name ) {
44
- const supports = getSupportedGlobalStylesPanels( name );
45
- const [ fontFamiliesPerOrigin ] = useGlobalSetting(
46
- 'typography.fontFamilies',
47
- name
48
- );
49
- const fontFamilies =
50
- fontFamiliesPerOrigin?.custom ||
51
- fontFamiliesPerOrigin?.theme ||
52
- fontFamiliesPerOrigin?.default;
53
- return supports.includes( 'fontFamily' ) && !! fontFamilies?.length;
54
- }
55
-
56
- function useHasLineHeightControl( name ) {
57
- const supports = getSupportedGlobalStylesPanels( name );
58
- return (
59
- useGlobalSetting( 'typography.lineHeight', name )[ 0 ] &&
60
- supports.includes( 'lineHeight' )
61
- );
62
- }
63
-
64
- function useHasAppearanceControl( name ) {
65
- const supports = getSupportedGlobalStylesPanels( name );
66
- const hasFontStyles =
67
- useGlobalSetting( 'typography.fontStyle', name )[ 0 ] &&
68
- supports.includes( 'fontStyle' );
69
- const hasFontWeights =
70
- useGlobalSetting( 'typography.fontWeight', name )[ 0 ] &&
71
- supports.includes( 'fontWeight' );
72
- return hasFontStyles || hasFontWeights;
73
- }
74
-
75
- function useAppearanceControlLabel( name ) {
76
- const supports = getSupportedGlobalStylesPanels( name );
77
- const hasFontStyles =
78
- useGlobalSetting( 'typography.fontStyle', name )[ 0 ] &&
79
- supports.includes( 'fontStyle' );
80
- const hasFontWeights =
81
- useGlobalSetting( 'typography.fontWeight', name )[ 0 ] &&
82
- supports.includes( 'fontWeight' );
83
- if ( ! hasFontStyles ) {
84
- return __( 'Font weight' );
85
- }
86
- if ( ! hasFontWeights ) {
87
- return __( 'Font style' );
88
- }
89
- return __( 'Appearance' );
90
- }
91
-
92
- function useHasLetterSpacingControl( name, element ) {
93
- const setting = useGlobalSetting( 'typography.letterSpacing', name )[ 0 ];
94
- if ( ! setting ) {
95
- return false;
96
- }
97
- if ( ! name && element === 'heading' ) {
98
- return true;
99
- }
100
- const supports = getSupportedGlobalStylesPanels( name );
101
- return supports.includes( 'letterSpacing' );
102
- }
103
-
104
- function useHasTextTransformControl( name, element ) {
105
- const setting = useGlobalSetting( 'typography.textTransform', name )[ 0 ];
106
- if ( ! setting ) {
107
- return false;
108
- }
109
- if ( ! name && element === 'heading' ) {
110
- return true;
111
- }
112
- const supports = getSupportedGlobalStylesPanels( name );
113
- return supports.includes( 'textTransform' );
114
- }
115
-
116
- function useHasTextDecorationControl( name, element ) {
117
- // This is an exception for link elements.
118
- // We shouldn't allow other blocks or elements to set textDecoration
119
- // because this will be inherited by their children.
120
- return ! name && element === 'link';
121
- }
122
-
123
- function useStyleWithReset( path, blockName ) {
124
- const [ style, setStyle ] = useGlobalStyle( path, blockName );
125
- const [ userStyle ] = useGlobalStyle( path, blockName, 'user' );
126
- const hasStyle = () => !! userStyle;
127
- const resetStyle = () => setStyle( undefined );
128
- return [ style, setStyle, hasStyle, resetStyle ];
129
- }
130
-
131
- function useFontSizeWithReset( path, blockName ) {
132
- const [ fontSize, setStyleCallback ] = useGlobalStyle( path, blockName );
133
- const [ userStyle ] = useGlobalStyle( path, blockName, 'user' );
134
- const hasFontSize = () => !! userStyle;
135
- const resetFontSize = () => setStyleCallback( undefined );
136
- const setFontSize = ( newValue, metadata ) => {
137
- if ( !! metadata?.slug ) {
138
- newValue = `var:preset|font-size|${ metadata?.slug }`;
139
- }
140
- setStyleCallback( newValue );
141
- };
142
-
143
- return {
144
- fontSize,
145
- setFontSize,
146
- hasFontSize,
147
- resetFontSize,
148
- };
149
- }
150
-
151
- function useFontAppearance( prefix, name ) {
152
- const [ fontStyle, setFontStyle ] = useGlobalStyle(
153
- prefix + 'typography.fontStyle',
154
- name
155
- );
156
- const [ userFontStyle ] = useGlobalStyle(
157
- prefix + 'typography.fontStyle',
158
- name,
159
- 'user'
160
- );
161
- const [ fontWeight, setFontWeight ] = useGlobalStyle(
162
- prefix + 'typography.fontWeight',
163
- name
164
- );
165
- const [ userFontWeight ] = useGlobalStyle(
166
- prefix + 'typography.fontWeight',
167
- name,
168
- 'user'
169
- );
170
- const hasFontAppearance = () => !! userFontStyle || !! userFontWeight;
171
- const resetFontAppearance = () => {
172
- setFontStyle( undefined );
173
- setFontWeight( undefined );
174
- };
175
- return {
176
- fontStyle,
177
- setFontStyle,
178
- fontWeight,
179
- setFontWeight,
180
- hasFontAppearance,
181
- resetFontAppearance,
182
- };
183
- }
11
+ const {
12
+ useGlobalStyle,
13
+ useGlobalSetting,
14
+ useSettingsForBlockElement,
15
+ TypographyPanel: StylesTypographyPanel,
16
+ } = unlock( blockEditorPrivateApis );
184
17
 
185
18
  export default function TypographyPanel( {
186
19
  name,
@@ -188,234 +21,35 @@ export default function TypographyPanel( {
188
21
  headingLevel,
189
22
  variation = '',
190
23
  } ) {
191
- const supports = getSupportedGlobalStylesPanels( name );
192
- let prefix = '';
24
+ let prefixParts = [];
193
25
  if ( element === 'heading' ) {
194
- prefix = `elements.${ headingLevel }.`;
26
+ prefixParts = prefixParts.concat( [ 'elements', headingLevel ] );
195
27
  } else if ( element && element !== 'text' ) {
196
- prefix = `elements.${ element }.`;
28
+ prefixParts = prefixParts.concat( [ 'elements', element ] );
197
29
  }
198
30
  if ( variation ) {
199
- prefix = prefix
200
- ? `variations.${ variation }.${ prefix }`
201
- : `variations.${ variation }`;
202
- }
203
- const [ fontSizesPerOrigin ] = useGlobalSetting(
204
- 'typography.fontSizes',
205
- name
206
- );
207
- const fontSizes =
208
- fontSizesPerOrigin?.custom ||
209
- fontSizesPerOrigin?.theme ||
210
- fontSizesPerOrigin?.default;
211
-
212
- const disableCustomFontSizes = ! useGlobalSetting(
213
- 'typography.customFontSize',
214
- name
215
- )[ 0 ];
216
- const [ fontFamiliesPerOrigin ] = useGlobalSetting(
217
- 'typography.fontFamilies',
218
- name
219
- );
220
- const fontFamilies =
221
- fontFamiliesPerOrigin?.custom ||
222
- fontFamiliesPerOrigin?.theme ||
223
- fontFamiliesPerOrigin?.default;
224
- const hasFontStyles =
225
- useGlobalSetting( 'typography.fontStyle', name )[ 0 ] &&
226
- supports.includes( 'fontStyle' );
227
- const hasFontWeights =
228
- useGlobalSetting( 'typography.fontWeight', name )[ 0 ] &&
229
- supports.includes( 'fontWeight' );
230
- const hasFontFamilyEnabled = useHasFontFamilyControl( name );
231
- const hasLineHeightEnabled = useHasLineHeightControl( name );
232
- const hasAppearanceControl = useHasAppearanceControl( name );
233
- const appearanceControlLabel = useAppearanceControlLabel( name );
234
- const hasLetterSpacingControl = useHasLetterSpacingControl( name, element );
235
- const hasTextTransformControl = useHasTextTransformControl( name, element );
236
- const hasTextDecorationControl = useHasTextDecorationControl(
31
+ prefixParts = [ 'variations', variation ].concat( prefixParts );
32
+ }
33
+ const prefix = prefixParts.join( '.' );
34
+
35
+ const [ style ] = useGlobalStyle( prefix, name, 'user', false );
36
+ const [ inheritedStyle, setStyle ] = useGlobalStyle( prefix, name, 'all', {
37
+ shouldDecodeEncode: false,
38
+ } );
39
+ const [ rawSettings ] = useGlobalSetting( '', name );
40
+ const usedElement = element === 'heading' ? headingLevel : element;
41
+ const settings = useSettingsForBlockElement(
42
+ rawSettings,
237
43
  name,
238
- element
44
+ usedElement
239
45
  );
240
46
 
241
- /* Disable font size controls when the option to style all headings is selected. */
242
- let hasFontSizeEnabled = supports.includes( 'fontSize' );
243
- if ( element === 'heading' && headingLevel === 'heading' ) {
244
- hasFontSizeEnabled = false;
245
- }
246
-
247
- const [ fontFamily, setFontFamily, hasFontFamily, resetFontFamily ] =
248
- useStyleWithReset( prefix + 'typography.fontFamily', name );
249
- const { fontSize, setFontSize, hasFontSize, resetFontSize } =
250
- useFontSizeWithReset( prefix + 'typography.fontSize', name );
251
- const {
252
- fontStyle,
253
- setFontStyle,
254
- fontWeight,
255
- setFontWeight,
256
- hasFontAppearance,
257
- resetFontAppearance,
258
- } = useFontAppearance( prefix, name );
259
- const [ lineHeight, setLineHeight, hasLineHeight, resetLineHeight ] =
260
- useStyleWithReset( prefix + 'typography.lineHeight', name );
261
- const [
262
- letterSpacing,
263
- setLetterSpacing,
264
- hasLetterSpacing,
265
- resetLetterSpacing,
266
- ] = useStyleWithReset( prefix + 'typography.letterSpacing', name );
267
- const [
268
- textTransform,
269
- setTextTransform,
270
- hasTextTransform,
271
- resetTextTransform,
272
- ] = useStyleWithReset( prefix + 'typography.textTransform', name );
273
- const [
274
- textDecoration,
275
- setTextDecoration,
276
- hasTextDecoration,
277
- resetTextDecoration,
278
- ] = useStyleWithReset( prefix + 'typography.textDecoration', name );
279
-
280
- const resetAll = () => {
281
- resetFontFamily();
282
- resetFontSize();
283
- resetFontAppearance();
284
- resetLineHeight();
285
- resetLetterSpacing();
286
- resetTextTransform();
287
- };
288
-
289
47
  return (
290
- <ToolsPanel label={ __( 'Typography' ) } resetAll={ resetAll }>
291
- { hasFontFamilyEnabled && (
292
- <ToolsPanelItem
293
- label={ __( 'Font family' ) }
294
- hasValue={ hasFontFamily }
295
- onDeselect={ resetFontFamily }
296
- isShownByDefault
297
- >
298
- <FontFamilyControl
299
- fontFamilies={ fontFamilies }
300
- value={ fontFamily }
301
- onChange={ setFontFamily }
302
- size="__unstable-large"
303
- __nextHasNoMarginBottom
304
- />
305
- </ToolsPanelItem>
306
- ) }
307
- { hasFontSizeEnabled && (
308
- <ToolsPanelItem
309
- label={ __( 'Font size' ) }
310
- hasValue={ hasFontSize }
311
- onDeselect={ resetFontSize }
312
- isShownByDefault
313
- >
314
- <FontSizePicker
315
- value={ fontSize }
316
- onChange={ setFontSize }
317
- fontSizes={ fontSizes }
318
- disableCustomFontSizes={ disableCustomFontSizes }
319
- withReset={ false }
320
- withSlider
321
- size="__unstable-large"
322
- __nextHasNoMarginBottom
323
- />
324
- </ToolsPanelItem>
325
- ) }
326
- { hasAppearanceControl && (
327
- <ToolsPanelItem
328
- className="single-column"
329
- label={ appearanceControlLabel }
330
- hasValue={ hasFontAppearance }
331
- onDeselect={ resetFontAppearance }
332
- isShownByDefault
333
- >
334
- <FontAppearanceControl
335
- value={ {
336
- fontStyle,
337
- fontWeight,
338
- } }
339
- onChange={ ( {
340
- fontStyle: newFontStyle,
341
- fontWeight: newFontWeight,
342
- } ) => {
343
- setFontStyle( newFontStyle );
344
- setFontWeight( newFontWeight );
345
- } }
346
- hasFontStyles={ hasFontStyles }
347
- hasFontWeights={ hasFontWeights }
348
- size="__unstable-large"
349
- __nextHasNoMarginBottom
350
- />
351
- </ToolsPanelItem>
352
- ) }
353
- { hasLineHeightEnabled && (
354
- <ToolsPanelItem
355
- className="single-column"
356
- label={ __( 'Line height' ) }
357
- hasValue={ hasLineHeight }
358
- onDeselect={ resetLineHeight }
359
- isShownByDefault
360
- >
361
- <LineHeightControl
362
- __nextHasNoMarginBottom
363
- __unstableInputWidth="auto"
364
- value={ lineHeight }
365
- onChange={ setLineHeight }
366
- size="__unstable-large"
367
- />
368
- </ToolsPanelItem>
369
- ) }
370
- { hasLetterSpacingControl && (
371
- <ToolsPanelItem
372
- className="single-column"
373
- label={ __( 'Letter spacing' ) }
374
- hasValue={ hasLetterSpacing }
375
- onDeselect={ resetLetterSpacing }
376
- isShownByDefault
377
- >
378
- <LetterSpacingControl
379
- value={ letterSpacing }
380
- onChange={ setLetterSpacing }
381
- size="__unstable-large"
382
- __unstableInputWidth="auto"
383
- />
384
- </ToolsPanelItem>
385
- ) }
386
- { hasTextTransformControl && (
387
- <ToolsPanelItem
388
- label={ __( 'Letter case' ) }
389
- hasValue={ hasTextTransform }
390
- onDeselect={ resetTextTransform }
391
- isShownByDefault
392
- >
393
- <TextTransformControl
394
- value={ textTransform }
395
- onChange={ setTextTransform }
396
- showNone
397
- isBlock
398
- size="__unstable-large"
399
- __nextHasNoMarginBottom
400
- />
401
- </ToolsPanelItem>
402
- ) }
403
- { hasTextDecorationControl && (
404
- <ToolsPanelItem
405
- className="single-column"
406
- label={ __( 'Text decoration' ) }
407
- hasValue={ hasTextDecoration }
408
- onDeselect={ resetTextDecoration }
409
- isShownByDefault
410
- >
411
- <TextDecorationControl
412
- value={ textDecoration }
413
- onChange={ setTextDecoration }
414
- size="__unstable-large"
415
- __unstableInputWidth="auto"
416
- />
417
- </ToolsPanelItem>
418
- ) }
419
- </ToolsPanel>
48
+ <StylesTypographyPanel
49
+ inheritedValue={ inheritedStyle }
50
+ value={ style }
51
+ onChange={ setStyle }
52
+ settings={ settings }
53
+ />
420
54
  );
421
55
  }
@@ -24,6 +24,7 @@ import ScreenBlockList from './screen-block-list';
24
24
  import ScreenBlock from './screen-block';
25
25
  import ScreenTypography from './screen-typography';
26
26
  import ScreenTypographyElement from './screen-typography-element';
27
+ import ScreenFilters from './screen-filters';
27
28
  import ScreenColors from './screen-colors';
28
29
  import ScreenColorPalette from './screen-color-palette';
29
30
  import ScreenBackgroundColor from './screen-background-color';
@@ -205,6 +206,10 @@ function ContextScreens( { name, parentMenu = '', variation = '' } ) {
205
206
  <ScreenBackgroundColor name={ name } variation={ variation } />
206
207
  </GlobalStylesNavigationScreen>
207
208
 
209
+ <GlobalStylesNavigationScreen path={ parentMenu + '/filters' }>
210
+ <ScreenFilters name={ name } />
211
+ </GlobalStylesNavigationScreen>
212
+
208
213
  <GlobalStylesNavigationScreen path={ parentMenu + '/colors/text' }>
209
214
  <ScreenTextColor name={ name } variation={ variation } />
210
215
  </GlobalStylesNavigationScreen>
@@ -36,4 +36,14 @@ export const textFormattingShortcuts = [
36
36
  keyCombination: { modifier: 'access', character: 'x' },
37
37
  description: __( 'Make the selected text inline code.' ),
38
38
  },
39
+ {
40
+ keyCombination: { modifier: 'access', character: '0' },
41
+ description: __( 'Convert the current heading to a paragraph.' ),
42
+ },
43
+ {
44
+ keyCombination: { modifier: 'access', character: '1-6' },
45
+ description: __(
46
+ 'Convert the current paragraph or heading to a heading of level 1 to 6.'
47
+ ),
48
+ },
39
49
  ];
@@ -10,7 +10,9 @@ import { isAppleOS } from '@wordpress/keycodes';
10
10
  import { useDispatch, useSelect } from '@wordpress/data';
11
11
  import { __ } from '@wordpress/i18n';
12
12
  import { store as coreStore } from '@wordpress/core-data';
13
+ import { store as blockEditorStore } from '@wordpress/block-editor';
13
14
  import { store as interfaceStore } from '@wordpress/interface';
15
+ import { createBlock } from '@wordpress/blocks';
14
16
 
15
17
  /**
16
18
  * Internal dependencies
@@ -41,6 +43,38 @@ function KeyboardShortcuts() {
41
43
  useDispatch( interfaceStore );
42
44
  const { setIsSaveViewOpened } = useDispatch( editSiteStore );
43
45
 
46
+ const { replaceBlocks } = useDispatch( blockEditorStore );
47
+ const { getBlockName, getSelectedBlockClientId, getBlockAttributes } =
48
+ useSelect( blockEditorStore );
49
+
50
+ const handleTextLevelShortcut = ( event, level ) => {
51
+ event.preventDefault();
52
+ const destinationBlockName =
53
+ level === 0 ? 'core/paragraph' : 'core/heading';
54
+ const currentClientId = getSelectedBlockClientId();
55
+ if ( currentClientId === null ) {
56
+ return;
57
+ }
58
+ const blockName = getBlockName( currentClientId );
59
+ if ( blockName !== 'core/paragraph' && blockName !== 'core/heading' ) {
60
+ return;
61
+ }
62
+ const attributes = getBlockAttributes( currentClientId );
63
+ const textAlign =
64
+ blockName === 'core/paragraph' ? 'align' : 'textAlign';
65
+ const destinationTextAlign =
66
+ destinationBlockName === 'core/paragraph' ? 'align' : 'textAlign';
67
+
68
+ replaceBlocks(
69
+ currentClientId,
70
+ createBlock( destinationBlockName, {
71
+ level,
72
+ content: attributes.content,
73
+ ...{ [ destinationTextAlign ]: attributes[ textAlign ] },
74
+ } )
75
+ );
76
+ };
77
+
44
78
  useShortcut( 'core/edit-site/save', ( event ) => {
45
79
  event.preventDefault();
46
80
 
@@ -85,6 +119,20 @@ function KeyboardShortcuts() {
85
119
  switchEditorMode( getEditorMode() === 'visual' ? 'text' : 'visual' );
86
120
  } );
87
121
 
122
+ useShortcut( 'core/edit-site/transform-heading-to-paragraph', ( event ) =>
123
+ handleTextLevelShortcut( event, 0 )
124
+ );
125
+
126
+ [ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {
127
+ //the loop is based off on a constant therefore
128
+ //the hook will execute the same way every time
129
+ //eslint-disable-next-line react-hooks/rules-of-hooks
130
+ useShortcut(
131
+ `core/edit-site/transform-paragraph-to-heading-${ level }`,
132
+ ( event ) => handleTextLevelShortcut( event, level )
133
+ );
134
+ } );
135
+
88
136
  return null;
89
137
  }
90
138
 
@@ -208,6 +256,28 @@ function KeyboardShortcutsRegister() {
208
256
  character: 'm',
209
257
  },
210
258
  } );
259
+
260
+ registerShortcut( {
261
+ name: `core/edit-site/transform-heading-to-paragraph`,
262
+ category: 'block-library',
263
+ description: __( 'Transform heading to paragraph.' ),
264
+ keyCombination: {
265
+ modifier: 'access',
266
+ character: `0`,
267
+ },
268
+ } );
269
+
270
+ [ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {
271
+ registerShortcut( {
272
+ name: `core/edit-site/transform-paragraph-to-heading-${ level }`,
273
+ category: 'block-library',
274
+ description: __( 'Transform paragraph to heading.' ),
275
+ keyCombination: {
276
+ modifier: 'access',
277
+ character: `${ level }`,
278
+ },
279
+ } );
280
+ } );
211
281
  }, [ registerShortcut ] );
212
282
 
213
283
  return null;
@@ -3,14 +3,12 @@
3
3
  */
4
4
  import { useSelect } from '@wordpress/data';
5
5
  import { useState, useEffect } from '@wordpress/element';
6
- import { SelectControl } from '@wordpress/components';
7
6
  import { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';
8
7
  import {
9
8
  store as blockEditorStore,
10
9
  BlockEditorProvider,
11
10
  } from '@wordpress/block-editor';
12
11
  import { speak } from '@wordpress/a11y';
13
- import { useInstanceId } from '@wordpress/compose';
14
12
  import { __ } from '@wordpress/i18n';
15
13
 
16
14
  /**
@@ -71,11 +69,6 @@ export default function NavigationInspector( { onSelect } ) {
71
69
  };
72
70
  }, [] );
73
71
 
74
- const navMenuListId = useInstanceId(
75
- NavigationMenu,
76
- 'edit-site-navigation-inspector-menu'
77
- );
78
-
79
72
  const firstNavRefInTemplate = clientIdToRef[ firstNavigationBlockId ];
80
73
  const firstNavigationMenuRef = navigationMenus?.[ 0 ]?.id;
81
74
 
@@ -99,14 +92,6 @@ export default function NavigationInspector( { onSelect } ) {
99
92
  }
100
93
  }, [ selectedNavigationBlockId ] );
101
94
 
102
- let options = [];
103
- if ( navigationMenus ) {
104
- options = navigationMenus.map( ( { id, title } ) => ( {
105
- value: id,
106
- label: title.rendered,
107
- } ) );
108
- }
109
-
110
95
  const [ innerBlocks, onInput, onChange ] = useEntityBlockEditor(
111
96
  'postType',
112
97
  'wp_navigation',
@@ -137,8 +122,6 @@ export default function NavigationInspector( { onSelect } ) {
137
122
 
138
123
  const isLoading = ! ( hasResolvedNavigationMenus && hasLoadedInnerBlocks );
139
124
 
140
- const hasMoreThanOneNavigationMenu = navigationMenus?.length > 1;
141
-
142
125
  const hasNavigationMenus = !! navigationMenus?.length;
143
126
 
144
127
  // Entity block editor will return entities that are not currently published.
@@ -178,21 +161,6 @@ export default function NavigationInspector( { onSelect } ) {
178
161
  { ! hasResolvedNavigationMenus && (
179
162
  <div className="edit-site-navigation-inspector__placeholder" />
180
163
  ) }
181
- { hasResolvedNavigationMenus && hasMoreThanOneNavigationMenu && (
182
- <SelectControl
183
- __nextHasNoMarginBottom
184
- className="edit-site-navigation-inspector__select-menu"
185
- aria-controls={
186
- // aria-controls should only apply when referenced element is in DOM
187
- hasLoadedInnerBlocks ? navMenuListId : undefined
188
- }
189
- value={ currentMenuId || defaultNavigationMenuId }
190
- options={ options }
191
- onChange={ ( newMenuId ) =>
192
- setCurrentMenuId( Number( newMenuId ) )
193
- }
194
- />
195
- ) }
196
164
  { isLoading && (
197
165
  <>
198
166
  <div className="edit-site-navigation-inspector__placeholder is-child" />