@wordpress/block-editor 16.2.0 → 17.0.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 (328) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/build/components/block-inspector/index.cjs +9 -6
  3. package/build/components/block-inspector/index.cjs.map +2 -2
  4. package/build/components/block-keyboard-shortcuts/index.cjs +201 -0
  5. package/build/components/block-keyboard-shortcuts/index.cjs.map +7 -0
  6. package/build/components/block-list/block.cjs +10 -3
  7. package/build/components/block-list/block.cjs.map +2 -2
  8. package/build/components/block-list/index.cjs +6 -1
  9. package/build/components/block-list/index.cjs.map +2 -2
  10. package/build/components/block-list/use-block-props/use-focus-first-element.cjs +4 -0
  11. package/build/components/block-list/use-block-props/use-focus-first-element.cjs.map +2 -2
  12. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs +6 -7
  13. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs.map +2 -2
  14. package/build/components/block-parent-selector/index.cjs +98 -29
  15. package/build/components/block-parent-selector/index.cjs.map +3 -3
  16. package/build/components/block-popover/inbetween.cjs +2 -2
  17. package/build/components/block-popover/inbetween.cjs.map +2 -2
  18. package/build/components/block-preview/index.cjs +0 -4
  19. package/build/components/block-preview/index.cjs.map +2 -2
  20. package/build/components/block-styles/index.cjs +77 -33
  21. package/build/components/block-styles/index.cjs.map +3 -3
  22. package/build/components/block-visibility/constants.cjs.map +2 -2
  23. package/build/components/child-layout-control/index.cjs.map +2 -2
  24. package/build/components/colors/with-colors.cjs +55 -71
  25. package/build/components/colors/with-colors.cjs.map +2 -2
  26. package/build/components/dimensions-tool/aspect-ratio-tool.cjs +4 -2
  27. package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +2 -2
  28. package/build/components/dimensions-tool/index.cjs +18 -16
  29. package/build/components/dimensions-tool/index.cjs.map +2 -2
  30. package/build/components/dimensions-tool/utils.cjs +61 -0
  31. package/build/components/dimensions-tool/utils.cjs.map +7 -0
  32. package/build/components/duotone-control/index.cjs +2 -0
  33. package/build/components/duotone-control/index.cjs.map +2 -2
  34. package/build/components/global-styles/advanced-panel.cjs.map +3 -3
  35. package/build/components/global-styles/border-panel.cjs +2 -5
  36. package/build/components/global-styles/border-panel.cjs.map +2 -2
  37. package/build/components/global-styles/color-panel.cjs +14 -2
  38. package/build/components/global-styles/color-panel.cjs.map +2 -2
  39. package/build/components/global-styles/dimensions-panel.cjs +9 -5
  40. package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
  41. package/build/components/global-styles/filters-panel.cjs +12 -8
  42. package/build/components/global-styles/filters-panel.cjs.map +2 -2
  43. package/build/components/global-styles/shadow-panel-components.cjs +16 -11
  44. package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
  45. package/build/components/global-styles/utils.cjs +9 -0
  46. package/build/components/global-styles/utils.cjs.map +2 -2
  47. package/build/components/inner-blocks/index.cjs +5 -3
  48. package/build/components/inner-blocks/index.cjs.map +2 -2
  49. package/build/components/inserter/block-patterns-explorer/index.cjs +39 -22
  50. package/build/components/inserter/block-patterns-explorer/index.cjs.map +2 -2
  51. package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.cjs +21 -55
  52. package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.cjs.map +2 -2
  53. package/build/components/inserter/block-patterns-explorer/pattern-list.cjs +19 -44
  54. package/build/components/inserter/block-patterns-explorer/pattern-list.cjs.map +3 -3
  55. package/build/components/inserter/hooks/use-insertion-point.cjs +4 -4
  56. package/build/components/inserter/hooks/use-insertion-point.cjs.map +2 -2
  57. package/build/components/inserter/menu.cjs +18 -7
  58. package/build/components/inserter/menu.cjs.map +2 -2
  59. package/build/components/inserter/quick-inserter.cjs +30 -27
  60. package/build/components/inserter/quick-inserter.cjs.map +2 -2
  61. package/build/components/inspector-controls-tabs/styles-tab.cjs +1 -1
  62. package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
  63. package/build/components/list-view/index.cjs +31 -5
  64. package/build/components/list-view/index.cjs.map +3 -3
  65. package/build/components/list-view/utils.cjs +13 -1
  66. package/build/components/list-view/utils.cjs.map +2 -2
  67. package/build/components/media-placeholder/index.cjs +1 -1
  68. package/build/components/media-placeholder/index.cjs.map +3 -3
  69. package/build/components/provider/index.cjs +5 -1
  70. package/build/components/provider/index.cjs.map +3 -3
  71. package/build/components/publish-date-time-picker/index.cjs +3 -2
  72. package/build/components/publish-date-time-picker/index.cjs.map +2 -2
  73. package/build/components/rich-text/event-listeners/enter.cjs +46 -39
  74. package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
  75. package/build/components/rich-text/index.cjs +7 -5
  76. package/build/components/rich-text/index.cjs.map +2 -2
  77. package/build/components/rich-text/multiline.cjs +105 -70
  78. package/build/components/rich-text/multiline.cjs.map +3 -3
  79. package/build/components/url-input/index.cjs.map +2 -2
  80. package/build/components/writing-flow/use-input.cjs +65 -13
  81. package/build/components/writing-flow/use-input.cjs.map +3 -3
  82. package/build/hooks/border.cjs +25 -3
  83. package/build/hooks/border.cjs.map +2 -2
  84. package/build/hooks/dimensions.cjs +9 -2
  85. package/build/hooks/dimensions.cjs.map +2 -2
  86. package/build/hooks/duotone.cjs +4 -3
  87. package/build/hooks/duotone.cjs.map +2 -2
  88. package/build/hooks/gap.cjs +8 -2
  89. package/build/hooks/gap.cjs.map +2 -2
  90. package/build/hooks/layout-child.cjs +35 -13
  91. package/build/hooks/layout-child.cjs.map +2 -2
  92. package/build/hooks/layout.cjs +23 -1
  93. package/build/hooks/layout.cjs.map +2 -2
  94. package/build/hooks/states.cjs +7 -4
  95. package/build/hooks/states.cjs.map +2 -2
  96. package/build/layouts/constrained.cjs +8 -1
  97. package/build/layouts/constrained.cjs.map +2 -2
  98. package/build/layouts/flex.cjs +9 -0
  99. package/build/layouts/flex.cjs.map +2 -2
  100. package/build/layouts/flow.cjs +4 -1
  101. package/build/layouts/flow.cjs.map +2 -2
  102. package/build/layouts/grid.cjs +5 -1
  103. package/build/layouts/grid.cjs.map +2 -2
  104. package/build/private-apis.cjs +3 -1
  105. package/build/private-apis.cjs.map +2 -2
  106. package/build/store/actions.cjs +1 -1
  107. package/build/store/actions.cjs.map +2 -2
  108. package/build-module/components/block-inspector/index.mjs +9 -6
  109. package/build-module/components/block-inspector/index.mjs.map +2 -2
  110. package/build-module/components/block-keyboard-shortcuts/index.mjs +173 -0
  111. package/build-module/components/block-keyboard-shortcuts/index.mjs.map +7 -0
  112. package/build-module/components/block-list/block.mjs +10 -3
  113. package/build-module/components/block-list/block.mjs.map +2 -2
  114. package/build-module/components/block-list/index.mjs +6 -1
  115. package/build-module/components/block-list/index.mjs.map +2 -2
  116. package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs +4 -0
  117. package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs.map +2 -2
  118. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs +6 -7
  119. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs.map +2 -2
  120. package/build-module/components/block-parent-selector/index.mjs +101 -32
  121. package/build-module/components/block-parent-selector/index.mjs.map +2 -2
  122. package/build-module/components/block-popover/inbetween.mjs +2 -2
  123. package/build-module/components/block-popover/inbetween.mjs.map +2 -2
  124. package/build-module/components/block-preview/index.mjs +0 -4
  125. package/build-module/components/block-preview/index.mjs.map +2 -2
  126. package/build-module/components/block-styles/index.mjs +79 -35
  127. package/build-module/components/block-styles/index.mjs.map +2 -2
  128. package/build-module/components/block-visibility/constants.mjs.map +2 -2
  129. package/build-module/components/child-layout-control/index.mjs +5 -5
  130. package/build-module/components/child-layout-control/index.mjs.map +1 -1
  131. package/build-module/components/colors/with-colors.mjs +56 -72
  132. package/build-module/components/colors/with-colors.mjs.map +2 -2
  133. package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +4 -2
  134. package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
  135. package/build-module/components/dimensions-tool/index.mjs +19 -17
  136. package/build-module/components/dimensions-tool/index.mjs.map +2 -2
  137. package/build-module/components/dimensions-tool/utils.mjs +35 -0
  138. package/build-module/components/dimensions-tool/utils.mjs.map +7 -0
  139. package/build-module/components/duotone-control/index.mjs +2 -0
  140. package/build-module/components/duotone-control/index.mjs.map +2 -2
  141. package/build-module/components/global-styles/advanced-panel.mjs +5 -2
  142. package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
  143. package/build-module/components/global-styles/border-panel.mjs +2 -5
  144. package/build-module/components/global-styles/border-panel.mjs.map +2 -2
  145. package/build-module/components/global-styles/color-panel.mjs +14 -2
  146. package/build-module/components/global-styles/color-panel.mjs.map +2 -2
  147. package/build-module/components/global-styles/dimensions-panel.mjs +9 -5
  148. package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
  149. package/build-module/components/global-styles/filters-panel.mjs +16 -9
  150. package/build-module/components/global-styles/filters-panel.mjs.map +2 -2
  151. package/build-module/components/global-styles/shadow-panel-components.mjs +16 -11
  152. package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
  153. package/build-module/components/global-styles/utils.mjs +8 -0
  154. package/build-module/components/global-styles/utils.mjs.map +2 -2
  155. package/build-module/components/inner-blocks/index.mjs +5 -3
  156. package/build-module/components/inner-blocks/index.mjs.map +2 -2
  157. package/build-module/components/inserter/block-patterns-explorer/index.mjs +39 -22
  158. package/build-module/components/inserter/block-patterns-explorer/index.mjs.map +2 -2
  159. package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.mjs +22 -56
  160. package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.mjs.map +2 -2
  161. package/build-module/components/inserter/block-patterns-explorer/pattern-list.mjs +20 -45
  162. package/build-module/components/inserter/block-patterns-explorer/pattern-list.mjs.map +2 -2
  163. package/build-module/components/inserter/hooks/use-insertion-point.mjs +4 -4
  164. package/build-module/components/inserter/hooks/use-insertion-point.mjs.map +2 -2
  165. package/build-module/components/inserter/menu.mjs +19 -8
  166. package/build-module/components/inserter/menu.mjs.map +2 -2
  167. package/build-module/components/inserter/quick-inserter.mjs +30 -27
  168. package/build-module/components/inserter/quick-inserter.mjs.map +2 -2
  169. package/build-module/components/inspector-controls-tabs/styles-tab.mjs +1 -1
  170. package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
  171. package/build-module/components/list-view/index.mjs +32 -5
  172. package/build-module/components/list-view/index.mjs.map +3 -3
  173. package/build-module/components/list-view/utils.mjs +13 -1
  174. package/build-module/components/list-view/utils.mjs.map +2 -2
  175. package/build-module/components/media-placeholder/index.mjs +3 -3
  176. package/build-module/components/media-placeholder/index.mjs.map +2 -2
  177. package/build-module/components/provider/index.mjs +6 -2
  178. package/build-module/components/provider/index.mjs.map +2 -2
  179. package/build-module/components/publish-date-time-picker/index.mjs +3 -2
  180. package/build-module/components/publish-date-time-picker/index.mjs.map +2 -2
  181. package/build-module/components/rich-text/event-listeners/enter.mjs +46 -39
  182. package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
  183. package/build-module/components/rich-text/index.mjs +7 -5
  184. package/build-module/components/rich-text/index.mjs.map +2 -2
  185. package/build-module/components/rich-text/multiline.mjs +112 -72
  186. package/build-module/components/rich-text/multiline.mjs.map +2 -2
  187. package/build-module/components/url-input/index.mjs +2 -2
  188. package/build-module/components/url-input/index.mjs.map +1 -1
  189. package/build-module/components/writing-flow/use-input.mjs +66 -14
  190. package/build-module/components/writing-flow/use-input.mjs.map +3 -3
  191. package/build-module/hooks/border.mjs +26 -8
  192. package/build-module/hooks/border.mjs.map +2 -2
  193. package/build-module/hooks/dimensions.mjs +9 -2
  194. package/build-module/hooks/dimensions.mjs.map +2 -2
  195. package/build-module/hooks/duotone.mjs +8 -4
  196. package/build-module/hooks/duotone.mjs.map +2 -2
  197. package/build-module/hooks/gap.mjs +6 -1
  198. package/build-module/hooks/gap.mjs.map +2 -2
  199. package/build-module/hooks/layout-child.mjs +36 -13
  200. package/build-module/hooks/layout-child.mjs.map +2 -2
  201. package/build-module/hooks/layout.mjs +22 -1
  202. package/build-module/hooks/layout.mjs.map +2 -2
  203. package/build-module/hooks/states.mjs +8 -5
  204. package/build-module/hooks/states.mjs.map +2 -2
  205. package/build-module/layouts/constrained.mjs +8 -1
  206. package/build-module/layouts/constrained.mjs.map +2 -2
  207. package/build-module/layouts/flex.mjs +9 -0
  208. package/build-module/layouts/flex.mjs.map +2 -2
  209. package/build-module/layouts/flow.mjs +4 -1
  210. package/build-module/layouts/flow.mjs.map +2 -2
  211. package/build-module/layouts/grid.mjs +5 -1
  212. package/build-module/layouts/grid.mjs.map +2 -2
  213. package/build-module/private-apis.mjs +3 -1
  214. package/build-module/private-apis.mjs.map +2 -2
  215. package/build-module/store/actions.mjs +1 -1
  216. package/build-module/store/actions.mjs.map +2 -2
  217. package/build-style/style-rtl.css +108 -71
  218. package/build-style/style.css +108 -71
  219. package/build-types/components/block-visibility/constants.d.ts +4 -3
  220. package/build-types/components/block-visibility/constants.d.ts.map +1 -1
  221. package/package.json +43 -43
  222. package/src/components/background-image-control/README.md +122 -0
  223. package/src/components/block-edit-visually-button/README.md +39 -0
  224. package/src/components/block-editing-mode/README.md +72 -0
  225. package/src/components/block-inspector/index.js +6 -6
  226. package/src/components/block-keyboard-shortcuts/index.js +256 -0
  227. package/src/components/block-list/block.js +7 -0
  228. package/src/components/block-list/index.js +7 -1
  229. package/src/components/block-list/use-block-props/use-focus-first-element.js +5 -0
  230. package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +6 -8
  231. package/src/components/block-parent-selector/index.js +111 -30
  232. package/src/components/block-popover/README.md +10 -3
  233. package/src/components/block-popover/inbetween.js +8 -2
  234. package/src/components/block-popover/stories/index.story.jsx +143 -0
  235. package/src/components/block-preview/index.js +0 -2
  236. package/src/components/block-styles/index.js +95 -43
  237. package/src/components/block-styles/style.scss +5 -34
  238. package/src/components/block-tools/style.scss +94 -0
  239. package/src/components/block-visibility/constants.ts +4 -3
  240. package/src/components/child-layout-control/index.js +5 -5
  241. package/src/components/color-palette/test/__snapshots__/control.js.snap +3 -29
  242. package/src/components/colors/test/with-colors.js +6 -7
  243. package/src/components/colors/with-colors.js +79 -105
  244. package/src/components/dimensions-tool/aspect-ratio-tool.js +16 -4
  245. package/src/components/dimensions-tool/index.js +34 -22
  246. package/src/components/dimensions-tool/test/index.js +166 -2
  247. package/src/components/dimensions-tool/test/utils.js +51 -0
  248. package/src/components/dimensions-tool/utils.js +67 -0
  249. package/src/components/duotone-control/index.js +2 -0
  250. package/src/components/duotone-control/test/index.js +100 -0
  251. package/src/components/global-styles/advanced-panel.js +5 -2
  252. package/src/components/global-styles/border-panel.js +11 -9
  253. package/src/components/global-styles/color-panel.js +13 -1
  254. package/src/components/global-styles/dimensions-panel.js +17 -5
  255. package/src/components/global-styles/filters-panel.js +24 -10
  256. package/src/components/global-styles/shadow-panel-components.js +38 -11
  257. package/src/components/global-styles/test/border-panel.js +230 -0
  258. package/src/components/global-styles/test/color-panel.js +24 -0
  259. package/src/components/global-styles/test/dimensions-panel.js +98 -7
  260. package/src/components/global-styles/test/filters-panel.js +84 -0
  261. package/src/components/global-styles/test/utils.js +30 -0
  262. package/src/components/global-styles/utils.js +23 -0
  263. package/src/components/inner-blocks/index.js +11 -2
  264. package/src/components/inner-blocks/stories/index.story.jsx +246 -0
  265. package/src/components/inserter/block-patterns-explorer/index.js +24 -11
  266. package/src/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +18 -56
  267. package/src/components/inserter/block-patterns-explorer/pattern-list.js +22 -47
  268. package/src/components/inserter/hooks/use-insertion-point.js +9 -4
  269. package/src/components/inserter/menu.js +23 -10
  270. package/src/components/inserter/quick-inserter.js +15 -13
  271. package/src/components/inserter/style.scss +44 -62
  272. package/src/components/inspector-controls-tabs/README.md +92 -0
  273. package/src/components/inspector-controls-tabs/styles-tab.js +1 -1
  274. package/src/components/link-control/test/index.js +5 -0
  275. package/src/components/list-view/index.js +50 -7
  276. package/src/components/list-view/utils.js +16 -1
  277. package/src/components/media-placeholder/index.js +9 -4
  278. package/src/components/plain-text/stories/index.story.jsx +3 -0
  279. package/src/components/provider/index.js +7 -1
  280. package/src/components/publish-date-time-picker/README.md +10 -0
  281. package/src/components/publish-date-time-picker/index.js +17 -14
  282. package/src/components/rich-text/event-listeners/enter.js +58 -45
  283. package/src/components/rich-text/index.js +9 -4
  284. package/src/components/rich-text/multiline.js +126 -86
  285. package/src/components/url-input/index.js +2 -2
  286. package/src/components/url-input/test/fixtures/validated-input-control-deprecation.js +27 -0
  287. package/src/components/url-input/test/index.js +5 -0
  288. package/src/components/url-popover/README.md +7 -0
  289. package/src/components/url-popover/stories/index.story.jsx +133 -47
  290. package/src/components/writing-flow/use-input.js +105 -15
  291. package/src/hooks/border.js +27 -8
  292. package/src/hooks/dimensions.js +8 -1
  293. package/src/hooks/duotone.js +23 -7
  294. package/src/hooks/gap.js +16 -0
  295. package/src/hooks/layout-child.js +41 -9
  296. package/src/hooks/layout.js +117 -71
  297. package/src/hooks/states.js +8 -5
  298. package/src/hooks/test/gap.js +31 -1
  299. package/src/hooks/test/layout-child.js +60 -1
  300. package/src/hooks/test/layout.js +27 -0
  301. package/src/layouts/constrained.js +9 -1
  302. package/src/layouts/flex.js +15 -0
  303. package/src/layouts/flow.js +4 -1
  304. package/src/layouts/grid.js +9 -1
  305. package/src/layouts/test/constrained.js +26 -0
  306. package/src/layouts/test/flow.js +26 -0
  307. package/src/layouts/test/grid.js +46 -0
  308. package/src/private-apis.js +2 -0
  309. package/src/store/actions.js +14 -1
  310. package/build/components/floating-toolbar/nav-up-icon.cjs +0 -52
  311. package/build/components/floating-toolbar/nav-up-icon.cjs.map +0 -7
  312. package/build/components/gradients/with-gradient.cjs +0 -36
  313. package/build/components/gradients/with-gradient.cjs.map +0 -7
  314. package/build/components/inserter-button/sparkles.cjs +0 -36
  315. package/build/components/inserter-button/sparkles.cjs.map +0 -7
  316. package/build-module/components/floating-toolbar/nav-up-icon.mjs +0 -31
  317. package/build-module/components/floating-toolbar/nav-up-icon.mjs.map +0 -7
  318. package/build-module/components/gradients/with-gradient.mjs +0 -11
  319. package/build-module/components/gradients/with-gradient.mjs.map +0 -7
  320. package/build-module/components/inserter-button/sparkles.mjs +0 -15
  321. package/build-module/components/inserter-button/sparkles.mjs.map +0 -7
  322. package/build-style/default-editor-styles-rtl.css +0 -68
  323. package/build-style/default-editor-styles.css +0 -68
  324. package/src/components/floating-toolbar/nav-up-icon.js +0 -22
  325. package/src/components/gradients/with-gradient.js +0 -9
  326. package/src/components/inserter-button/README.md +0 -62
  327. package/src/components/inserter-button/sparkles.js +0 -12
  328. package/src/default-editor-styles.scss +0 -25
