@wordpress/block-editor 7.0.4 → 8.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 (347) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +31 -0
  3. package/build/components/alignment-control/ui.js +1 -2
  4. package/build/components/alignment-control/ui.js.map +1 -1
  5. package/build/components/block-icon/index.js +5 -1
  6. package/build/components/block-icon/index.js.map +1 -1
  7. package/build/components/block-inspector/index.js +4 -0
  8. package/build/components/block-inspector/index.js.map +1 -1
  9. package/build/components/block-list/index.native.js +1 -1
  10. package/build/components/block-list/index.native.js.map +1 -1
  11. package/build/components/block-list/use-block-props/use-multi-selection.js +21 -8
  12. package/build/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
  13. package/build/components/block-navigation/dropdown.js +0 -1
  14. package/build/components/block-navigation/dropdown.js.map +1 -1
  15. package/build/components/block-patterns-list/index.js +1 -8
  16. package/build/components/block-patterns-list/index.js.map +1 -1
  17. package/build/components/block-settings/container.native.js +5 -2
  18. package/build/components/block-settings/container.native.js.map +1 -1
  19. package/build/components/block-settings-menu/block-settings-dropdown.js +22 -2
  20. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  21. package/build/components/block-styles/preview.native.js +2 -2
  22. package/build/components/block-styles/preview.native.js.map +1 -1
  23. package/build/components/colors-gradients/control.js +8 -47
  24. package/build/components/colors-gradients/control.js.map +1 -1
  25. package/build/components/colors-gradients/panel-color-gradient-settings.js +81 -6
  26. package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  27. package/build/components/duotone-control/index.js +5 -2
  28. package/build/components/duotone-control/index.js.map +1 -1
  29. package/build/components/font-appearance-control/index.js +27 -15
  30. package/build/components/font-appearance-control/index.js.map +1 -1
  31. package/build/components/iframe/index.js +1 -1
  32. package/build/components/iframe/index.js.map +1 -1
  33. package/build/components/index.js +20 -2
  34. package/build/components/index.js.map +1 -1
  35. package/build/components/index.native.js +2 -2
  36. package/build/components/index.native.js.map +1 -1
  37. package/build/components/inner-blocks/index.js +5 -4
  38. package/build/components/inner-blocks/index.js.map +1 -1
  39. package/build/components/inner-blocks/index.native.js +4 -3
  40. package/build/components/inner-blocks/index.native.js.map +1 -1
  41. package/build/components/inserter/block-patterns-explorer/explorer.js +62 -0
  42. package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
  43. package/build/components/inserter/block-patterns-explorer/patterns-list.js +111 -0
  44. package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
  45. package/build/components/inserter/block-patterns-explorer/sidebar.js +78 -0
  46. package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
  47. package/build/components/inserter/block-patterns-tab.js +74 -45
  48. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  49. package/build/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
  50. package/build/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
  51. package/build/components/inserter/pattern-panel.js +19 -10
  52. package/build/components/inserter/pattern-panel.js.map +1 -1
  53. package/build/components/inspector-controls/groups.js +3 -1
  54. package/build/components/inspector-controls/groups.js.map +1 -1
  55. package/build/components/letter-spacing-control/index.js +9 -6
  56. package/build/components/letter-spacing-control/index.js.map +1 -1
  57. package/build/components/link-control/index.js +88 -35
  58. package/build/components/link-control/index.js.map +1 -1
  59. package/build/components/link-control/link-preview.js +19 -6
  60. package/build/components/link-control/link-preview.js.map +1 -1
  61. package/build/components/link-control/search-input.js +12 -3
  62. package/build/components/link-control/search-input.js.map +1 -1
  63. package/build/components/list-view/block.js +49 -23
  64. package/build/components/list-view/block.js.map +1 -1
  65. package/build/components/list-view/branch.js +92 -73
  66. package/build/components/list-view/branch.js.map +1 -1
  67. package/build/components/list-view/index.js +39 -16
  68. package/build/components/list-view/index.js.map +1 -1
  69. package/build/components/list-view/leaf.js +1 -1
  70. package/build/components/list-view/leaf.js.map +1 -1
  71. package/build/components/list-view/use-list-view-client-ids.js +8 -58
  72. package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
  73. package/build/components/rich-text/embed-handler-picker.native.js +1 -0
  74. package/build/components/rich-text/embed-handler-picker.native.js.map +1 -1
  75. package/build/components/rich-text/format-edit.js +28 -2
  76. package/build/components/rich-text/format-edit.js.map +1 -1
  77. package/build/components/rich-text/format-toolbar/index.js +2 -1
  78. package/build/components/rich-text/format-toolbar/index.js.map +1 -1
  79. package/build/components/url-input/index.js +11 -4
  80. package/build/components/url-input/index.js.map +1 -1
  81. package/build/components/use-setting/index.js +48 -9
  82. package/build/components/use-setting/index.js.map +1 -1
  83. package/build/hooks/border.js +5 -5
  84. package/build/hooks/border.js.map +1 -1
  85. package/build/hooks/color-panel.js +2 -1
  86. package/build/hooks/color-panel.js.map +1 -1
  87. package/build/hooks/duotone.js +16 -5
  88. package/build/hooks/duotone.js.map +1 -1
  89. package/build/hooks/font-appearance.js +49 -6
  90. package/build/hooks/font-appearance.js.map +1 -1
  91. package/build/hooks/font-family.js +37 -16
  92. package/build/hooks/font-family.js.map +1 -1
  93. package/build/hooks/font-size.js +51 -9
  94. package/build/hooks/font-size.js.map +1 -1
  95. package/build/hooks/index.js +8 -0
  96. package/build/hooks/index.js.map +1 -1
  97. package/build/hooks/index.native.js +8 -0
  98. package/build/hooks/index.native.js.map +1 -1
  99. package/build/hooks/letter-spacing.js +44 -7
  100. package/build/hooks/letter-spacing.js.map +1 -1
  101. package/build/hooks/line-height.js +45 -8
  102. package/build/hooks/line-height.js.map +1 -1
  103. package/build/hooks/margin.js +1 -1
  104. package/build/hooks/margin.js.map +1 -1
  105. package/build/hooks/padding.js +1 -1
  106. package/build/hooks/padding.js.map +1 -1
  107. package/build/hooks/text-decoration.js +42 -6
  108. package/build/hooks/text-decoration.js.map +1 -1
  109. package/build/hooks/text-transform.js +42 -6
  110. package/build/hooks/text-transform.js.map +1 -1
  111. package/build/hooks/typography.js +108 -8
  112. package/build/hooks/typography.js.map +1 -1
  113. package/build/hooks/use-cached-truthy.js +29 -0
  114. package/build/hooks/use-cached-truthy.js.map +1 -0
  115. package/build/index.js +7 -0
  116. package/build/index.js.map +1 -1
  117. package/build/layouts/flex.js +120 -28
  118. package/build/layouts/flex.js.map +1 -1
  119. package/build/store/actions.js +303 -265
  120. package/build/store/actions.js.map +1 -1
  121. package/build/store/index.js +1 -3
  122. package/build/store/index.js.map +1 -1
  123. package/build/store/reducer.js +23 -22
  124. package/build/store/reducer.js.map +1 -1
  125. package/build/store/selectors.js +44 -35
  126. package/build/store/selectors.js.map +1 -1
  127. package/build-module/components/alignment-control/ui.js +1 -2
  128. package/build-module/components/alignment-control/ui.js.map +1 -1
  129. package/build-module/components/block-icon/index.js +5 -1
  130. package/build-module/components/block-icon/index.js.map +1 -1
  131. package/build-module/components/block-inspector/index.js +4 -0
  132. package/build-module/components/block-inspector/index.js.map +1 -1
  133. package/build-module/components/block-list/index.native.js +1 -1
  134. package/build-module/components/block-list/index.native.js.map +1 -1
  135. package/build-module/components/block-list/use-block-props/use-multi-selection.js +21 -8
  136. package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
  137. package/build-module/components/block-navigation/dropdown.js +0 -1
  138. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  139. package/build-module/components/block-patterns-list/index.js +1 -6
  140. package/build-module/components/block-patterns-list/index.js.map +1 -1
  141. package/build-module/components/block-settings/container.native.js +6 -3
  142. package/build-module/components/block-settings/container.native.js.map +1 -1
  143. package/build-module/components/block-settings-menu/block-settings-dropdown.js +24 -4
  144. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  145. package/build-module/components/block-styles/preview.native.js +2 -2
  146. package/build-module/components/block-styles/preview.native.js.map +1 -1
  147. package/build-module/components/colors-gradients/control.js +12 -53
  148. package/build-module/components/colors-gradients/control.js.map +1 -1
  149. package/build-module/components/colors-gradients/panel-color-gradient-settings.js +82 -6
  150. package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  151. package/build-module/components/duotone-control/index.js +5 -2
  152. package/build-module/components/duotone-control/index.js.map +1 -1
  153. package/build-module/components/font-appearance-control/index.js +23 -15
  154. package/build-module/components/font-appearance-control/index.js.map +1 -1
  155. package/build-module/components/iframe/index.js +1 -1
  156. package/build-module/components/iframe/index.js.map +1 -1
  157. package/build-module/components/index.js +3 -1
  158. package/build-module/components/index.js.map +1 -1
  159. package/build-module/components/index.native.js +1 -1
  160. package/build-module/components/index.native.js.map +1 -1
  161. package/build-module/components/inner-blocks/index.js +6 -5
  162. package/build-module/components/inner-blocks/index.js.map +1 -1
  163. package/build-module/components/inner-blocks/index.native.js +5 -4
  164. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  165. package/build-module/components/inserter/block-patterns-explorer/explorer.js +50 -0
  166. package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
  167. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +92 -0
  168. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
  169. package/build-module/components/inserter/block-patterns-explorer/sidebar.js +69 -0
  170. package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
  171. package/build-module/components/inserter/block-patterns-tab.js +75 -46
  172. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  173. package/build-module/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
  174. package/build-module/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
  175. package/build-module/components/inserter/pattern-panel.js +21 -13
  176. package/build-module/components/inserter/pattern-panel.js.map +1 -1
  177. package/build-module/components/inspector-controls/groups.js +3 -1
  178. package/build-module/components/inspector-controls/groups.js.map +1 -1
  179. package/build-module/components/letter-spacing-control/index.js +9 -6
  180. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  181. package/build-module/components/link-control/index.js +88 -36
  182. package/build-module/components/link-control/index.js.map +1 -1
  183. package/build-module/components/link-control/link-preview.js +19 -7
  184. package/build-module/components/link-control/link-preview.js.map +1 -1
  185. package/build-module/components/link-control/search-input.js +11 -3
  186. package/build-module/components/link-control/search-input.js.map +1 -1
  187. package/build-module/components/list-view/block.js +49 -24
  188. package/build-module/components/list-view/block.js.map +1 -1
  189. package/build-module/components/list-view/branch.js +92 -73
  190. package/build-module/components/list-view/branch.js.map +1 -1
  191. package/build-module/components/list-view/index.js +41 -18
  192. package/build-module/components/list-view/index.js.map +1 -1
  193. package/build-module/components/list-view/leaf.js +1 -1
  194. package/build-module/components/list-view/leaf.js.map +1 -1
  195. package/build-module/components/list-view/use-list-view-client-ids.js +8 -58
  196. package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
  197. package/build-module/components/rich-text/embed-handler-picker.native.js +1 -0
  198. package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -1
  199. package/build-module/components/rich-text/format-edit.js +28 -3
  200. package/build-module/components/rich-text/format-edit.js.map +1 -1
  201. package/build-module/components/rich-text/format-toolbar/index.js +2 -1
  202. package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
  203. package/build-module/components/url-input/index.js +11 -4
  204. package/build-module/components/url-input/index.js.map +1 -1
  205. package/build-module/components/use-setting/index.js +48 -9
  206. package/build-module/components/use-setting/index.js.map +1 -1
  207. package/build-module/hooks/border.js +5 -5
  208. package/build-module/hooks/border.js.map +1 -1
  209. package/build-module/hooks/color-panel.js +2 -1
  210. package/build-module/hooks/color-panel.js.map +1 -1
  211. package/build-module/hooks/duotone.js +16 -5
  212. package/build-module/hooks/duotone.js.map +1 -1
  213. package/build-module/hooks/font-appearance.js +45 -6
  214. package/build-module/hooks/font-appearance.js.map +1 -1
  215. package/build-module/hooks/font-family.js +33 -16
  216. package/build-module/hooks/font-family.js.map +1 -1
  217. package/build-module/hooks/font-size.js +47 -9
  218. package/build-module/hooks/font-size.js.map +1 -1
  219. package/build-module/hooks/index.js +1 -0
  220. package/build-module/hooks/index.js.map +1 -1
  221. package/build-module/hooks/index.native.js +1 -0
  222. package/build-module/hooks/index.native.js.map +1 -1
  223. package/build-module/hooks/letter-spacing.js +40 -7
  224. package/build-module/hooks/letter-spacing.js.map +1 -1
  225. package/build-module/hooks/line-height.js +41 -8
  226. package/build-module/hooks/line-height.js.map +1 -1
  227. package/build-module/hooks/margin.js +1 -1
  228. package/build-module/hooks/margin.js.map +1 -1
  229. package/build-module/hooks/padding.js +1 -1
  230. package/build-module/hooks/padding.js.map +1 -1
  231. package/build-module/hooks/text-decoration.js +38 -6
  232. package/build-module/hooks/text-decoration.js.map +1 -1
  233. package/build-module/hooks/text-transform.js +38 -6
  234. package/build-module/hooks/text-transform.js.map +1 -1
  235. package/build-module/hooks/typography.js +117 -17
  236. package/build-module/hooks/typography.js.map +1 -1
  237. package/build-module/hooks/use-cached-truthy.js +21 -0
  238. package/build-module/hooks/use-cached-truthy.js.map +1 -0
  239. package/build-module/index.js +1 -1
  240. package/build-module/index.js.map +1 -1
  241. package/build-module/layouts/flex.js +124 -32
  242. package/build-module/layouts/flex.js.map +1 -1
  243. package/build-module/store/actions.js +266 -241
  244. package/build-module/store/actions.js.map +1 -1
  245. package/build-module/store/index.js +1 -2
  246. package/build-module/store/index.js.map +1 -1
  247. package/build-module/store/reducer.js +23 -22
  248. package/build-module/store/reducer.js.map +1 -1
  249. package/build-module/store/selectors.js +42 -30
  250. package/build-module/store/selectors.js.map +1 -1
  251. package/build-style/style-rtl.css +160 -57
  252. package/build-style/style.css +160 -57
  253. package/package.json +13 -14
  254. package/src/components/alignment-control/test/__snapshots__/index.js.snap +0 -2
  255. package/src/components/alignment-control/ui.js +1 -4
  256. package/src/components/block-draggable/style.scss +19 -4
  257. package/src/components/block-icon/index.js +4 -1
  258. package/src/components/block-inspector/index.js +5 -0
  259. package/src/components/block-list/index.native.js +1 -1
  260. package/src/components/block-list/use-block-props/use-multi-selection.js +27 -7
  261. package/src/components/block-navigation/dropdown.js +0 -1
  262. package/src/components/block-patterns-list/index.js +1 -8
  263. package/src/components/block-patterns-list/style.scss +22 -12
  264. package/src/components/block-settings/container.native.js +7 -0
  265. package/src/components/block-settings-menu/block-settings-dropdown.js +19 -7
  266. package/src/components/block-styles/preview.native.js +2 -2
  267. package/src/components/block-switcher/test/__snapshots__/index.js.snap +1 -1
  268. package/src/components/color-palette/test/__snapshots__/control.js.snap +88 -63
  269. package/src/components/colors-gradients/control.js +19 -62
  270. package/src/components/colors-gradients/panel-color-gradient-settings.js +76 -6
  271. package/src/components/colors-gradients/style.scss +3 -14
  272. package/src/components/colors-gradients/test/control.js +0 -16
  273. package/src/components/duotone-control/index.js +6 -0
  274. package/src/components/duotone-control/style.scss +27 -12
  275. package/src/components/font-appearance-control/index.js +22 -14
  276. package/src/components/iframe/index.js +1 -1
  277. package/src/components/index.js +3 -4
  278. package/src/components/index.native.js +1 -4
  279. package/src/components/inner-blocks/index.js +4 -4
  280. package/src/components/inner-blocks/index.native.js +7 -4
  281. package/src/components/inserter/block-patterns-explorer/explorer.js +50 -0
  282. package/src/components/inserter/block-patterns-explorer/patterns-list.js +122 -0
  283. package/src/components/inserter/block-patterns-explorer/sidebar.js +73 -0
  284. package/src/components/inserter/block-patterns-tab.js +107 -80
  285. package/src/components/inserter/hooks/use-block-type-impressions.native.js +14 -21
  286. package/src/components/inserter/pattern-panel.js +33 -16
  287. package/src/components/inserter/style.scss +64 -1
  288. package/src/components/inserter/test/block-types-tab.native.js +1 -1
  289. package/src/components/inserter/test/fixtures/index.native.js +12 -0
  290. package/src/components/inspector-controls/groups.js +4 -0
  291. package/src/components/letter-spacing-control/index.js +12 -6
  292. package/src/components/link-control/README.md +7 -0
  293. package/src/components/link-control/index.js +99 -34
  294. package/src/components/link-control/link-preview.js +21 -9
  295. package/src/components/link-control/search-input.js +9 -3
  296. package/src/components/link-control/style.scss +32 -16
  297. package/src/components/link-control/test/index.js +179 -4
  298. package/src/components/list-view/block.js +67 -23
  299. package/src/components/list-view/branch.js +113 -91
  300. package/src/components/list-view/index.js +58 -19
  301. package/src/components/list-view/leaf.js +1 -1
  302. package/src/components/list-view/style.scss +14 -3
  303. package/src/components/list-view/use-list-view-client-ids.js +7 -66
  304. package/src/components/rich-text/embed-handler-picker.native.js +1 -0
  305. package/src/components/rich-text/format-edit.js +36 -2
  306. package/src/components/rich-text/format-toolbar/index.js +3 -0
  307. package/src/components/url-input/index.js +14 -4
  308. package/src/components/use-setting/index.js +49 -11
  309. package/src/hooks/border.js +8 -11
  310. package/src/hooks/color-panel.js +1 -0
  311. package/src/hooks/duotone.js +21 -7
  312. package/src/hooks/font-appearance.js +38 -7
  313. package/src/hooks/font-family.js +29 -13
  314. package/src/hooks/font-size.js +42 -6
  315. package/src/hooks/index.js +1 -0
  316. package/src/hooks/index.native.js +1 -0
  317. package/src/hooks/layout.scss +3 -1
  318. package/src/hooks/letter-spacing.js +35 -7
  319. package/src/hooks/line-height.js +37 -9
  320. package/src/hooks/margin.js +1 -1
  321. package/src/hooks/padding.js +1 -1
  322. package/src/hooks/text-decoration.js +34 -6
  323. package/src/hooks/text-transform.js +34 -6
  324. package/src/hooks/typography.js +165 -15
  325. package/src/hooks/typography.scss +16 -0
  326. package/src/hooks/use-cached-truthy.js +20 -0
  327. package/src/index.js +1 -0
  328. package/src/layouts/flex.js +137 -41
  329. package/src/store/actions.js +223 -391
  330. package/src/store/index.js +1 -2
  331. package/src/store/reducer.js +36 -18
  332. package/src/store/selectors.js +52 -47
  333. package/src/store/test/actions.js +395 -694
  334. package/src/store/test/selectors.js +79 -21
  335. package/src/style.scss +1 -1
  336. package/src/utils/test/parse-css-unit-to-px.js +127 -167
  337. package/build/components/text-decoration-and-transform/index.js +0 -39
  338. package/build/components/text-decoration-and-transform/index.js.map +0 -1
  339. package/build/store/controls.js +0 -44
  340. package/build/store/controls.js.map +0 -1
  341. package/build-module/components/text-decoration-and-transform/index.js +0 -30
  342. package/build-module/components/text-decoration-and-transform/index.js.map +0 -1
  343. package/build-module/store/controls.js +0 -32
  344. package/build-module/store/controls.js.map +0 -1
  345. package/src/components/text-decoration-and-transform/index.js +0 -36
  346. package/src/components/text-decoration-and-transform/style.scss +0 -3
  347. package/src/store/controls.js +0 -39
