@wordpress/block-editor 12.4.0 → 12.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 (316) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +5 -0
  3. package/build/components/block-heading-level-dropdown/heading-level-icon.js +10 -2
  4. package/build/components/block-heading-level-dropdown/heading-level-icon.js.map +1 -1
  5. package/build/components/block-heading-level-dropdown/index.native.js +4 -3
  6. package/build/components/block-heading-level-dropdown/index.native.js.map +1 -1
  7. package/build/components/block-lock/toolbar.js +25 -6
  8. package/build/components/block-lock/toolbar.js.map +1 -1
  9. package/build/components/block-mobile-toolbar/block-actions-menu.native.js +3 -6
  10. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  11. package/build/components/block-parent-selector/index.js +8 -5
  12. package/build/components/block-parent-selector/index.js.map +1 -1
  13. package/build/components/block-removal-warning-modal/index.js +18 -25
  14. package/build/components/block-removal-warning-modal/index.js.map +1 -1
  15. package/build/components/block-toolbar/index.js +8 -5
  16. package/build/components/block-toolbar/index.js.map +1 -1
  17. package/build/components/block-tools/block-contextual-toolbar.js +7 -11
  18. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  19. package/build/components/dimensions-tool/aspect-ratio-tool.js +99 -0
  20. package/build/components/dimensions-tool/aspect-ratio-tool.js.map +1 -0
  21. package/build/components/dimensions-tool/index.js +207 -0
  22. package/build/components/dimensions-tool/index.js.map +1 -0
  23. package/build/components/dimensions-tool/scale-tool.js +111 -0
  24. package/build/components/dimensions-tool/scale-tool.js.map +1 -0
  25. package/build/components/dimensions-tool/width-height-tool.js +125 -0
  26. package/build/components/dimensions-tool/width-height-tool.js.map +1 -0
  27. package/build/components/global-styles/color-panel.js +1 -1
  28. package/build/components/global-styles/color-panel.js.map +1 -1
  29. package/build/components/global-styles/filters-panel.js +1 -1
  30. package/build/components/global-styles/filters-panel.js.map +1 -1
  31. package/build/components/global-styles/hooks.js +2 -2
  32. package/build/components/global-styles/hooks.js.map +1 -1
  33. package/build/components/global-styles/typography-panel.js +34 -2
  34. package/build/components/global-styles/typography-panel.js.map +1 -1
  35. package/build/components/image-editor/aspect-ratio-dropdown.js +1 -1
  36. package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  37. package/build/components/image-editor/use-save-image.js +1 -2
  38. package/build/components/image-editor/use-save-image.js.map +1 -1
  39. package/build/components/image-size-control/index.js +6 -0
  40. package/build/components/image-size-control/index.js.map +1 -1
  41. package/build/components/index.js +19 -1
  42. package/build/components/index.js.map +1 -1
  43. package/build/components/inserter/block-patterns-explorer/patterns-list.js +2 -2
  44. package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
  45. package/build/components/inserter/block-patterns-tab.js +7 -35
  46. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  47. package/build/components/inserter/hooks/use-block-types-state.js +3 -4
  48. package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
  49. package/build/components/inserter/hooks/use-patterns-state.js +9 -3
  50. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  51. package/build/components/inserter/media-tab/hooks.js +2 -21
  52. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  53. package/build/components/inserter/reusable-block-rename-hint.js +62 -0
  54. package/build/components/inserter/reusable-block-rename-hint.js.map +1 -0
  55. package/build/components/inserter/reusable-blocks-tab.js +6 -2
  56. package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
  57. package/build/components/inserter/reusable-blocks-tab.native.js +2 -2
  58. package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  59. package/build/components/inserter/tabs.native.js +1 -1
  60. package/build/components/inserter/tabs.native.js.map +1 -1
  61. package/build/components/inserter-draggable-blocks/index.js +9 -1
  62. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  63. package/build/components/link-control/constants.js +1 -1
  64. package/build/components/link-control/constants.js.map +1 -1
  65. package/build/components/link-control/index.js +17 -15
  66. package/build/components/link-control/index.js.map +1 -1
  67. package/build/components/link-control/search-create-button.js +5 -21
  68. package/build/components/link-control/search-create-button.js.map +1 -1
  69. package/build/components/link-control/search-input.js +4 -4
  70. package/build/components/link-control/search-input.js.map +1 -1
  71. package/build/components/link-control/search-item.js +13 -30
  72. package/build/components/link-control/search-item.js.map +1 -1
  73. package/build/components/link-control/search-results.js +2 -2
  74. package/build/components/link-control/search-results.js.map +1 -1
  75. package/build/components/link-control/settings-drawer.js +2 -3
  76. package/build/components/link-control/settings-drawer.js.map +1 -1
  77. package/build/components/list-view/appender.js +2 -6
  78. package/build/components/list-view/appender.js.map +1 -1
  79. package/build/components/provider/index.js +5 -2
  80. package/build/components/provider/index.js.map +1 -1
  81. package/build/components/provider/use-block-sync.js +21 -0
  82. package/build/components/provider/use-block-sync.js.map +1 -1
  83. package/build/components/resolution-tool/index.js +55 -0
  84. package/build/components/resolution-tool/index.js.map +1 -0
  85. package/build/components/url-input/index.js +4 -2
  86. package/build/components/url-input/index.js.map +1 -1
  87. package/build/components/writing-flow/use-tab-nav.js +10 -27
  88. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  89. package/build/components/writing-mode-control/index.js +70 -0
  90. package/build/components/writing-mode-control/index.js.map +1 -0
  91. package/build/hooks/behaviors.js +25 -20
  92. package/build/hooks/behaviors.js.map +1 -1
  93. package/build/hooks/supports.js +7 -1
  94. package/build/hooks/supports.js.map +1 -1
  95. package/build/hooks/typography.js +2 -1
  96. package/build/hooks/typography.js.map +1 -1
  97. package/build/hooks/utils.js +4 -2
  98. package/build/hooks/utils.js.map +1 -1
  99. package/build/private-apis.js +10 -1
  100. package/build/private-apis.js.map +1 -1
  101. package/build/private-apis.native.js +3 -0
  102. package/build/private-apis.native.js.map +1 -1
  103. package/build/store/actions.js +195 -1
  104. package/build/store/actions.js.map +1 -1
  105. package/build/store/defaults.js +1 -0
  106. package/build/store/defaults.js.map +1 -1
  107. package/build/store/index.js +10 -1
  108. package/build/store/index.js.map +1 -1
  109. package/build/store/private-actions.js +46 -40
  110. package/build/store/private-actions.js.map +1 -1
  111. package/build/store/private-selectors.js +3 -3
  112. package/build/store/private-selectors.js.map +1 -1
  113. package/build/store/reducer.js +22 -8
  114. package/build/store/reducer.js.map +1 -1
  115. package/build/store/selectors.js +33 -15
  116. package/build/store/selectors.js.map +1 -1
  117. package/build-module/components/block-heading-level-dropdown/heading-level-icon.js +9 -2
  118. package/build-module/components/block-heading-level-dropdown/heading-level-icon.js.map +1 -1
  119. package/build-module/components/block-heading-level-dropdown/index.native.js +4 -3
  120. package/build-module/components/block-heading-level-dropdown/index.native.js.map +1 -1
  121. package/build-module/components/block-lock/toolbar.js +25 -7
  122. package/build-module/components/block-lock/toolbar.js.map +1 -1
  123. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +4 -6
  124. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  125. package/build-module/components/block-parent-selector/index.js +7 -5
  126. package/build-module/components/block-parent-selector/index.js.map +1 -1
  127. package/build-module/components/block-removal-warning-modal/index.js +20 -24
  128. package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
  129. package/build-module/components/block-toolbar/index.js +8 -5
  130. package/build-module/components/block-toolbar/index.js.map +1 -1
  131. package/build-module/components/block-tools/block-contextual-toolbar.js +8 -11
  132. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  133. package/build-module/components/dimensions-tool/aspect-ratio-tool.js +87 -0
  134. package/build-module/components/dimensions-tool/aspect-ratio-tool.js.map +1 -0
  135. package/build-module/components/dimensions-tool/index.js +195 -0
  136. package/build-module/components/dimensions-tool/index.js.map +1 -0
  137. package/build-module/components/dimensions-tool/scale-tool.js +103 -0
  138. package/build-module/components/dimensions-tool/scale-tool.js.map +1 -0
  139. package/build-module/components/dimensions-tool/width-height-tool.js +122 -0
  140. package/build-module/components/dimensions-tool/width-height-tool.js.map +1 -0
  141. package/build-module/components/global-styles/color-panel.js +1 -1
  142. package/build-module/components/global-styles/color-panel.js.map +1 -1
  143. package/build-module/components/global-styles/filters-panel.js +2 -2
  144. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  145. package/build-module/components/global-styles/hooks.js +2 -2
  146. package/build-module/components/global-styles/hooks.js.map +1 -1
  147. package/build-module/components/global-styles/typography-panel.js +33 -2
  148. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  149. package/build-module/components/image-editor/aspect-ratio-dropdown.js +1 -1
  150. package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  151. package/build-module/components/image-editor/use-save-image.js +1 -2
  152. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  153. package/build-module/components/image-size-control/index.js +5 -0
  154. package/build-module/components/image-size-control/index.js.map +1 -1
  155. package/build-module/components/index.js +6 -0
  156. package/build-module/components/index.js.map +1 -1
  157. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +2 -2
  158. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
  159. package/build-module/components/inserter/block-patterns-tab.js +7 -33
  160. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  161. package/build-module/components/inserter/hooks/use-block-types-state.js +3 -4
  162. package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
  163. package/build-module/components/inserter/hooks/use-patterns-state.js +9 -3
  164. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  165. package/build-module/components/inserter/media-tab/hooks.js +2 -21
  166. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  167. package/build-module/components/inserter/reusable-block-rename-hint.js +48 -0
  168. package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -0
  169. package/build-module/components/inserter/reusable-blocks-tab.js +5 -2
  170. package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
  171. package/build-module/components/inserter/reusable-blocks-tab.native.js +2 -2
  172. package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  173. package/build-module/components/inserter/tabs.native.js +1 -1
  174. package/build-module/components/inserter/tabs.native.js.map +1 -1
  175. package/build-module/components/inserter-draggable-blocks/index.js +9 -2
  176. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  177. package/build-module/components/link-control/constants.js +1 -1
  178. package/build-module/components/link-control/constants.js.map +1 -1
  179. package/build-module/components/link-control/index.js +17 -15
  180. package/build-module/components/link-control/index.js.map +1 -1
  181. package/build-module/components/link-control/search-create-button.js +7 -20
  182. package/build-module/components/link-control/search-create-button.js.map +1 -1
  183. package/build-module/components/link-control/search-input.js +4 -4
  184. package/build-module/components/link-control/search-input.js.map +1 -1
  185. package/build-module/components/link-control/search-item.js +14 -28
  186. package/build-module/components/link-control/search-item.js.map +1 -1
  187. package/build-module/components/link-control/search-results.js +3 -3
  188. package/build-module/components/link-control/search-results.js.map +1 -1
  189. package/build-module/components/link-control/settings-drawer.js +4 -5
  190. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  191. package/build-module/components/list-view/appender.js +2 -6
  192. package/build-module/components/list-view/appender.js.map +1 -1
  193. package/build-module/components/provider/index.js +5 -2
  194. package/build-module/components/provider/index.js.map +1 -1
  195. package/build-module/components/provider/use-block-sync.js +21 -0
  196. package/build-module/components/provider/use-block-sync.js.map +1 -1
  197. package/build-module/components/resolution-tool/index.js +45 -0
  198. package/build-module/components/resolution-tool/index.js.map +1 -0
  199. package/build-module/components/url-input/index.js +4 -2
  200. package/build-module/components/url-input/index.js.map +1 -1
  201. package/build-module/components/writing-flow/use-tab-nav.js +8 -26
  202. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  203. package/build-module/components/writing-mode-control/index.js +57 -0
  204. package/build-module/components/writing-mode-control/index.js.map +1 -0
  205. package/build-module/hooks/behaviors.js +26 -20
  206. package/build-module/hooks/behaviors.js.map +1 -1
  207. package/build-module/hooks/supports.js +7 -1
  208. package/build-module/hooks/supports.js.map +1 -1
  209. package/build-module/hooks/typography.js +2 -1
  210. package/build-module/hooks/typography.js.map +1 -1
  211. package/build-module/hooks/utils.js +4 -2
  212. package/build-module/hooks/utils.js.map +1 -1
  213. package/build-module/private-apis.js +7 -1
  214. package/build-module/private-apis.js.map +1 -1
  215. package/build-module/private-apis.native.js +2 -0
  216. package/build-module/private-apis.native.js.map +1 -1
  217. package/build-module/store/actions.js +191 -1
  218. package/build-module/store/actions.js.map +1 -1
  219. package/build-module/store/defaults.js +1 -0
  220. package/build-module/store/defaults.js.map +1 -1
  221. package/build-module/store/index.js +10 -1
  222. package/build-module/store/index.js.map +1 -1
  223. package/build-module/store/private-actions.js +45 -36
  224. package/build-module/store/private-actions.js.map +1 -1
  225. package/build-module/store/private-selectors.js +2 -2
  226. package/build-module/store/private-selectors.js.map +1 -1
  227. package/build-module/store/reducer.js +22 -8
  228. package/build-module/store/reducer.js.map +1 -1
  229. package/build-module/store/selectors.js +33 -15
  230. package/build-module/store/selectors.js.map +1 -1
  231. package/build-style/content-rtl.css +3 -0
  232. package/build-style/content.css +3 -0
  233. package/build-style/style-rtl.css +131 -129
  234. package/build-style/style.css +131 -129
  235. package/package.json +32 -31
  236. package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -6
  237. package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -5
  238. package/src/components/block-draggable/style.scss +1 -0
  239. package/src/components/block-heading-level-dropdown/heading-level-icon.js +6 -1
  240. package/src/components/block-heading-level-dropdown/index.native.js +8 -4
  241. package/src/components/block-inspector/style.scss +2 -1
  242. package/src/components/block-lock/toolbar.js +34 -6
  243. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +4 -8
  244. package/src/components/block-parent-selector/index.js +13 -8
  245. package/src/components/block-removal-warning-modal/index.js +20 -33
  246. package/src/components/block-toolbar/index.js +9 -6
  247. package/src/components/block-tools/block-contextual-toolbar.js +5 -11
  248. package/src/components/block-tools/style.scss +73 -26
  249. package/src/components/default-block-appender/content.scss +11 -0
  250. package/src/components/dimensions-tool/aspect-ratio-tool.js +124 -0
  251. package/src/components/dimensions-tool/index.js +212 -0
  252. package/src/components/dimensions-tool/scale-tool.js +124 -0
  253. package/src/components/dimensions-tool/stories/aspect-ratio-tool.js +52 -0
  254. package/src/components/dimensions-tool/stories/index.js +54 -0
  255. package/src/components/dimensions-tool/stories/scale-tool.js +48 -0
  256. package/src/components/dimensions-tool/stories/width-height-tool.js +54 -0
  257. package/src/components/dimensions-tool/test/index.js +641 -0
  258. package/src/components/dimensions-tool/width-height-tool.js +113 -0
  259. package/src/components/font-family/README.md +71 -0
  260. package/src/components/global-styles/color-panel.js +1 -1
  261. package/src/components/global-styles/filters-panel.js +2 -2
  262. package/src/components/global-styles/hooks.js +2 -0
  263. package/src/components/global-styles/typography-panel.js +40 -0
  264. package/src/components/image-editor/aspect-ratio-dropdown.js +1 -1
  265. package/src/components/image-editor/use-save-image.js +0 -1
  266. package/src/components/image-size-control/index.js +6 -0
  267. package/src/components/index.js +6 -0
  268. package/src/components/inserter/block-patterns-explorer/patterns-list.js +8 -2
  269. package/src/components/inserter/block-patterns-tab.js +8 -56
  270. package/src/components/inserter/hooks/use-block-types-state.js +3 -4
  271. package/src/components/inserter/hooks/use-patterns-state.js +35 -19
  272. package/src/components/inserter/media-tab/hooks.js +2 -22
  273. package/src/components/inserter/reusable-block-rename-hint.js +52 -0
  274. package/src/components/inserter/reusable-blocks-tab.js +5 -1
  275. package/src/components/inserter/reusable-blocks-tab.native.js +2 -2
  276. package/src/components/inserter/style.scss +28 -0
  277. package/src/components/inserter/tabs.native.js +5 -1
  278. package/src/components/inserter-draggable-blocks/index.js +13 -2
  279. package/src/components/link-control/constants.js +1 -1
  280. package/src/components/link-control/index.js +32 -28
  281. package/src/components/link-control/search-create-button.js +8 -26
  282. package/src/components/link-control/search-input.js +4 -3
  283. package/src/components/link-control/search-item.js +21 -43
  284. package/src/components/link-control/search-results.js +48 -46
  285. package/src/components/link-control/settings-drawer.js +6 -5
  286. package/src/components/link-control/style.scss +51 -123
  287. package/src/components/link-control/test/index.js +135 -123
  288. package/src/components/list-view/appender.js +5 -6
  289. package/src/components/list-view/style.scss +1 -2
  290. package/src/components/media-replace-flow/test/index.js +1 -1
  291. package/src/components/panel-color-settings/README.md +98 -0
  292. package/src/components/provider/index.js +9 -2
  293. package/src/components/provider/test/use-block-sync.js +21 -6
  294. package/src/components/provider/use-block-sync.js +19 -0
  295. package/src/components/recursion-provider/README.md +101 -0
  296. package/src/components/resolution-tool/index.js +56 -0
  297. package/src/components/resolution-tool/stories/index.js +48 -0
  298. package/src/components/url-input/index.js +2 -0
  299. package/src/components/writing-flow/use-tab-nav.js +10 -33
  300. package/src/components/writing-mode-control/index.js +68 -0
  301. package/src/components/writing-mode-control/style.scss +18 -0
  302. package/src/hooks/behaviors.js +25 -16
  303. package/src/hooks/supports.js +7 -0
  304. package/src/hooks/typography.js +2 -0
  305. package/src/hooks/utils.js +3 -0
  306. package/src/private-apis.js +6 -0
  307. package/src/private-apis.native.js +2 -0
  308. package/src/store/actions.js +194 -1
  309. package/src/store/defaults.js +1 -0
  310. package/src/store/index.js +10 -0
  311. package/src/store/private-actions.js +39 -39
  312. package/src/store/private-selectors.js +2 -2
  313. package/src/store/reducer.js +22 -8
  314. package/src/store/selectors.js +54 -20
  315. package/src/store/test/actions.js +111 -0
  316. package/src/store/test/private-actions.js +56 -0