@@ -119,6 +119,14 @@
119
119
  margin-left: 0;
120
120
  }
121
121
  }
122
+
123
+ // Make room for the inserter next to the parent selector.
124
+ &.has-parent:has(.block-editor-block-parent-selector__inserter) {
125
+ margin-left: calc(#{$grid-unit-60} + #{$grid-unit-30} + #{$grid-unit-15} + #{$grid-unit-10} + 2 * #{$border-width});
126
+ .show-icon-labels & {
127
+ margin-left: 0;
128
+ }
129
+ }
122
130
  }
123
131
 
124
132
  .block-editor-block-toolbar {
@@ -149,6 +157,92 @@
149
157
  position: absolute;
150
158
  left: calc(-#{$grid-unit-60} - #{$grid-unit-10} - #{$border-width});
151
159
 
160
+ // With the inserter next to the parent button, the border moves to
161
+ // the shared container so the pair reads as one toolbar segment.
162
+ // The toolbar group sizing comes from the components-toolbar-group
163
+ // class the container carries when the inserter is in it; only the
164
+ // detached position and the full border are its own.
165
+ &:has(.block-editor-block-parent-selector__inserter) {
166
+ left: calc(-#{$grid-unit-60} - #{$grid-unit-30} - #{$grid-unit-15} - #{$grid-unit-10} - 3 * #{$border-width});
167
+ border: $border-width solid $gray-900;
168
+ border-radius: $radius-small;
169
+ // The box paints the background, like the toolbar box does for
170
+ // its groups.
171
+ background-color: $white;
172
+
173
+ // The same rule the Toolbar container has for its last group;
174
+ // this box stands in for it here.
175
+ > .components-toolbar-group:last-child {
176
+ border-right: none;
177
+ }
178
+
179
+ .block-editor-block-parent-selector__button {
180
+ // Buttons in a toolbar are transparent; the box paints the
181
+ // background and border behind them.
182
+ border: none;
183
+ background: none;
184
+ }
185
+ }
186
+
187
+ .block-editor-block-parent-selector__inserter.components-button.has-icon {
188
+ color: $white;
189
+ background: transparent;
190
+
191
+ // The black square every other inserter has, drawn under the
192
+ // icon in the middle of the target.
193
+ &::after {
194
+ content: "";
195
+ position: absolute;
196
+ z-index: -1;
197
+ top: 50%;
198
+ left: 50%;
199
+ transform: translate(-50%, -50%);
200
+ width: $button-size-small;
201
+ height: $button-size-small;
202
+ border-radius: $radius-small;
203
+ background: $gray-900;
204
+ }
205
+
206
+ &:hover {
207
+ color: $white;
208
+
209
+ &::after {
210
+ background: var(--wp-admin-theme-color);
211
+ }
212
+ }
213
+
214
+ // With the text labels preference, the button shows its label
215
+ // like every other toolbar button, not the black square.
216
+ .show-icon-labels & {
217
+ width: auto;
218
+ padding: 0 $grid-unit-15;
219
+ color: inherit;
220
+
221
+ svg {
222
+ display: none;
223
+ }
224
+
225
+ &::after {
226
+ content: attr(aria-label);
227
+ position: static;
228
+ transform: none;
229
+ width: auto;
230
+ height: auto;
231
+ border-radius: 0;
232
+ background: none;
233
+ white-space: nowrap;
234
+ }
235
+
236
+ &:hover {
237
+ color: var(--wp-admin-theme-color);
238
+
239
+ &::after {
240
+ background: none;
241
+ }
242
+ }
243
+ }
244
+ }
245
+
152
246
  &::before {
153
247
  content: "";
154
248
  }
@@ -10,9 +10,10 @@ export type BlockVisibilityViewport = 'desktop' | 'tablet' | 'mobile';
10
10
  /**
11
11
  * The choices for the block visibility.
12
12
  *
13
- * Duplicated in packages/editor/src/components/preview-dropdown/index.js (choices array)
14
- * and packages/edit-site/src/components/block-editor/use-viewport-sync.js
15
- * (VALID_DEVICE_TYPES). Update all three when adding new viewport types.
13
+ * Duplicated in packages/editor/src/components/preview-dropdown/index.js (choices
14
+ * array), packages/edit-site/src/components/block-editor/viewport.js and
15
+ * packages/boot/src/components/canvas/viewport.ts (VALID_VIEWPORTS). Update all
16
+ * four when adding new viewport types.
16
17
  *
17
18
  * @todo create a single source of truth for the viewport types.
18
19
  */
@@ -2,7 +2,7 @@ import {
2
2
  __experimentalToggleGroupControl as ToggleGroupControl,
3
3
  __experimentalToggleGroupControlOption as ToggleGroupControlOption,
4
4
  __experimentalUnitControl as UnitControl,
5
- __experimentalInputControl as InputControl,
5
+ __experimentalInputControl as WCInputControl,
6
6
  __experimentalVStack as VStack,
7
7
  __experimentalToolsPanelItem as ToolsPanelItem,
8
8
  __experimentalUseCustomUnits as useCustomUnits,
@@ -298,7 +298,7 @@ function GridControls( {
298
298
  panelId={ panelId }
299
299
  >
300
300
  <FlexItem style={ { width: '50%' } }>
301
- <InputControl
301
+ <WCInputControl
302
302
  label={ __( 'Column span' ) }
303
303
  type="number"
304
304
  onChange={ ( value ) => {
@@ -322,7 +322,7 @@ function GridControls( {
322
322
  />
323
323
  </FlexItem>
324
324
  <FlexItem style={ { width: '50%' } }>
325
- <InputControl
325
+ <WCInputControl
326
326
  label={ __( 'Row span' ) }
327
327
  type="number"
328
328
  onChange={ ( value ) => {
@@ -359,7 +359,7 @@ function GridControls( {
359
359
  panelId={ panelId }
360
360
  >
361
361
  <FlexItem style={ { width: '50%' } }>
362
- <InputControl
362
+ <WCInputControl
363
363
  label={ __( 'Column' ) }
364
364
  type="number"
365
365
  onChange={ ( value ) => {
@@ -393,7 +393,7 @@ function GridControls( {
393
393
  />
394
394
  </FlexItem>
395
395
  <FlexItem style={ { width: '50%' } }>
396
- <InputControl
396
+ <WCInputControl
397
397
  label={ __( 'Row' ) }
398
398
  type="number"
399
399
  onChange={ ( value ) => {
@@ -1,38 +1,12 @@
1
1
  // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2
2
 
3
3
  exports[`ColorPaletteControl matches the snapshot 1`] = `
4
- .emotion-0 {
5
- font-family: -apple-system,system-ui,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',sans-serif;
6
- font-size: 13px;
7
- box-sizing: border-box;
8
- }
9
-
10
- .emotion-0 *,
11
- .emotion-0 *::before,
12
- .emotion-0 *::after {
13
- box-sizing: inherit;
14
- }
15
-
16
- .components-panel__row .emotion-2 {
17
- margin-bottom: inherit;
18
- }
19
-
20
- .emotion-4 {
21
- font-size: 11px;
22
- font-weight: 600;
23
- line-height: 1.4;
24
- text-transform: uppercase;
25
- display: block;
26
- margin-bottom: calc(4px * 2);
27
- padding: 0;
28
- }
29
-
30
4
  <div>
31
5
  <div
32
- class="components-base-control block-editor-color-gradient-control emotion-0 emotion-1"
6
+ class="style-wrapper components-base-control block-editor-color-gradient-control"
33
7
  >
34
8
  <div
35
- class="components-base-control__field emotion-2 emotion-3"
9
+ class="style-field components-base-control__field"
36
10
  >
37
11
  <fieldset
38
12
  class="block-editor-color-gradient-control__fieldset"
@@ -48,7 +22,7 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
48
22
  class="block-editor-color-gradient-control__color-indicator"
49
23
  >
50
24
  <span
51
- class="components-base-control__label emotion-4 emotion-5"
25
+ class="style-label components-base-control__label"
52
26
  >
53
27
  Test Color
54
28
  </span>
@@ -17,17 +17,16 @@ describe( 'createCustomColorsHOC', () => {
17
17
 
18
18
  expect( BaseComponent ).toHaveBeenCalledWith(
19
19
  expect.objectContaining( {
20
- attributes: {
20
+ attributes: expect.objectContaining( {
21
21
  backgroundColor: null,
22
- },
23
- backgroundColor: {
22
+ } ),
23
+ backgroundColor: expect.objectContaining( {
24
24
  class: undefined,
25
25
  color: undefined,
26
- },
27
- colorUtils: {
26
+ } ),
27
+ colorUtils: expect.objectContaining( {
28
28
  getMostReadableColor: expect.any( Function ),
29
- },
30
- colors: undefined,
29
+ } ),
31
30
  setBackgroundColor: expect.any( Function ),
32
31
  } ),
33
32
  expect.anything()
@@ -1,4 +1,4 @@
1
- import { useMemo, Component } from '@wordpress/element';
1
+ import { useMemo, useRef } from '@wordpress/element';
2
2
  import { compose, createHigherOrderComponent } from '@wordpress/compose';
3
3
  import { kebabCase } from '@wordpress/kebab-case';
4
4
  import {
@@ -87,119 +87,93 @@ function createColorHOC( colorTypes, withColorPalette ) {
87
87
  return compose( [
88
88
  withColorPalette,
89
89
  ( WrappedComponent ) => {
90
- return class WithColors extends Component {
91
- constructor( props ) {
92
- super( props );
90
+ return function WithColors( props ) {
91
+ const { colors: _colors, ...passedProps } = props;
92
+ const { attributes, setAttributes } = passedProps;
93
+ const prevColorPropsRef = useRef( null );
93
94
 
94
- this.setters = this.createSetters();
95
- this.colorUtils = {
96
- getMostReadableColor:
97
- this.getMostReadableColor.bind( this ),
98
- };
95
+ const colorProps = useMemo( () => {
96
+ const prevColorProps = prevColorPropsRef.current;
99
97
 
100
- this.state = {};
101
- }
98
+ const result = Object.fromEntries(
99
+ Object.entries( colorMap ).flatMap(
100
+ ( [ colorAttributeName, colorContext ] ) => {
101
+ const customAttr = `custom${ upperFirst(
102
+ colorAttributeName
103
+ ) }`;
104
+ const upperFirstColorAttributeName =
105
+ upperFirst( colorAttributeName );
102
106
 
103
- getMostReadableColor( colorValue ) {
104
- const { colors } = this.props;
105
- return getMostReadableColor( colors, colorValue );
106
- }
107
+ const colorObject =
108
+ getColorObjectByAttributeValues(
109
+ _colors,
110
+ attributes[ colorAttributeName ],
111
+ attributes[ customAttr ]
112
+ );
107
113
 
108
- createSetters() {
109
- return Object.keys( colorMap ).reduce(
110
- ( settersAccumulator, colorAttributeName ) => {
111
- const upperFirstColorAttributeName =
112
- upperFirst( colorAttributeName );
113
- const customColorAttributeName = `custom${ upperFirstColorAttributeName }`;
114
- settersAccumulator[
115
- `set${ upperFirstColorAttributeName }`
116
- ] = this.createSetColor(
117
- colorAttributeName,
118
- customColorAttributeName
119
- );
120
- return settersAccumulator;
121
- },
122
- {}
123
- );
124
- }
125
-
126
- createSetColor( colorAttributeName, customColorAttributeName ) {
127
- return ( colorValue ) => {
128
- const colorObject = getColorObjectByColorValue(
129
- this.props.colors,
130
- colorValue
131
- );
132
- this.props.setAttributes( {
133
- [ colorAttributeName ]:
134
- colorObject && colorObject.slug
135
- ? colorObject.slug
136
- : undefined,
137
- [ customColorAttributeName ]:
138
- colorObject && colorObject.slug
139
- ? undefined
140
- : colorValue,
141
- } );
142
- };
143
- }
144
-
145
- static getDerivedStateFromProps(
146
- { attributes, colors },
147
- previousState
148
- ) {
149
- return Object.entries( colorMap ).reduce(
150
- ( newState, [ colorAttributeName, colorContext ] ) => {
151
- const colorObject = getColorObjectByAttributeValues(
152
- colors,
153
- attributes[ colorAttributeName ],
154
- attributes[
155
- `custom${ upperFirst(
156
- colorAttributeName
157
- ) }`
158
- ]
159
- );
114
+ const prevColorValue =
115
+ prevColorProps?.[ colorAttributeName ];
116
+ const colorValue =
117
+ prevColorValue?.color ===
118
+ colorObject.color && prevColorValue
119
+ ? prevColorValue
120
+ : {
121
+ ...colorObject,
122
+ class: getColorClassName(
123
+ colorContext,
124
+ colorObject.slug
125
+ ),
126
+ };
160
127
 
161
- const previousColorObject =
162
- previousState[ colorAttributeName ];
163
- const previousColor = previousColorObject?.color;
164
- /**
165
- * The "and previousColorObject" condition checks that a previous color object was already computed.
166
- * At the start previousColorObject and colorValue are both equal to undefined
167
- * bus as previousColorObject does not exist we should compute the object.
168
- */
169
- if (
170
- previousColor === colorObject.color &&
171
- previousColorObject
172
- ) {
173
- newState[ colorAttributeName ] =
174
- previousColorObject;
175
- } else {
176
- newState[ colorAttributeName ] = {
177
- ...colorObject,
178
- class: getColorClassName(
179
- colorContext,
180
- colorObject.slug
181
- ),
128
+ const setter = ( newColorValue ) => {
129
+ const resolvedColorObject =
130
+ getColorObjectByColorValue(
131
+ _colors,
132
+ newColorValue
133
+ );
134
+ setAttributes( {
135
+ [ colorAttributeName ]:
136
+ resolvedColorObject?.slug ||
137
+ undefined,
138
+ [ customAttr ]:
139
+ resolvedColorObject?.slug
140
+ ? undefined
141
+ : newColorValue,
142
+ } );
182
143
  };
144
+
145
+ return [
146
+ [ colorAttributeName, colorValue ],
147
+ [
148
+ `set${ upperFirstColorAttributeName }`,
149
+ setter,
150
+ ],
151
+ ];
183
152
  }
184
- return newState;
185
- },
186
- {}
153
+ )
187
154
  );
188
- }
189
155
 
190
- render() {
191
- return (
192
- <WrappedComponent
193
- { ...{
194
- ...this.props,
195
- colors: undefined,
196
- ...this.state,
197
- ...this.setters,
198
- colorUtils: this.colorUtils,
199
- } }
200
- />
201
- );
202
- }
156
+ prevColorPropsRef.current = result;
157
+ return result;
158
+ }, [ attributes, _colors, setAttributes ] );
159
+
160
+ const colorUtils = useMemo(
161
+ () => ( {
162
+ getMostReadableColor: ( colorValue ) =>
163
+ getMostReadableColor( _colors, colorValue ),
164
+ } ),
165
+ [ _colors ]
166
+ );
167
+
168
+ return (
169
+ <WrappedComponent
170
+ { ...{
171
+ ...passedProps,
172
+ ...colorProps,
173
+ colorUtils,
174
+ } }
175
+ />
176
+ );
203
177
  };
204
178
  },
205
179
  ] );
@@ -2,6 +2,7 @@ import { SelectControl } from '@wordpress/components';
2
2
  import { __, _x } from '@wordpress/i18n';
3
3
  import { useSettings } from '../use-settings';
4
4
  import { InheritanceToolsPanelItem } from '../global-styles/inheritance';
5
+ import { findAspectRatioOption } from './utils';
5
6
 
6
7
  /**
7
8
  * @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps
@@ -38,9 +39,6 @@ export default function AspectRatioTool( {
38
39
  isInherited,
39
40
  hasLocalOverride,
40
41
  } ) {
41
- // Match the CSS default so if the value is used directly in CSS it will look correct in the control.
42
- const displayValue = value ?? 'auto';
43
-
44
42
  const [ defaultRatios, themeRatios, showDefaultRatios ] = useSettings(
45
43
  'dimensions.aspectRatios.default',
46
44
  'dimensions.aspectRatios.theme',
@@ -75,6 +73,20 @@ export default function AspectRatioTool( {
75
73
  },
76
74
  ];
77
75
 
76
+ const resolvedOptions = options ?? aspectRatioOptions;
77
+
78
+ // The value is free-form CSS, so it doesn't necessarily match an option as
79
+ // written, e.g. '1/1' and '1' describe the same ratio. Resolve it to the
80
+ // option that represents it, falling back to 'custom' so that a ratio
81
+ // without a matching preset isn't displayed as one of the presets. Values
82
+ // that are empty match the CSS default, so if the value is used directly in
83
+ // CSS it will look correct in the control.
84
+ const displayValue =
85
+ value === undefined || value === null || value === 'auto'
86
+ ? 'auto'
87
+ : findAspectRatioOption( value, resolvedOptions )?.value ??
88
+ 'custom';
89
+
78
90
  return (
79
91
  <InheritanceToolsPanelItem
80
92
  className={ className }
@@ -91,7 +103,7 @@ export default function AspectRatioTool( {
91
103
  <SelectControl
92
104
  label={ __( 'Aspect ratio' ) }
93
105
  value={ displayValue }
94
- options={ options ?? aspectRatioOptions }
106
+ options={ resolvedOptions }
95
107
  onChange={ onChange }
96
108
  />
97
109
  </InheritanceToolsPanelItem>
@@ -1,4 +1,4 @@
1
- import { useState } from '@wordpress/element';
1
+ import { useEffect, useRef } from '@wordpress/element';
2
2
  import AspectRatioTool from './aspect-ratio-tool';
3
3
  import ScaleTool from './scale-tool';
4
4
  import WidthHeightTool from './width-height-tool';
@@ -68,13 +68,33 @@ function DimensionsTool( {
68
68
  : value.aspectRatio;
69
69
  const scale = value.scale === undefined ? null : value.scale;
70
70
 
71
- // Keep track of state internally, so when the value is cleared by means
72
- // other than directly editing that field, it's easier to restore the
73
- // previous value.
74
- const [ lastScale, setLastScale ] = useState( scale );
75
- const [ lastAspectRatio, setLastAspectRatio ] = useState( aspectRatio );
76
71
  const hasCustomAspectRatio = !! ( width && height );
77
72
 
73
+ // Keep track of the previous values, so when a value is cleared by means
74
+ // other than directly editing that field, it's easier to restore it. These
75
+ // are only ever read while handling a change, so they're kept in refs and
76
+ // synced from the value to stay correct when it is updated externally, e.g.
77
+ // by undo or by another client.
78
+ const lastScaleRef = useRef( scale );
79
+ const lastAspectRatioRef = useRef( aspectRatio );
80
+
81
+ useEffect( () => {
82
+ // Scale is cleared alongside the aspect ratio, so only remember the
83
+ // values it is actually set to.
84
+ if ( scale ) {
85
+ lastScaleRef.current = scale;
86
+ }
87
+ }, [ scale ] );
88
+
89
+ useEffect( () => {
90
+ // A custom aspect ratio, i.e. both a width and a height, clears the
91
+ // aspect ratio value. Keep the remembered one so it can be restored
92
+ // once the custom aspect ratio is removed.
93
+ if ( ! hasCustomAspectRatio ) {
94
+ lastAspectRatioRef.current = aspectRatio;
95
+ }
96
+ }, [ aspectRatio, hasCustomAspectRatio ] );
97
+
78
98
  // 'custom' is not a valid value for CSS aspect-ratio, but it is used in the
79
99
  // dropdown to indicate that setting both the width and height is the same
80
100
  // as a custom aspect ratio.
@@ -97,8 +117,6 @@ function DimensionsTool( {
97
117
  nextAspectRatio =
98
118
  nextAspectRatio === 'auto' ? null : nextAspectRatio;
99
119
 
100
- setLastAspectRatio( nextAspectRatio );
101
-
102
120
  // Update aspectRatio.
103
121
  if ( ! nextAspectRatio ) {
104
122
  delete nextValue.aspectRatio;
@@ -109,11 +127,9 @@ function DimensionsTool( {
109
127
  // Auto-update scale.
110
128
  if ( ! nextAspectRatio ) {
111
129
  delete nextValue.scale;
112
- } else if ( lastScale ) {
113
- nextValue.scale = lastScale;
114
130
  } else {
115
- nextValue.scale = defaultScale;
116
- setLastScale( defaultScale );
131
+ nextValue.scale =
132
+ lastScaleRef.current ?? defaultScale;
117
133
  }
118
134
 
119
135
  // Auto-update width and height.
@@ -154,8 +170,8 @@ function DimensionsTool( {
154
170
  // Auto-update aspectRatio.
155
171
  if ( nextWidth && nextHeight ) {
156
172
  delete nextValue.aspectRatio;
157
- } else if ( lastAspectRatio ) {
158
- nextValue.aspectRatio = lastAspectRatio;
173
+ } else if ( lastAspectRatioRef.current ) {
174
+ nextValue.aspectRatio = lastAspectRatioRef.current;
159
175
  } else {
160
176
  // No setting defaultAspectRatio here, because
161
177
  // aspectRatio is optional in this scenario,
@@ -164,15 +180,13 @@ function DimensionsTool( {
164
180
 
165
181
  // Auto-update scale.
166
182
  if (
167
- ! lastAspectRatio &&
183
+ ! lastAspectRatioRef.current &&
168
184
  !! nextWidth !== !! nextHeight
169
185
  ) {
170
186
  delete nextValue.scale;
171
- } else if ( lastScale ) {
172
- nextValue.scale = lastScale;
173
187
  } else {
174
- nextValue.scale = defaultScale;
175
- setLastScale( defaultScale );
188
+ nextValue.scale =
189
+ lastScaleRef.current ?? defaultScale;
176
190
  }
177
191
 
178
192
  onChange( nextValue );
@@ -184,12 +198,10 @@ function DimensionsTool( {
184
198
  panelId={ panelId }
185
199
  options={ scaleOptions }
186
200
  defaultValue={ defaultScale }
187
- value={ lastScale }
201
+ value={ scale }
188
202
  onChange={ ( nextScale ) => {
189
203
  const nextValue = { ...value };
190
204
 
191
- setLastScale( nextScale );
192
-
193
205
  // Update scale.
194
206
  if ( ! nextScale ) {
195
207
  delete nextValue.scale;