@@ -1,23 +1,38 @@
1
+ // Must equal $color-palette-circle-size and $color-palette-circle-spacing from:
2
+ // @wordpress/components/src/circular-option-picker/style.scss
3
+ $swatch-size: 28px;
4
+ $swatch-gap: 12px;
5
+
6
+ $popover-width: $sidebar-width;
7
+ $popover-padding: $grid-unit-20;
8
+
9
+ $swatch-columns: math.floor(math.div($popover-width + $swatch-gap - 2 * $popover-padding, $swatch-size + $swatch-gap));
10
+
1
11
  .block-editor-duotone-control__popover {
2
- .components-popover__content {
3
- border: $border-width solid $gray-900;
4
- min-width: 214px;
12
+ > .components-popover__content > div {
13
+ padding: $popover-padding;
14
+ width: $popover-width;
5
15
  }
6
16
 
7
- .components-circular-option-picker {
8
- padding: $grid-unit-15;
17
+ .components-menu-group__label {
18
+ padding: 0;
9
19
  }
10
20
 
11
- .components-menu-group__label {
12
- padding: $grid-unit-15 $grid-unit-15 0 $grid-unit-15;
13
- width: 100%;
14
- box-sizing: border-box;
21
+ .components-custom-gradient-picker__gradient-bar {
22
+ margin: $grid-unit-20 0 $grid-unit-15;
23
+ }
24
+
25
+ .components-circular-option-picker__swatches {
26
+ display: grid;
27
+ grid-template-columns: repeat($swatch-columns, $swatch-size);
28
+ gap: $swatch-gap;
29
+ justify-content: space-between;
15
30
  }
16
31
  }
17
32
 
18
- .block-editor-duotone-control__popover > .components-popover__content {
19
- // Matches 8 swatches in width.
20
- width: 334px;
33
+ .block-editor-duotone-control__description {
34
+ margin: $grid-unit-20 0;
35
+ font-size: $helptext-font-size;
21
36
  }
22
37
 
23
38
  // Better align the popover under the swatch.
@@ -55,6 +55,26 @@ const FONT_WEIGHTS = [
55
55
  },
56
56
  ];
57
57
 
58
+ /**
59
+ * Adjusts font appearance field label in case either font styles or weights
60
+ * are disabled.
61
+ *
62
+ * @param {boolean} hasFontStyles Whether font styles are enabled and present.
63
+ * @param {boolean} hasFontWeights Whether font weights are enabled and present.
64
+ * @return {string} A label representing what font appearance is being edited.
65
+ */
66
+ export const getFontAppearanceLabel = ( hasFontStyles, hasFontWeights ) => {
67
+ if ( ! hasFontStyles ) {
68
+ return __( 'Font weight' );
69
+ }
70
+
71
+ if ( ! hasFontWeights ) {
72
+ return __( 'Font style' );
73
+ }
74
+
75
+ return __( 'Appearance' );
76
+ };
77
+
58
78
  /**
59
79
  * Control to display unified font style and weight options.
60
80
  *
@@ -70,6 +90,7 @@ export default function FontAppearanceControl( props ) {
70
90
  value: { fontStyle, fontWeight },
71
91
  } = props;
72
92
  const hasStylesOrWeights = hasFontStyles || hasFontWeights;
93
+ const label = getFontAppearanceLabel( hasFontStyles, hasFontWeights );
73
94
  const defaultOption = {
74
95
  key: 'default',
75
96
  name: __( 'Default' ),
@@ -152,19 +173,6 @@ export default function FontAppearanceControl( props ) {
152
173
  option.style.fontWeight === fontWeight
153
174
  ) || selectOptions[ 0 ];
154
175
 
155
- // Adjusts field label in case either styles or weights are disabled.
156
- const getLabel = () => {
157
- if ( ! hasFontStyles ) {
158
- return __( 'Font weight' );
159
- }
160
-
161
- if ( ! hasFontWeights ) {
162
- return __( 'Font style' );
163
- }
164
-
165
- return __( 'Appearance' );
166
- };
167
-
168
176
  // Adjusts screen reader description based on styles or weights.
169
177
  const getDescribedBy = () => {
170
178
  if ( ! currentSelection ) {
@@ -198,7 +206,7 @@ export default function FontAppearanceControl( props ) {
198
206
  hasStylesOrWeights && (
199
207
  <CustomSelectControl
200
208
  className="components-font-appearance-control"
201
- label={ getLabel() }
209
+ label={ label }
202
210
  describedBy={ getDescribedBy() }
203
211
  options={ selectOptions }
204
212
  value={ currentSelection }
@@ -76,7 +76,7 @@ function styleSheetsCompat( doc ) {
76
76
 
77
77
  if ( isMatch && ! doc.getElementById( ownerNode.id ) ) {
78
78
  // eslint-disable-next-line no-console
79
- console.error(
79
+ console.warn(
80
80
  `Stylesheet ${ ownerNode.id } was not properly added.
81
81
  For blocks, use the block API's style (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#style) or editorStyle (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#editor-style).
82
82
  For themes, use add_editor_style (https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#editor-styles).`,
@@ -45,6 +45,8 @@ export { default as __experimentalDuotoneControl } from './duotone-control';
45
45
  export { default as __experimentalFontAppearanceControl } from './font-appearance-control';
46
46
  export { default as __experimentalFontFamilyControl } from './font-family';
47
47
  export { default as __experimentalLetterSpacingControl } from './letter-spacing-control';
48
+ export { default as __experimentalTextDecorationControl } from './text-decoration-control';
49
+ export { default as __experimentalTextTransformControl } from './text-transform-control';
48
50
  export { default as __experimentalColorGradientControl } from './colors-gradients/control';
49
51
  export { default as __experimentalPanelColorGradientSettings } from './colors-gradients/panel-color-gradient-settings';
50
52
  export {
@@ -52,10 +54,7 @@ export {
52
54
  ImageEditingProvider as __experimentalImageEditingProvider,
53
55
  } from './image-editor';
54
56
  export { default as __experimentalImageSizeControl } from './image-size-control';
55
- export {
56
- default as InnerBlocks,
57
- useInnerBlocksProps as __experimentalUseInnerBlocksProps,
58
- } from './inner-blocks';
57
+ export { default as InnerBlocks, useInnerBlocksProps } from './inner-blocks';
59
58
  export {
60
59
  default as InspectorControls,
61
60
  InspectorAdvancedControls,
@@ -18,10 +18,7 @@ export * from './colors';
18
18
  export * from './gradients';
19
19
  export * from './font-sizes';
20
20
  export { AlignmentControl, AlignmentToolbar } from './alignment-control';
21
- export {
22
- default as InnerBlocks,
23
- useInnerBlocksProps as __experimentalUseInnerBlocksProps,
24
- } from './inner-blocks';
21
+ export { default as InnerBlocks, useInnerBlocksProps } from './inner-blocks';
25
22
  export {
26
23
  default as InspectorControls,
27
24
  InspectorAdvancedControls,
@@ -12,7 +12,7 @@ import { useSelect } from '@wordpress/data';
12
12
  import {
13
13
  getBlockType,
14
14
  store as blocksStore,
15
- withBlockContentContext,
15
+ __unstableGetInnerBlocksProps as getInnerBlocksProps,
16
16
  } from '@wordpress/blocks';
17
17
 
18
18
  /**
@@ -210,13 +210,13 @@ export function useInnerBlocksProps( props = {}, options = {} ) {
210
210
  };
211
211
  }
212
212
 
213
+ useInnerBlocksProps.save = getInnerBlocksProps;
214
+
213
215
  // Expose default appender placeholders as components.
214
216
  ForwardedInnerBlocks.DefaultBlockAppender = DefaultBlockAppender;
215
217
  ForwardedInnerBlocks.ButtonBlockAppender = ButtonBlockAppender;
216
218
 
217
- ForwardedInnerBlocks.Content = withBlockContentContext(
218
- ( { BlockContent } ) => <BlockContent />
219
- );
219
+ ForwardedInnerBlocks.Content = () => useInnerBlocksProps.save().children;
220
220
 
221
221
  /**
222
222
  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md
@@ -2,7 +2,10 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useSelect } from '@wordpress/data';
5
- import { getBlockType, withBlockContentContext } from '@wordpress/blocks';
5
+ import {
6
+ getBlockType,
7
+ __unstableGetInnerBlocksProps as getInnerBlocksProps,
8
+ } from '@wordpress/blocks';
6
9
  import { useRef } from '@wordpress/element';
7
10
 
8
11
  /**
@@ -189,9 +192,9 @@ const InnerBlocks = ( props ) => {
189
192
  InnerBlocks.DefaultBlockAppender = DefaultBlockAppender;
190
193
  InnerBlocks.ButtonBlockAppender = ButtonBlockAppender;
191
194
 
192
- InnerBlocks.Content = withBlockContentContext( ( { BlockContent } ) => (
193
- <BlockContent />
194
- ) );
195
+ useInnerBlocksProps.save = getInnerBlocksProps;
196
+
197
+ InnerBlocks.Content = () => useInnerBlocksProps.save().children;
195
198
 
196
199
  /**
197
200
  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md
@@ -0,0 +1,50 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { Modal } from '@wordpress/components';
5
+ import { useState } from '@wordpress/element';
6
+ import { __ } from '@wordpress/i18n';
7
+
8
+ /**
9
+ * Internal dependencies
10
+ */
11
+ import PatternExplorerSidebar from './sidebar';
12
+ import PatternList from './patterns-list';
13
+
14
+ function PatternsExplorer( { initialCategory, patternCategories } ) {
15
+ const [ filterValue, setFilterValue ] = useState( '' );
16
+ const [ selectedCategory, setSelectedCategory ] = useState(
17
+ initialCategory?.name
18
+ );
19
+ return (
20
+ <div className="block-editor-block-patterns-explorer">
21
+ <PatternExplorerSidebar
22
+ selectedCategory={ selectedCategory }
23
+ patternCategories={ patternCategories }
24
+ onClickCategory={ setSelectedCategory }
25
+ filterValue={ filterValue }
26
+ setFilterValue={ setFilterValue }
27
+ />
28
+ <PatternList
29
+ filterValue={ filterValue }
30
+ selectedCategory={ selectedCategory }
31
+ patternCategories={ patternCategories }
32
+ />
33
+ </div>
34
+ );
35
+ }
36
+
37
+ function PatternsExplorerModal( { onModalClose, ...restProps } ) {
38
+ return (
39
+ <Modal
40
+ title={ __( 'Patterns' ) }
41
+ closeLabel={ __( 'Close' ) }
42
+ onRequestClose={ onModalClose }
43
+ isFullScreen
44
+ >
45
+ <PatternsExplorer { ...restProps } />
46
+ </Modal>
47
+ );
48
+ }
49
+
50
+ export default PatternsExplorerModal;
@@ -0,0 +1,122 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useMemo, useEffect } from '@wordpress/element';
5
+ import { _n, sprintf } from '@wordpress/i18n';
6
+ import { useDebounce, useAsyncList } from '@wordpress/compose';
7
+ import { __experimentalHeading as Heading } from '@wordpress/components';
8
+ import { speak } from '@wordpress/a11y';
9
+
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+ import BlockPatternsList from '../../block-patterns-list';
14
+ import InserterNoResults from '../no-results';
15
+ import useInsertionPoint from '../hooks/use-insertion-point';
16
+ import usePatternsState from '../hooks/use-patterns-state';
17
+ import InserterListbox from '../../inserter-listbox';
18
+ import { searchItems } from '../search-items';
19
+
20
+ const INITIAL_INSERTER_RESULTS = 2;
21
+
22
+ function PatternsListHeader( { filterValue, filteredBlockPatternsLength } ) {
23
+ if ( ! filterValue ) {
24
+ return null;
25
+ }
26
+ return (
27
+ <Heading
28
+ level={ 2 }
29
+ lineHeight={ '48px' }
30
+ className="block-editor-block-patterns-explorer__search-results-count"
31
+ >
32
+ { sprintf(
33
+ /* translators: %d: number of patterns. %s: block pattern search query */
34
+ _n(
35
+ '%1$d pattern found for "%2$s"',
36
+ '%1$d patterns found for "%2$s"',
37
+ filteredBlockPatternsLength
38
+ ),
39
+ filteredBlockPatternsLength,
40
+ filterValue
41
+ ) }
42
+ </Heading>
43
+ );
44
+ }
45
+
46
+ function PatternList( { filterValue, selectedCategory, patternCategories } ) {
47
+ const debouncedSpeak = useDebounce( speak, 500 );
48
+ const [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {
49
+ shouldFocusBlock: true,
50
+ } );
51
+ const [ allPatterns, , onSelectBlockPattern ] = usePatternsState(
52
+ onInsertBlocks,
53
+ destinationRootClientId
54
+ );
55
+ const registeredPatternCategories = useMemo(
56
+ () =>
57
+ patternCategories.map(
58
+ ( patternCategory ) => patternCategory.name
59
+ ),
60
+ [ patternCategories ]
61
+ );
62
+
63
+ const filteredBlockPatterns = useMemo( () => {
64
+ if ( ! filterValue ) {
65
+ return allPatterns.filter( ( pattern ) =>
66
+ selectedCategory === 'uncategorized'
67
+ ? ! pattern.categories?.length ||
68
+ pattern.categories.every(
69
+ ( category ) =>
70
+ ! registeredPatternCategories.includes(
71
+ category
72
+ )
73
+ )
74
+ : pattern.categories?.includes( selectedCategory )
75
+ );
76
+ }
77
+ return searchItems( allPatterns, filterValue );
78
+ }, [ filterValue, selectedCategory, allPatterns ] );
79
+
80
+ // Announce search results on change.
81
+ useEffect( () => {
82
+ if ( ! filterValue ) {
83
+ return;
84
+ }
85
+ const count = filteredBlockPatterns.length;
86
+ const resultsFoundMessage = sprintf(
87
+ /* translators: %d: number of results. */
88
+ _n( '%d result found.', '%d results found.', count ),
89
+ count
90
+ );
91
+ debouncedSpeak( resultsFoundMessage );
92
+ }, [ filterValue, debouncedSpeak ] );
93
+
94
+ const currentShownPatterns = useAsyncList( filteredBlockPatterns, {
95
+ step: INITIAL_INSERTER_RESULTS,
96
+ } );
97
+
98
+ const hasItems = !! filteredBlockPatterns?.length;
99
+ return (
100
+ <div className="block-editor-block-patterns-explorer__list">
101
+ { hasItems && (
102
+ <PatternsListHeader
103
+ filterValue={ filterValue }
104
+ filteredBlockPatternsLength={ filteredBlockPatterns.length }
105
+ />
106
+ ) }
107
+ <InserterListbox>
108
+ { ! hasItems && <InserterNoResults /> }
109
+ { hasItems && (
110
+ <BlockPatternsList
111
+ shownPatterns={ currentShownPatterns }
112
+ blockPatterns={ filteredBlockPatterns }
113
+ onClickPattern={ onSelectBlockPattern }
114
+ isDraggable={ false }
115
+ />
116
+ ) }
117
+ </InserterListbox>
118
+ </div>
119
+ );
120
+ }
121
+
122
+ export default PatternList;
@@ -0,0 +1,73 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { Button, SearchControl } from '@wordpress/components';
5
+ import { __ } from '@wordpress/i18n';
6
+
7
+ function PatternCategoriesList( {
8
+ selectedCategory,
9
+ patternCategories,
10
+ onClickCategory,
11
+ } ) {
12
+ const baseClassName = 'block-editor-block-patterns-explorer__sidebar';
13
+ return (
14
+ <div className={ `${ baseClassName }__categories-list` }>
15
+ { patternCategories.map( ( { name, label } ) => {
16
+ return (
17
+ <Button
18
+ key={ name }
19
+ label={ label }
20
+ className={ `${ baseClassName }__categories-list__item` }
21
+ isPressed={ selectedCategory === name }
22
+ onClick={ () => {
23
+ onClickCategory( name );
24
+ } }
25
+ >
26
+ { label }
27
+ </Button>
28
+ );
29
+ } ) }
30
+ </div>
31
+ );
32
+ }
33
+
34
+ function PatternsExplorerSearch( { filterValue, setFilterValue } ) {
35
+ const baseClassName = 'block-editor-block-patterns-explorer__search';
36
+ return (
37
+ <div className={ baseClassName }>
38
+ <SearchControl
39
+ onChange={ setFilterValue }
40
+ value={ filterValue }
41
+ label={ __( 'Search for patterns' ) }
42
+ placeholder={ __( 'Search' ) }
43
+ />
44
+ </div>
45
+ );
46
+ }
47
+
48
+ function PatternExplorerSidebar( {
49
+ selectedCategory,
50
+ patternCategories,
51
+ onClickCategory,
52
+ filterValue,
53
+ setFilterValue,
54
+ } ) {
55
+ const baseClassName = 'block-editor-block-patterns-explorer__sidebar';
56
+ return (
57
+ <div className={ baseClassName }>
58
+ <PatternsExplorerSearch
59
+ filterValue={ filterValue }
60
+ setFilterValue={ setFilterValue }
61
+ />
62
+ { ! filterValue && (
63
+ <PatternCategoriesList
64
+ selectedCategory={ selectedCategory }
65
+ patternCategories={ patternCategories }
66
+ onClickCategory={ onClickCategory }
67
+ />
68
+ ) }
69
+ </div>
70
+ );
71
+ }
72
+
73
+ export default PatternExplorerSidebar;
@@ -1,12 +1,7 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { fromPairs } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
9
- import { useMemo, useCallback, useEffect } from '@wordpress/element';
4
+ import { useMemo, useState, useCallback } from '@wordpress/element';
10
5
  import { _x } from '@wordpress/i18n';
11
6
  import { useAsyncList } from '@wordpress/compose';
12
7
 
@@ -16,66 +11,30 @@ import { useAsyncList } from '@wordpress/compose';
16
11
  import PatternInserterPanel from './pattern-panel';
17
12
  import usePatternsState from './hooks/use-patterns-state';
18
13
  import BlockPatternList from '../block-patterns-list';
14
+ import PatternsExplorerModal from './block-patterns-explorer/explorer';
19
15
 
20
16
  function BlockPatternsCategory( {
21
17
  rootClientId,
22
18
  onInsert,
23
19
  selectedCategory,
24
- onClickCategory,
20
+ populatedCategories,
25
21
  } ) {
26
- const [ allPatterns, allCategories, onClick ] = usePatternsState(
22
+ const [ allPatterns, , onClick ] = usePatternsState(
27
23
  onInsert,
28
24
  rootClientId
29
25
  );
30
26
 
31
- // Remove any empty categories
32
- const populatedCategories = useMemo(
33
- () =>
34
- allCategories
35
- .filter( ( category ) =>
36
- allPatterns.some( ( pattern ) =>
37
- pattern.categories?.includes( category.name )
38
- )
39
- )
40
- .sort( ( { name: currentName }, { name: nextName } ) => {
41
- if ( ! [ currentName, nextName ].includes( 'featured' ) ) {
42
- return 0;
43
- }
44
- return currentName === 'featured' ? -1 : 1;
45
- } ),
46
- [ allPatterns, allCategories ]
47
- );
48
-
49
- const patternCategory = selectedCategory
50
- ? selectedCategory
51
- : populatedCategories[ 0 ];
52
-
53
- useEffect( () => {
54
- if (
55
- allPatterns.some(
56
- ( pattern ) => getPatternIndex( pattern ) === Infinity
57
- ) &&
58
- ! populatedCategories.find(
59
- ( category ) => category.name === 'uncategorized'
60
- )
61
- ) {
62
- populatedCategories.push( {
63
- name: 'uncategorized',
64
- label: _x( 'Uncategorized' ),
65
- } );
66
- }
67
- }, [ populatedCategories, allPatterns ] );
68
-
69
27
  const getPatternIndex = useCallback(
70
28
  ( pattern ) => {
71
- if ( ! pattern.categories || ! pattern.categories.length ) {
29
+ if ( ! pattern.categories?.length ) {
72
30
  return Infinity;
73
31
  }
74
- const indexedCategories = fromPairs(
75
- populatedCategories.map( ( { name }, index ) => [
76
- name,
77
- index,
78
- ] )
32
+ const indexedCategories = populatedCategories.reduce(
33
+ ( accumulator, { name }, index ) => {
34
+ accumulator[ name ] = index;
35
+ return accumulator;
36
+ },
37
+ {}
79
38
  );
80
39
  return Math.min(
81
40
  ...pattern.categories.map( ( cat ) =>
@@ -91,12 +50,11 @@ function BlockPatternsCategory( {
91
50
  const currentCategoryPatterns = useMemo(
92
51
  () =>
93
52
  allPatterns.filter( ( pattern ) =>
94
- patternCategory.name === 'uncategorized'
53
+ selectedCategory.name === 'uncategorized'
95
54
  ? getPatternIndex( pattern ) === Infinity
96
- : pattern.categories &&
97
- pattern.categories.includes( patternCategory.name )
55
+ : pattern.categories?.includes( selectedCategory.name )
98
56
  ),
99
- [ allPatterns, patternCategory ]
57
+ [ allPatterns, selectedCategory ]
100
58
  );
101
59
 
102
60
  // Ordering the patterns is important for the async rendering.
@@ -108,25 +66,21 @@ function BlockPatternsCategory( {
108
66
 
109
67
  const currentShownPatterns = useAsyncList( orderedPatterns );
110
68
 
69
+ if ( ! currentCategoryPatterns.length ) {
70
+ return null;
71
+ }
72
+
111
73
  return (
112
- <>
113
- { !! currentCategoryPatterns.length && (
114
- <PatternInserterPanel
115
- selectedCategory={ patternCategory }
116
- patternCategories={ populatedCategories }
117
- onClickCategory={ onClickCategory }
118
- >
119
- <BlockPatternList
120
- shownPatterns={ currentShownPatterns }
121
- blockPatterns={ currentCategoryPatterns }
122
- onClickPattern={ onClick }
123
- label={ patternCategory.label }
124
- orientation="vertical"
125
- isDraggable
126
- />
127
- </PatternInserterPanel>
128
- ) }
129
- </>
74
+ <div className="block-editor-inserter__panel-content">
75
+ <BlockPatternList
76
+ shownPatterns={ currentShownPatterns }
77
+ blockPatterns={ currentCategoryPatterns }
78
+ onClickPattern={ onClick }
79
+ label={ selectedCategory.label }
80
+ orientation="vertical"
81
+ isDraggable
82
+ />
83
+ </div>
130
84
  );
131
85
  }
132
86
 
@@ -136,13 +90,86 @@ function BlockPatternsTabs( {
136
90
  onClickCategory,
137
91
  selectedCategory,
138
92
  } ) {
93
+ const [ showPatternsExplorer, setShowPatternsExplorer ] = useState( false );
94
+ const [ allPatterns, allCategories ] = usePatternsState();
95
+
96
+ const hasRegisteredCategory = useCallback(
97
+ ( pattern ) => {
98
+ if ( ! pattern.categories || ! pattern.categories.length ) {
99
+ return false;
100
+ }
101
+
102
+ return pattern.categories.some( ( cat ) =>
103
+ allCategories.some( ( category ) => category.name === cat )
104
+ );
105
+ },
106
+ [ allCategories ]
107
+ );
108
+
109
+ // Remove any empty categories
110
+ const populatedCategories = useMemo( () => {
111
+ const categories = allCategories
112
+ .filter( ( category ) =>
113
+ allPatterns.some( ( pattern ) =>
114
+ pattern.categories?.includes( category.name )
115
+ )
116
+ )
117
+ .sort( ( { name: currentName }, { name: nextName } ) => {
118
+ if ( ! [ currentName, nextName ].includes( 'featured' ) ) {
119
+ return 0;
120
+ }
121
+ return currentName === 'featured' ? -1 : 1;
122
+ } );
123
+
124
+ if (
125
+ allPatterns.some(
126
+ ( pattern ) => ! hasRegisteredCategory( pattern )
127
+ ) &&
128
+ ! categories.find(
129
+ ( category ) => category.name === 'uncategorized'
130
+ )
131
+ ) {
132
+ categories.push( {
133
+ name: 'uncategorized',
134
+ label: _x( 'Uncategorized' ),
135
+ } );
136
+ }
137
+
138
+ return categories;
139
+ }, [ allPatterns, allCategories ] );
140
+
141
+ const patternCategory = selectedCategory
142
+ ? selectedCategory
143
+ : populatedCategories[ 0 ];
144
+
139
145
  return (
140
- <BlockPatternsCategory
141
- rootClientId={ rootClientId }
142
- selectedCategory={ selectedCategory }
143
- onInsert={ onInsert }
144
- onClickCategory={ onClickCategory }
145
- />
146
+ <>
147
+ { ! showPatternsExplorer && (
148
+ <>
149
+ <PatternInserterPanel
150
+ selectedCategory={ patternCategory }
151
+ patternCategories={ populatedCategories }
152
+ onClickCategory={ onClickCategory }
153
+ openPatternExplorer={ () =>
154
+ setShowPatternsExplorer( true )
155
+ }
156
+ />
157
+ <BlockPatternsCategory
158
+ rootClientId={ rootClientId }
159
+ onInsert={ onInsert }
160
+ selectedCategory={ patternCategory }
161
+ populatedCategories={ populatedCategories }
162
+ />
163
+ </>
164
+ ) }
165
+ { showPatternsExplorer && (
166
+ <PatternsExplorerModal
167
+ initialCategory={ patternCategory }
168
+ patternCategories={ populatedCategories }
169
+ onModalClose={ () => setShowPatternsExplorer( false ) }
170
+ />
171
+ ) }
172
+ </>
146
173
  );
147
174
  }
148
175