@@ -20,7 +20,8 @@
20
20
 
21
21
  // Reset unwanted margin-bottom from being applied to BaseControls within certain components.
22
22
  .components-focal-point-picker-control,
23
- .components-query-controls {
23
+ .components-query-controls,
24
+ .components-range-control {
24
25
  .components-base-control {
25
26
  margin-bottom: 0;
26
27
  }
@@ -3,7 +3,8 @@
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { ToolbarButton, ToolbarGroup } from '@wordpress/components';
6
- import { useReducer } from '@wordpress/element';
6
+ import { focus } from '@wordpress/dom';
7
+ import { useReducer, useRef, useEffect } from '@wordpress/element';
7
8
  import { lock } from '@wordpress/icons';
8
9
 
9
10
  /**
@@ -12,7 +13,7 @@ import { lock } from '@wordpress/icons';
12
13
  import BlockLockModal from './modal';
13
14
  import useBlockLock from './use-block-lock';
14
15
 
15
- export default function BlockLockToolbar( { clientId } ) {
16
+ export default function BlockLockToolbar( { clientId, wrapperRef } ) {
16
17
  const { canEdit, canMove, canRemove, canLock } = useBlockLock( clientId );
17
18
 
18
19
  const [ isModalOpen, toggleModal ] = useReducer(
@@ -20,11 +21,37 @@ export default function BlockLockToolbar( { clientId } ) {
20
21
  false
21
22
  );
22
23
 
23
- if ( ! canLock ) {
24
- return null;
25
- }
24
+ const lockButtonRef = useRef( null );
25
+ const isFirstRender = useRef( true );
26
+
27
+ const shouldHideBlockLockUI =
28
+ ! canLock || ( canEdit && canMove && canRemove );
29
+
30
+ // Restore focus manually on the first focusable element in the toolbar
31
+ // when the block lock modal is closed and the block is not locked anymore.
32
+ // See https://github.com/WordPress/gutenberg/issues/51447
33
+ useEffect( () => {
34
+ if ( isFirstRender.current ) {
35
+ isFirstRender.current = false;
36
+ return;
37
+ }
38
+
39
+ if ( ! isModalOpen && shouldHideBlockLockUI ) {
40
+ focus.focusable
41
+ .find( wrapperRef.current, {
42
+ sequential: false,
43
+ } )
44
+ .find(
45
+ ( element ) =>
46
+ element.tagName === 'BUTTON' &&
47
+ element !== lockButtonRef.current
48
+ )
49
+ ?.focus();
50
+ }
51
+ // wrapperRef is a reference object and should be stable
52
+ }, [ isModalOpen, shouldHideBlockLockUI, wrapperRef ] );
26
53
 
27
- if ( canEdit && canMove && canRemove ) {
54
+ if ( shouldHideBlockLockUI ) {
28
55
  return null;
29
56
  }
30
57
 
@@ -35,6 +62,7 @@ export default function BlockLockToolbar( { clientId } ) {
35
62
  icon={ lock }
36
63
  label={ __( 'Unlock' ) }
37
64
  onClick={ toggleModal }
65
+ ref={ lockButtonRef }
38
66
  />
39
67
  </ToolbarGroup>
40
68
  { isModalOpen && (
@@ -213,16 +213,12 @@ const BlockActionsMenu = ( {
213
213
  id: 'convertToRegularBlocksOption',
214
214
  label:
215
215
  innerBlockCount > 1
216
- ? __( 'Convert to regular blocks' )
217
- : __( 'Convert to regular block' ),
216
+ ? __( 'Detach patterns' )
217
+ : __( 'Detach pattern' ),
218
218
  value: 'convertToRegularBlocksOption',
219
219
  onSelect: () => {
220
- const successNotice =
221
- innerBlockCount > 1
222
- ? /* translators: %s: name of the reusable block */
223
- __( '%s converted to regular blocks' )
224
- : /* translators: %s: name of the reusable block */
225
- __( '%s converted to regular block' );
220
+ /* translators: %s: name of the synced block */
221
+ const successNotice = __( '%s detached' );
226
222
  createSuccessNotice(
227
223
  sprintf(
228
224
  successNotice,
@@ -14,6 +14,7 @@ import useBlockDisplayInformation from '../use-block-display-information';
14
14
  import BlockIcon from '../block-icon';
15
15
  import { useShowMoversGestures } from '../block-toolbar/utils';
16
16
  import { store as blockEditorStore } from '../../store';
17
+ import { unlock } from '../../lock-unlock';
17
18
 
18
19
  /**
19
20
  * Block parent selector component, displaying the hierarchy of the
@@ -24,14 +25,15 @@ import { store as blockEditorStore } from '../../store';
24
25
  export default function BlockParentSelector() {
25
26
  const { selectBlock, toggleBlockHighlight } =
26
27
  useDispatch( blockEditorStore );
27
- const { firstParentClientId, shouldHide, isDistractionFree } = useSelect(
28
+ const { firstParentClientId, isVisible, isDistractionFree } = useSelect(
28
29
  ( select ) => {
29
30
  const {
30
31
  getBlockName,
31
32
  getBlockParents,
32
33
  getSelectedBlockClientId,
33
34
  getSettings,
34
- } = select( blockEditorStore );
35
+ getBlockEditingMode,
36
+ } = unlock( select( blockEditorStore ) );
35
37
  const { hasBlockSupport } = select( blocksStore );
36
38
  const selectedBlockClientId = getSelectedBlockClientId();
37
39
  const parents = getBlockParents( selectedBlockClientId );
@@ -41,11 +43,14 @@ export default function BlockParentSelector() {
41
43
  const settings = getSettings();
42
44
  return {
43
45
  firstParentClientId: _firstParentClientId,
44
- shouldHide: ! hasBlockSupport(
45
- _parentBlockType,
46
- '__experimentalParentSelector',
47
- true
48
- ),
46
+ isVisible:
47
+ _firstParentClientId &&
48
+ getBlockEditingMode( _firstParentClientId ) === 'default' &&
49
+ hasBlockSupport(
50
+ _parentBlockType,
51
+ '__experimentalParentSelector',
52
+ true
53
+ ),
49
54
  isDistractionFree: settings.isDistractionFree,
50
55
  };
51
56
  },
@@ -66,7 +71,7 @@ export default function BlockParentSelector() {
66
71
  },
67
72
  } );
68
73
 
69
- if ( shouldHide || firstParentClientId === undefined ) {
74
+ if ( ! isVisible ) {
70
75
  return null;
71
76
  }
72
77
 
@@ -8,7 +8,7 @@ import {
8
8
  Button,
9
9
  __experimentalHStack as HStack,
10
10
  } from '@wordpress/components';
11
- import { __, _n } from '@wordpress/i18n';
11
+ import { __ } from '@wordpress/i18n';
12
12
 
13
13
  /**
14
14
  * Internal dependencies
@@ -16,38 +16,26 @@ import { __, _n } from '@wordpress/i18n';
16
16
  import { store as blockEditorStore } from '../../store';
17
17
  import { unlock } from '../../lock-unlock';
18
18
 
19
- // In certain editing contexts, we'd like to prevent accidental removal of
20
- // important blocks. For example, in the site editor, the Query Loop block is
21
- // deemed important. In such cases, we'll ask the user for confirmation that
22
- // they intended to remove such block(s).
23
- //
24
- // @see https://github.com/WordPress/gutenberg/pull/51145
25
- export const blockTypePromptMessages = {
26
- 'core/query': __( 'Query Loop displays a list of posts or pages.' ),
27
- 'core/post-content': __(
28
- 'Post Content displays the content of a post or page.'
29
- ),
30
- };
31
-
32
- export function BlockRemovalWarningModal() {
19
+ export function BlockRemovalWarningModal( { rules } ) {
33
20
  const { clientIds, selectPrevious, blockNamesForPrompt } = useSelect(
34
21
  ( select ) =>
35
22
  unlock( select( blockEditorStore ) ).getRemovalPromptData()
36
23
  );
37
24
 
38
25
  const {
39
- clearRemovalPrompt,
40
- toggleRemovalPromptSupport,
26
+ clearBlockRemovalPrompt,
27
+ setBlockRemovalRules,
41
28
  privateRemoveBlocks,
42
29
  } = unlock( useDispatch( blockEditorStore ) );
43
30
 
44
- // Signalling the removal prompt is in place.
31
+ // Load block removal rules, simultaneously signalling that the block
32
+ // removal prompt is in place.
45
33
  useEffect( () => {
46
- toggleRemovalPromptSupport( true );
34
+ setBlockRemovalRules( rules );
47
35
  return () => {
48
- toggleRemovalPromptSupport( false );
36
+ setBlockRemovalRules();
49
37
  };
50
- }, [ toggleRemovalPromptSupport ] );
38
+ }, [ rules, setBlockRemovalRules ] );
51
39
 
52
40
  if ( ! blockNamesForPrompt ) {
53
41
  return;
@@ -55,34 +43,33 @@ export function BlockRemovalWarningModal() {
55
43
 
56
44
  const onConfirmRemoval = () => {
57
45
  privateRemoveBlocks( clientIds, selectPrevious, /* force */ true );
58
- clearRemovalPrompt();
46
+ clearBlockRemovalPrompt();
59
47
  };
60
48
 
61
49
  return (
62
50
  <Modal
63
51
  title={ __( 'Are you sure?' ) }
64
- onRequestClose={ clearRemovalPrompt }
52
+ onRequestClose={ clearBlockRemovalPrompt }
53
+ style={ {
54
+ maxWidth: '40rem',
55
+ } }
65
56
  >
66
57
  { blockNamesForPrompt.length === 1 ? (
67
- <p>{ blockTypePromptMessages[ blockNamesForPrompt[ 0 ] ] }</p>
58
+ <p>{ rules[ blockNamesForPrompt[ 0 ] ] }</p>
68
59
  ) : (
69
60
  <ul style={ { listStyleType: 'disc', paddingLeft: '1rem' } }>
70
61
  { blockNamesForPrompt.map( ( name ) => (
71
- <li key={ name }>
72
- { blockTypePromptMessages[ name ] }
73
- </li>
62
+ <li key={ name }>{ rules[ name ] }</li>
74
63
  ) ) }
75
64
  </ul>
76
65
  ) }
77
66
  <p>
78
- { _n(
79
- 'Removing this block is not advised.',
80
- 'Removing these blocks is not advised.',
81
- blockNamesForPrompt.length
82
- ) }
67
+ { blockNamesForPrompt.length > 1
68
+ ? __( 'Removing these blocks is not advised.' )
69
+ : __( 'Removing this block is not advised.' ) }
83
70
  </p>
84
71
  <HStack justify="right">
85
- <Button variant="tertiary" onClick={ clearRemovalPrompt }>
72
+ <Button variant="tertiary" onClick={ clearBlockRemovalPrompt }>
86
73
  { __( 'Cancel' ) }
87
74
  </Button>
88
75
  <Button variant="primary" onClick={ onConfirmRemoval }>
@@ -78,6 +78,8 @@ const BlockToolbar = ( { hideDragHandle } ) => {
78
78
  };
79
79
  }, [] );
80
80
 
81
+ const toolbarWrapperRef = useRef( null );
82
+
81
83
  // Handles highlighting the current block outline on hover or focus of the
82
84
  // block type toolbar area.
83
85
  const { toggleBlockHighlight } = useDispatch( blockEditorStore );
@@ -123,18 +125,19 @@ const BlockToolbar = ( { hideDragHandle } ) => {
123
125
  } );
124
126
 
125
127
  return (
126
- <div className={ classes }>
128
+ <div className={ classes } ref={ toolbarWrapperRef }>
127
129
  { ! isMultiToolbar &&
128
130
  isLargeViewport &&
129
131
  blockEditingMode === 'default' && <BlockParentSelector /> }
130
- <div ref={ nodeRef } { ...showMoversGestures }>
131
- { ( shouldShowVisualToolbar || isMultiToolbar ) &&
132
- blockEditingMode === 'default' && (
132
+ { ( shouldShowVisualToolbar || isMultiToolbar ) &&
133
+ blockEditingMode === 'default' && (
134
+ <div ref={ nodeRef } { ...showMoversGestures }>
133
135
  <ToolbarGroup className="block-editor-block-toolbar__block-controls">
134
136
  <BlockSwitcher clientIds={ blockClientIds } />
135
137
  { ! isMultiToolbar && (
136
138
  <BlockLockToolbar
137
139
  clientId={ blockClientIds[ 0 ] }
140
+ wrapperRef={ toolbarWrapperRef }
138
141
  />
139
142
  ) }
140
143
  <BlockMover
@@ -142,8 +145,8 @@ const BlockToolbar = ( { hideDragHandle } ) => {
142
145
  hideDragHandle={ hideDragHandle }
143
146
  />
144
147
  </ToolbarGroup>
145
- ) }
146
- </div>
148
+ </div>
149
+ ) }
147
150
  { shouldShowVisualToolbar && isMultiToolbar && (
148
151
  <BlockGroupToolbar />
149
152
  ) }
@@ -15,7 +15,7 @@ import {
15
15
  ToolbarButton,
16
16
  ToolbarGroup,
17
17
  } from '@wordpress/components';
18
- import { levelUp } from '@wordpress/icons';
18
+ import { next, previous } from '@wordpress/icons';
19
19
  import { useViewportMatch } from '@wordpress/compose';
20
20
 
21
21
  /**
@@ -24,7 +24,6 @@ import { useViewportMatch } from '@wordpress/compose';
24
24
  import NavigableToolbar from '../navigable-toolbar';
25
25
  import BlockToolbar from '../block-toolbar';
26
26
  import { store as blockEditorStore } from '../../store';
27
- import BlockIcon from '../block-icon';
28
27
  import { unlock } from '../../lock-unlock';
29
28
 
30
29
  function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
@@ -57,6 +56,7 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
57
56
  hasParents: parents.length,
58
57
  showParentSelector:
59
58
  parentBlockType &&
59
+ getBlockEditingMode( firstParentClientId ) === 'default' &&
60
60
  hasBlockSupport(
61
61
  parentBlockType,
62
62
  '__experimentalParentSelector',
@@ -93,6 +93,7 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
93
93
  aria-label={ __( 'Block tools' ) }
94
94
  { ...props }
95
95
  >
96
+ { ! isCollapsed && <BlockToolbar hideDragHandle={ isFixed } /> }
96
97
  { isFixed && isLargeViewport && blockType && (
97
98
  <ToolbarGroup
98
99
  className={
@@ -104,13 +105,7 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
104
105
  <ToolbarItem
105
106
  as={ ToolbarButton }
106
107
  ref={ toolbarButtonRef }
107
- icon={
108
- isCollapsed ? (
109
- <BlockIcon icon={ blockType.icon } />
110
- ) : (
111
- levelUp
112
- )
113
- }
108
+ icon={ isCollapsed ? next : previous }
114
109
  onClick={ () => {
115
110
  setIsCollapsed( ( collapsed ) => ! collapsed );
116
111
  toolbarButtonRef.current.focus();
@@ -118,12 +113,11 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
118
113
  label={
119
114
  isCollapsed
120
115
  ? __( 'Show block tools' )
121
- : __( 'Show document tools' )
116
+ : __( 'Hide block tools' )
122
117
  }
123
118
  />
124
119
  </ToolbarGroup>
125
120
  ) }
126
- { ! isCollapsed && <BlockToolbar hideDragHandle={ isFixed } /> }
127
121
  </NavigableToolbar>
128
122
  );
129
123
  }
@@ -121,17 +121,21 @@
121
121
  }
122
122
  }
123
123
 
124
+ &:has(.block-editor-block-toolbar:empty) {
125
+ display: none;
126
+ }
127
+
124
128
  // on desktop and tablet viewports the toolbar is fixed
125
129
  // on top of interface header
126
130
 
127
131
  @include break-medium() {
128
132
  &.is-fixed {
129
133
 
130
- // leave room for block inserter
131
- margin-left: $grid-unit-80;
134
+ // leave room for block inserter, undo and redo, list view
135
+ margin-left: $grid-unit-80 * 3 - 2 * $grid-unit + $grid-unit-05;
132
136
  // position on top of interface header
133
137
  position: fixed;
134
- top: $admin-bar-height + $grid-unit;
138
+ top: $admin-bar-height + $grid-unit - $border-width;
135
139
  // Don't fill up when empty
136
140
  min-height: initial;
137
141
  // remove the border
@@ -141,32 +145,63 @@
141
145
 
142
146
  &.is-collapsed {
143
147
  width: initial;
144
- margin-left: $grid-unit-80 * 3 + $grid-unit-30;
145
148
  }
146
149
 
147
150
  .is-fullscreen-mode & {
148
- // leave room for block inserter
149
- margin-left: $grid-unit-80 + $grid-unit-70;
150
- top: $grid-unit;
151
+ // leave room for block inserter, undo and redo, list view
152
+ // and some margin left
153
+ margin-left: $grid-unit-80 * 4 - 2 * $grid-unit;
154
+ top: $grid-unit - $border-width;
151
155
  &.is-collapsed {
152
156
  width: initial;
153
- margin-left: $grid-unit-80 * 4 + $grid-unit-30;
157
+ }
158
+ }
159
+
160
+ & > .block-editor-block-toolbar.is-showing-movers {
161
+ flex-grow: initial;
162
+ width: initial;
163
+
164
+ // Add a border as separator in the block toolbar.
165
+ &::before {
166
+ content: "";
167
+ width: $border-width;
168
+ height: 3 * $grid-unit;
169
+ margin-top: $grid-unit + $grid-unit-05;
170
+ margin-right: 0;
171
+ background-color: $gray-300;
172
+ position: relative;
173
+ left: math.div(-$grid-unit-05, 2);
174
+ top: -1px;
154
175
  }
155
176
  }
156
177
 
157
178
  & > .block-editor-block-toolbar__group-collapse-fixed-toolbar {
158
179
  border: none;
159
180
 
181
+ .show-icon-labels & {
182
+ .components-button.has-icon {
183
+ // Hide the button icons when labels are set to display...
184
+ svg {
185
+ display: none;
186
+ }
187
+ // ... and display labels.
188
+ &::after {
189
+ content: attr(aria-label);
190
+ font-size: $helptext-font-size;
191
+ }
192
+ }
193
+ }
194
+
160
195
  // Add a border as separator in the block toolbar.
161
- &::after {
196
+ &::before {
162
197
  content: "";
163
198
  width: $border-width;
164
- height: 24px;
199
+ height: 3 * $grid-unit;
165
200
  margin-top: $grid-unit + $grid-unit-05;
166
- margin-bottom: $grid-unit + $grid-unit-05;
201
+ margin-right: $grid-unit-10;
167
202
  background-color: $gray-300;
168
- position: absolute;
169
- left: 44px;
203
+ position: relative;
204
+ left: 0;
170
205
  top: -1px;
171
206
  }
172
207
  }
@@ -174,6 +209,21 @@
174
209
  & > .block-editor-block-toolbar__group-expand-fixed-toolbar {
175
210
  border: none;
176
211
 
212
+ .show-icon-labels & {
213
+ width: $grid-unit-80 * 4;
214
+ .components-button.has-icon {
215
+ // Hide the button icons when labels are set to display...
216
+ svg {
217
+ display: none;
218
+ }
219
+ // ... and display labels.
220
+ &::after {
221
+ content: attr(aria-label);
222
+ font-size: $helptext-font-size;
223
+ }
224
+ }
225
+ }
226
+
177
227
  // Add a border as separator in the block toolbar.
178
228
  &::before {
179
229
  content: "";
@@ -182,27 +232,20 @@
182
232
  margin-bottom: $grid-unit + $grid-unit-05;
183
233
  background-color: $gray-300;
184
234
  position: relative;
185
- left: -12px; //the padding of buttons
186
- height: 24px;
235
+ left: -8px;
236
+ height: 3 * $grid-unit;
237
+ top: -1px;
187
238
  }
188
239
  }
189
240
 
190
241
  .show-icon-labels & {
191
242
 
192
- margin-left: $grid-unit-80;
193
-
194
- &.is-collapsed {
195
- margin-left: $grid-unit-80 * 6;
196
- }
243
+ margin-left: $grid-unit-80 + 2 * $grid-unit; // inserter and margin ;
197
244
 
198
245
  .is-fullscreen-mode & {
199
- margin-left: $grid-unit-80 + $grid-unit-80;
200
- &.is-collapsed {
201
- margin-left: $grid-unit-80 * 7;
202
- }
246
+ margin-left: $grid-unit * 18; // site hub, inserter and margin
203
247
  }
204
248
 
205
-
206
249
  .block-editor-block-parent-selector .block-editor-block-parent-selector__button::after {
207
250
  left: 0;
208
251
  }
@@ -230,12 +273,14 @@
230
273
  }
231
274
 
232
275
  &.is-fixed .block-editor-block-parent-selector {
276
+
233
277
  .block-editor-block-parent-selector__button {
234
278
  position: relative;
235
279
  top: -1px;
236
280
  border: 0;
237
281
  padding-right: 6px;
238
282
  padding-left: 6px;
283
+
239
284
  &::after {
240
285
  content: "\00B7";
241
286
  font-size: 16px;
@@ -277,7 +322,9 @@
277
322
  // for the block inserter the publish button
278
323
  @include break-large() {
279
324
  &.is-fixed {
280
- width: initial;
325
+ // the combined with of the tools at the right of the header and the margin left
326
+ // of the toolbar which includes four buttons
327
+ width: calc(100% - 240px - #{4 * $grid-unit-80});
281
328
  }
282
329
  }
283
330
 
@@ -26,6 +26,17 @@
26
26
  opacity: 0.62;
27
27
  }
28
28
 
29
+ // In "constrained" layout containers, the first and last paragraphs have their margins zeroed out.
30
+ // In the case of this appender, it needs to apply those same rules to avoid layout shifts.
31
+ // Such shifts happen when the bottom margin of the Title block has been set to less than the default 1em margin of paragraphs.
32
+ :where(body .is-layout-constrained) & {
33
+ > :first-child:first-child {
34
+ margin-block-start: 0;
35
+ }
36
+
37
+ // Since this particular appender will only ever appear on an entirely empty document, we don't account for last-child.
38
+ }
39
+
29
40
  // Dropzone.
30
41
  .components-drop-zone__content-icon {
31
42
  display: none;
@@ -0,0 +1,124 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ SelectControl,
6
+ __experimentalToolsPanelItem as ToolsPanelItem,
7
+ } from '@wordpress/components';
8
+ import { __, _x } from '@wordpress/i18n';
9
+
10
+ /**
11
+ * @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps
12
+ */
13
+
14
+ /**
15
+ * @type {SelectControlProps[]}
16
+ */
17
+ export const DEFAULT_ASPECT_RATIO_OPTIONS = [
18
+ {
19
+ label: _x( 'Original', 'Aspect ratio option for dimensions control' ),
20
+ value: 'auto',
21
+ },
22
+ {
23
+ label: _x(
24
+ 'Square - 1:1',
25
+ 'Aspect ratio option for dimensions control'
26
+ ),
27
+ value: '1',
28
+ },
29
+ {
30
+ label: _x(
31
+ 'Standard - 4:3',
32
+ 'Aspect ratio option for dimensions control'
33
+ ),
34
+ value: '4/3',
35
+ },
36
+ {
37
+ label: _x(
38
+ 'Portrait - 3:4',
39
+ 'Aspect ratio option for dimensions control'
40
+ ),
41
+ value: '3/4',
42
+ },
43
+ {
44
+ label: _x(
45
+ 'Classic - 3:2',
46
+ 'Aspect ratio option for dimensions control'
47
+ ),
48
+ value: '3/2',
49
+ },
50
+ {
51
+ label: _x(
52
+ 'Classic Portrait - 2:3',
53
+ 'Aspect ratio option for dimensions control'
54
+ ),
55
+ value: '2/3',
56
+ },
57
+ {
58
+ label: _x(
59
+ 'Wide - 16:9',
60
+ 'Aspect ratio option for dimensions control'
61
+ ),
62
+ value: '16/9',
63
+ },
64
+ {
65
+ label: _x(
66
+ 'Tall - 9:16',
67
+ 'Aspect ratio option for dimensions control'
68
+ ),
69
+ value: '9/16',
70
+ },
71
+ {
72
+ label: _x( 'Custom', 'Aspect ratio option for dimensions control' ),
73
+ value: 'custom',
74
+ disabled: true,
75
+ hidden: true,
76
+ },
77
+ ];
78
+
79
+ /**
80
+ * @callback AspectRatioToolPropsOnChange
81
+ * @param {string} [value] New aspect ratio value.
82
+ * @return {void} No return.
83
+ */
84
+
85
+ /**
86
+ * @typedef {Object} AspectRatioToolProps
87
+ * @property {string} [panelId] ID of the panel this tool is associated with.
88
+ * @property {string} [value] Current aspect ratio value.
89
+ * @property {AspectRatioToolPropsOnChange} [onChange] Callback to update the aspect ratio value.
90
+ * @property {SelectControlProps[]} [options] Aspect ratio options.
91
+ * @property {string} [defaultValue] Default aspect ratio value.
92
+ * @property {boolean} [isShownByDefault] Whether the tool is shown by default.
93
+ */
94
+
95
+ export default function AspectRatioTool( {
96
+ panelId,
97
+ value,
98
+ onChange = () => {},
99
+ options = DEFAULT_ASPECT_RATIO_OPTIONS,
100
+ defaultValue = DEFAULT_ASPECT_RATIO_OPTIONS[ 0 ].value,
101
+ isShownByDefault = true,
102
+ } ) {
103
+ // Match the CSS default so if the value is used directly in CSS it will look correct in the control.
104
+ const displayValue = value ?? 'auto';
105
+
106
+ return (
107
+ <ToolsPanelItem
108
+ hasValue={ () => displayValue !== defaultValue }
109
+ label={ __( 'Aspect ratio' ) }
110
+ onDeselect={ () => onChange( undefined ) }
111
+ isShownByDefault={ isShownByDefault }
112
+ panelId={ panelId }
113
+ >
114
+ <SelectControl
115
+ label={ __( 'Aspect ratio' ) }
116
+ value={ displayValue }
117
+ options={ options }
118
+ onChange={ onChange }
119
+ size={ '__unstable-large' }
120
+ __nextHasNoMarginBottom
121
+ />
122
+ </ToolsPanelItem>
123
+ );
124
+ }