@wordpress/block-editor 13.2.0 → 13.3.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 (367) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +0 -1
  3. package/build/components/block-breadcrumb/index.js +12 -1
  4. package/build/components/block-breadcrumb/index.js.map +1 -1
  5. package/build/components/block-lock/toolbar.js +0 -1
  6. package/build/components/block-lock/toolbar.js.map +1 -1
  7. package/build/components/block-mover/button.js +1 -1
  8. package/build/components/block-mover/button.js.map +1 -1
  9. package/build/components/block-mover/index.js +1 -1
  10. package/build/components/block-mover/index.js.map +1 -1
  11. package/build/components/block-pattern-setup/setup-toolbar.js +2 -2
  12. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  13. package/build/components/block-patterns-paging/index.js +5 -7
  14. package/build/components/block-patterns-paging/index.js.map +1 -1
  15. package/build/components/block-quick-navigation/index.js +20 -17
  16. package/build/components/block-quick-navigation/index.js.map +1 -1
  17. package/build/components/block-rename/modal.js +4 -12
  18. package/build/components/block-rename/modal.js.map +1 -1
  19. package/build/components/block-toolbar/shuffle.js +1 -0
  20. package/build/components/block-toolbar/shuffle.js.map +1 -1
  21. package/build/components/block-tools/block-selection-button.js +7 -58
  22. package/build/components/block-tools/block-selection-button.js.map +1 -1
  23. package/build/components/block-tools/block-toolbar-breadcrumb.js +9 -2
  24. package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
  25. package/build/components/block-tools/index.js +14 -1
  26. package/build/components/block-tools/index.js.map +1 -1
  27. package/build/components/block-tools/use-show-block-tools.js +4 -2
  28. package/build/components/block-tools/use-show-block-tools.js.map +1 -1
  29. package/build/components/block-tools/zoom-out-mode-inserters.js +5 -4
  30. package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  31. package/build/components/block-tools/zoom-out-popover.js +57 -0
  32. package/build/components/block-tools/zoom-out-popover.js.map +1 -0
  33. package/build/components/block-tools/zoom-out-toolbar.js +138 -0
  34. package/build/components/block-tools/zoom-out-toolbar.js.map +1 -0
  35. package/build/components/button-block-appender/index.js +3 -1
  36. package/build/components/button-block-appender/index.js.map +1 -1
  37. package/build/components/child-layout-control/index.js +26 -18
  38. package/build/components/child-layout-control/index.js.map +1 -1
  39. package/build/components/date-format-picker/index.js +10 -1
  40. package/build/components/date-format-picker/index.js.map +1 -1
  41. package/build/components/dimensions-tool/index.js +6 -4
  42. package/build/components/dimensions-tool/index.js.map +1 -1
  43. package/build/components/font-appearance-control/index.js +26 -61
  44. package/build/components/font-appearance-control/index.js.map +1 -1
  45. package/build/components/global-styles/background-panel.js +178 -116
  46. package/build/components/global-styles/background-panel.js.map +1 -1
  47. package/build/components/global-styles/border-panel.js +2 -1
  48. package/build/components/global-styles/border-panel.js.map +1 -1
  49. package/build/components/global-styles/color-panel.js +2 -1
  50. package/build/components/global-styles/color-panel.js.map +1 -1
  51. package/build/components/global-styles/dimensions-panel.js +2 -1
  52. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  53. package/build/components/global-styles/filters-panel.js +2 -1
  54. package/build/components/global-styles/filters-panel.js.map +1 -1
  55. package/build/components/global-styles/hooks.js +8 -0
  56. package/build/components/global-styles/hooks.js.map +1 -1
  57. package/build/components/global-styles/image-settings-panel.js +2 -1
  58. package/build/components/global-styles/image-settings-panel.js.map +1 -1
  59. package/build/components/global-styles/typography-panel.js +50 -12
  60. package/build/components/global-styles/typography-panel.js.map +1 -1
  61. package/build/components/global-styles/typography-utils.js +50 -0
  62. package/build/components/global-styles/typography-utils.js.map +1 -1
  63. package/build/components/global-styles/use-global-styles-output.js +23 -8
  64. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  65. package/build/components/global-styles/utils.js +17 -7
  66. package/build/components/global-styles/utils.js.map +1 -1
  67. package/build/components/grid/grid-item-movers.js +11 -14
  68. package/build/components/grid/grid-item-movers.js.map +1 -1
  69. package/build/components/grid/grid-item-resizer.js +2 -2
  70. package/build/components/grid/grid-item-resizer.js.map +1 -1
  71. package/build/components/grid/grid-visualizer.js +116 -36
  72. package/build/components/grid/grid-visualizer.js.map +1 -1
  73. package/build/components/grid/use-grid-layout-sync.js +29 -22
  74. package/build/components/grid/use-grid-layout-sync.js.map +1 -1
  75. package/build/components/inner-blocks/index.js +1 -1
  76. package/build/components/inner-blocks/index.js.map +1 -1
  77. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -19
  78. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
  79. package/build/components/inserter/menu.js +26 -4
  80. package/build/components/inserter/menu.js.map +1 -1
  81. package/build/components/inserter/quick-inserter.js +2 -1
  82. package/build/components/inserter/quick-inserter.js.map +1 -1
  83. package/build/components/inspector-controls/block-support-tools-panel.js +2 -1
  84. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  85. package/build/components/link-control/link-preview.js +1 -1
  86. package/build/components/link-control/link-preview.js.map +1 -1
  87. package/build/components/media-placeholder/index.js +19 -23
  88. package/build/components/media-placeholder/index.js.map +1 -1
  89. package/build/components/navigable-toolbar/index.js +3 -1
  90. package/build/components/navigable-toolbar/index.js.map +1 -1
  91. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +5 -1
  92. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  93. package/build/components/tabbed-sidebar/index.js +66 -0
  94. package/build/components/tabbed-sidebar/index.js.map +1 -0
  95. package/build/components/url-popover/index.js +3 -0
  96. package/build/components/url-popover/index.js.map +1 -1
  97. package/build/hooks/background.js +26 -4
  98. package/build/hooks/background.js.map +1 -1
  99. package/build/hooks/block-hooks.js +11 -17
  100. package/build/hooks/block-hooks.js.map +1 -1
  101. package/build/hooks/block-style-variation.js +169 -4
  102. package/build/hooks/block-style-variation.js.map +1 -1
  103. package/build/hooks/duotone.js +16 -11
  104. package/build/hooks/duotone.js.map +1 -1
  105. package/build/hooks/grid-visualizer.js +65 -0
  106. package/build/hooks/grid-visualizer.js.map +1 -0
  107. package/build/hooks/index.js +15 -2
  108. package/build/hooks/index.js.map +1 -1
  109. package/build/hooks/layout-child.js +39 -22
  110. package/build/hooks/layout-child.js.map +1 -1
  111. package/build/hooks/position.js +2 -9
  112. package/build/hooks/position.js.map +1 -1
  113. package/build/hooks/use-bindings-attributes.js +16 -6
  114. package/build/hooks/use-bindings-attributes.js.map +1 -1
  115. package/build/hooks/utils.js +2 -0
  116. package/build/hooks/utils.js.map +1 -1
  117. package/build/layouts/constrained.js +44 -2
  118. package/build/layouts/constrained.js.map +1 -1
  119. package/build/layouts/grid.js +90 -51
  120. package/build/layouts/grid.js.map +1 -1
  121. package/build/private-apis.js +6 -1
  122. package/build/private-apis.js.map +1 -1
  123. package/build/store/defaults.js +0 -2
  124. package/build/store/defaults.js.map +1 -1
  125. package/build/store/defaults.native.js +0 -3
  126. package/build/store/defaults.native.js.map +1 -1
  127. package/build/store/private-keys.js +2 -1
  128. package/build/store/private-keys.js.map +1 -1
  129. package/build/utils/format-font-style.js +45 -0
  130. package/build/utils/format-font-style.js.map +1 -0
  131. package/build/utils/format-font-weight.js +68 -0
  132. package/build/utils/format-font-weight.js.map +1 -0
  133. package/build/utils/get-editor-region.js +34 -0
  134. package/build/utils/get-editor-region.js.map +1 -0
  135. package/build/utils/get-font-styles-and-weights.js +167 -0
  136. package/build/utils/get-font-styles-and-weights.js.map +1 -0
  137. package/build/utils/pasting.js +5 -13
  138. package/build/utils/pasting.js.map +1 -1
  139. package/build-module/components/block-breadcrumb/index.js +12 -1
  140. package/build-module/components/block-breadcrumb/index.js.map +1 -1
  141. package/build-module/components/block-lock/toolbar.js +0 -1
  142. package/build-module/components/block-lock/toolbar.js.map +1 -1
  143. package/build-module/components/block-mover/button.js +1 -1
  144. package/build-module/components/block-mover/button.js.map +1 -1
  145. package/build-module/components/block-mover/index.js +1 -1
  146. package/build-module/components/block-mover/index.js.map +1 -1
  147. package/build-module/components/block-pattern-setup/setup-toolbar.js +2 -2
  148. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  149. package/build-module/components/block-patterns-paging/index.js +5 -7
  150. package/build-module/components/block-patterns-paging/index.js.map +1 -1
  151. package/build-module/components/block-quick-navigation/index.js +20 -17
  152. package/build-module/components/block-quick-navigation/index.js.map +1 -1
  153. package/build-module/components/block-rename/modal.js +5 -13
  154. package/build-module/components/block-rename/modal.js.map +1 -1
  155. package/build-module/components/block-toolbar/shuffle.js +1 -0
  156. package/build-module/components/block-toolbar/shuffle.js.map +1 -1
  157. package/build-module/components/block-tools/block-selection-button.js +10 -61
  158. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  159. package/build-module/components/block-tools/block-toolbar-breadcrumb.js +9 -2
  160. package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
  161. package/build-module/components/block-tools/index.js +14 -1
  162. package/build-module/components/block-tools/index.js.map +1 -1
  163. package/build-module/components/block-tools/use-show-block-tools.js +4 -2
  164. package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
  165. package/build-module/components/block-tools/zoom-out-mode-inserters.js +5 -4
  166. package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  167. package/build-module/components/block-tools/zoom-out-popover.js +48 -0
  168. package/build-module/components/block-tools/zoom-out-popover.js.map +1 -0
  169. package/build-module/components/block-tools/zoom-out-toolbar.js +131 -0
  170. package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -0
  171. package/build-module/components/button-block-appender/index.js +3 -1
  172. package/build-module/components/button-block-appender/index.js.map +1 -1
  173. package/build-module/components/child-layout-control/index.js +27 -19
  174. package/build-module/components/child-layout-control/index.js.map +1 -1
  175. package/build-module/components/date-format-picker/index.js +11 -3
  176. package/build-module/components/date-format-picker/index.js.map +1 -1
  177. package/build-module/components/dimensions-tool/index.js +6 -4
  178. package/build-module/components/dimensions-tool/index.js.map +1 -1
  179. package/build-module/components/font-appearance-control/index.js +28 -63
  180. package/build-module/components/font-appearance-control/index.js.map +1 -1
  181. package/build-module/components/global-styles/background-panel.js +181 -119
  182. package/build-module/components/global-styles/background-panel.js.map +1 -1
  183. package/build-module/components/global-styles/border-panel.js +3 -2
  184. package/build-module/components/global-styles/border-panel.js.map +1 -1
  185. package/build-module/components/global-styles/color-panel.js +3 -2
  186. package/build-module/components/global-styles/color-panel.js.map +1 -1
  187. package/build-module/components/global-styles/dimensions-panel.js +3 -2
  188. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  189. package/build-module/components/global-styles/filters-panel.js +3 -2
  190. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  191. package/build-module/components/global-styles/hooks.js +8 -0
  192. package/build-module/components/global-styles/hooks.js.map +1 -1
  193. package/build-module/components/global-styles/image-settings-panel.js +3 -2
  194. package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
  195. package/build-module/components/global-styles/typography-panel.js +52 -14
  196. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  197. package/build-module/components/global-styles/typography-utils.js +48 -0
  198. package/build-module/components/global-styles/typography-utils.js.map +1 -1
  199. package/build-module/components/global-styles/use-global-styles-output.js +23 -8
  200. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  201. package/build-module/components/global-styles/utils.js +15 -6
  202. package/build-module/components/global-styles/utils.js.map +1 -1
  203. package/build-module/components/grid/grid-item-movers.js +11 -14
  204. package/build-module/components/grid/grid-item-movers.js.map +1 -1
  205. package/build-module/components/grid/grid-item-resizer.js +2 -2
  206. package/build-module/components/grid/grid-item-resizer.js.map +1 -1
  207. package/build-module/components/grid/grid-visualizer.js +117 -37
  208. package/build-module/components/grid/grid-visualizer.js.map +1 -1
  209. package/build-module/components/grid/use-grid-layout-sync.js +29 -22
  210. package/build-module/components/grid/use-grid-layout-sync.js.map +1 -1
  211. package/build-module/components/inner-blocks/index.js +1 -1
  212. package/build-module/components/inner-blocks/index.js.map +1 -1
  213. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -19
  214. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
  215. package/build-module/components/inserter/menu.js +26 -4
  216. package/build-module/components/inserter/menu.js.map +1 -1
  217. package/build-module/components/inserter/quick-inserter.js +2 -1
  218. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  219. package/build-module/components/inspector-controls/block-support-tools-panel.js +3 -2
  220. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  221. package/build-module/components/link-control/link-preview.js +1 -1
  222. package/build-module/components/link-control/link-preview.js.map +1 -1
  223. package/build-module/components/media-placeholder/index.js +19 -23
  224. package/build-module/components/media-placeholder/index.js.map +1 -1
  225. package/build-module/components/navigable-toolbar/index.js +3 -1
  226. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  227. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +5 -1
  228. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  229. package/build-module/components/tabbed-sidebar/index.js +60 -0
  230. package/build-module/components/tabbed-sidebar/index.js.map +1 -0
  231. package/build-module/components/url-popover/index.js +3 -0
  232. package/build-module/components/url-popover/index.js.map +1 -1
  233. package/build-module/hooks/background.js +26 -4
  234. package/build-module/hooks/background.js.map +1 -1
  235. package/build-module/hooks/block-hooks.js +11 -17
  236. package/build-module/hooks/block-hooks.js.map +1 -1
  237. package/build-module/hooks/block-style-variation.js +168 -4
  238. package/build-module/hooks/block-style-variation.js.map +1 -1
  239. package/build-module/hooks/duotone.js +16 -11
  240. package/build-module/hooks/duotone.js.map +1 -1
  241. package/build-module/hooks/grid-visualizer.js +64 -0
  242. package/build-module/hooks/grid-visualizer.js.map +1 -0
  243. package/build-module/hooks/index.js +3 -0
  244. package/build-module/hooks/index.js.map +1 -1
  245. package/build-module/hooks/layout-child.js +39 -22
  246. package/build-module/hooks/layout-child.js.map +1 -1
  247. package/build-module/hooks/position.js +2 -9
  248. package/build-module/hooks/position.js.map +1 -1
  249. package/build-module/hooks/use-bindings-attributes.js +16 -6
  250. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  251. package/build-module/hooks/utils.js +2 -0
  252. package/build-module/hooks/utils.js.map +1 -1
  253. package/build-module/layouts/constrained.js +44 -2
  254. package/build-module/layouts/constrained.js.map +1 -1
  255. package/build-module/layouts/grid.js +90 -51
  256. package/build-module/layouts/grid.js.map +1 -1
  257. package/build-module/private-apis.js +8 -3
  258. package/build-module/private-apis.js.map +1 -1
  259. package/build-module/store/defaults.js +0 -2
  260. package/build-module/store/defaults.js.map +1 -1
  261. package/build-module/store/defaults.native.js +0 -3
  262. package/build-module/store/defaults.native.js.map +1 -1
  263. package/build-module/store/private-keys.js +1 -0
  264. package/build-module/store/private-keys.js.map +1 -1
  265. package/build-module/utils/format-font-style.js +39 -0
  266. package/build-module/utils/format-font-style.js.map +1 -0
  267. package/build-module/utils/format-font-weight.js +62 -0
  268. package/build-module/utils/format-font-weight.js.map +1 -0
  269. package/build-module/utils/get-editor-region.js +28 -0
  270. package/build-module/utils/get-editor-region.js.map +1 -0
  271. package/build-module/utils/get-font-styles-and-weights.js +160 -0
  272. package/build-module/utils/get-font-styles-and-weights.js.map +1 -0
  273. package/build-module/utils/pasting.js +5 -13
  274. package/build-module/utils/pasting.js.map +1 -1
  275. package/build-style/content-rtl.css +1 -0
  276. package/build-style/content.css +1 -0
  277. package/build-style/style-rtl.css +207 -96
  278. package/build-style/style.css +207 -96
  279. package/package.json +32 -32
  280. package/src/components/block-breadcrumb/index.js +16 -1
  281. package/src/components/block-lock/toolbar.js +0 -1
  282. package/src/components/block-mover/button.js +1 -1
  283. package/src/components/block-mover/index.js +1 -1
  284. package/src/components/block-pattern-setup/setup-toolbar.js +2 -2
  285. package/src/components/block-patterns-paging/index.js +8 -11
  286. package/src/components/block-patterns-paging/style.scss +18 -0
  287. package/src/components/block-quick-navigation/index.js +21 -28
  288. package/src/components/block-rename/modal.js +2 -8
  289. package/src/components/block-switcher/test/index.js +6 -6
  290. package/src/components/block-toolbar/shuffle.js +1 -0
  291. package/src/components/block-toolbar/style.scss +1 -11
  292. package/src/components/block-tools/block-selection-button.js +11 -83
  293. package/src/components/block-tools/block-toolbar-breadcrumb.js +9 -4
  294. package/src/components/block-tools/index.js +21 -1
  295. package/src/components/block-tools/style.scss +15 -0
  296. package/src/components/block-tools/use-show-block-tools.js +14 -6
  297. package/src/components/block-tools/zoom-out-mode-inserters.js +5 -4
  298. package/src/components/block-tools/zoom-out-popover.js +49 -0
  299. package/src/components/block-tools/zoom-out-toolbar.js +140 -0
  300. package/src/components/button-block-appender/index.js +2 -1
  301. package/src/components/child-layout-control/index.js +41 -23
  302. package/src/components/date-format-picker/index.js +10 -1
  303. package/src/components/date-format-picker/style.scss +0 -9
  304. package/src/components/dimensions-tool/index.js +97 -89
  305. package/src/components/font-appearance-control/index.js +29 -83
  306. package/src/components/font-appearance-control/style.scss +3 -5
  307. package/src/components/global-styles/background-panel.js +249 -170
  308. package/src/components/global-styles/border-panel.js +3 -2
  309. package/src/components/global-styles/color-panel.js +3 -2
  310. package/src/components/global-styles/dimensions-panel.js +3 -2
  311. package/src/components/global-styles/filters-panel.js +3 -2
  312. package/src/components/global-styles/hooks.js +9 -0
  313. package/src/components/global-styles/image-settings-panel.js +3 -2
  314. package/src/components/global-styles/style.scss +105 -20
  315. package/src/components/global-styles/test/typography-utils.js +269 -0
  316. package/src/components/global-styles/typography-panel.js +49 -12
  317. package/src/components/global-styles/typography-utils.js +63 -0
  318. package/src/components/global-styles/use-global-styles-output.js +23 -8
  319. package/src/components/global-styles/utils.js +17 -6
  320. package/src/components/grid/grid-item-movers.js +11 -27
  321. package/src/components/grid/grid-item-resizer.js +3 -2
  322. package/src/components/grid/grid-visualizer.js +171 -54
  323. package/src/components/grid/style.scss +43 -8
  324. package/src/components/grid/use-grid-layout-sync.js +31 -28
  325. package/src/components/iframe/content.scss +1 -0
  326. package/src/components/inner-blocks/index.js +2 -1
  327. package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -16
  328. package/src/components/inserter/menu.js +47 -13
  329. package/src/components/inserter/quick-inserter.js +6 -1
  330. package/src/components/inserter/style.scss +1 -49
  331. package/src/components/inspector-controls/block-support-tools-panel.js +3 -3
  332. package/src/components/link-control/link-preview.js +1 -1
  333. package/src/components/media-placeholder/index.js +22 -32
  334. package/src/components/navigable-toolbar/index.js +3 -1
  335. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +6 -1
  336. package/src/components/tabbed-sidebar/README.md +76 -0
  337. package/src/components/tabbed-sidebar/index.js +70 -0
  338. package/src/components/tabbed-sidebar/style.scss +53 -0
  339. package/src/components/url-popover/index.js +3 -0
  340. package/src/hooks/background.js +25 -10
  341. package/src/hooks/block-hooks.js +9 -16
  342. package/src/hooks/block-style-variation.js +202 -3
  343. package/src/hooks/duotone.js +16 -12
  344. package/src/hooks/grid-visualizer.js +64 -0
  345. package/src/hooks/index.js +3 -0
  346. package/src/hooks/layout-child.js +53 -37
  347. package/src/hooks/position.js +3 -10
  348. package/src/hooks/test/get-variation-styles-with-ref-values.js +91 -0
  349. package/src/hooks/use-bindings-attributes.js +18 -4
  350. package/src/hooks/utils.js +2 -0
  351. package/src/layouts/constrained.js +43 -2
  352. package/src/layouts/grid.js +146 -51
  353. package/src/private-apis.js +12 -1
  354. package/src/store/defaults.js +0 -2
  355. package/src/store/defaults.native.js +0 -3
  356. package/src/store/private-keys.js +1 -0
  357. package/src/style.scss +1 -1
  358. package/src/utils/format-font-style.js +40 -0
  359. package/src/utils/format-font-weight.js +63 -0
  360. package/src/utils/get-editor-region.js +31 -0
  361. package/src/utils/get-font-styles-and-weights.js +191 -0
  362. package/src/utils/pasting.js +5 -12
  363. package/src/utils/test/format-font-style.js +34 -0
  364. package/src/utils/test/format-font-weight.js +66 -0
  365. package/src/utils/test/get-font-styles-and-weights.js +513 -0
  366. package/tsconfig.tsbuildinfo +1 -1
  367. package/src/hooks/position.scss +0 -18
@@ -11,7 +11,7 @@ import { __, _x } from '@wordpress/i18n';
11
11
  /**
12
12
  * Internal dependencies
13
13
  */
14
- import { TOOLSPANEL_DROPDOWNMENU_PROPS } from './utils';
14
+ import { useToolsPanelDropdownMenuProps } from './utils';
15
15
 
16
16
  export function useHasImageSettingsPanel( name, value, inheritedValue ) {
17
17
  // Note: If lightbox `value` exists, that means it was
@@ -30,6 +30,7 @@ export default function ImageSettingsPanel( {
30
30
  inheritedValue,
31
31
  panelId,
32
32
  } ) {
33
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
33
34
  const resetLightbox = () => {
34
35
  onChange( undefined );
35
36
  };
@@ -52,7 +53,7 @@ export default function ImageSettingsPanel( {
52
53
  label={ _x( 'Settings', 'Image settings' ) }
53
54
  resetAll={ resetLightbox }
54
55
  panelId={ panelId }
55
- dropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }
56
+ dropdownMenuProps={ dropdownMenuProps }
56
57
  >
57
58
  <ToolsPanelItem
58
59
  // We use the `userSettings` prop instead of `settings`, because `settings`
@@ -71,20 +71,55 @@
71
71
  direction: ltr;
72
72
  }
73
73
 
74
+
74
75
  .block-editor-global-styles-background-panel__inspector-media-replace-container {
75
- position: relative;
76
+ border: 1px solid $gray-300;
77
+ border-radius: 2px;
78
+ // Full width. ToolsPanel lays out children in a grid.
79
+ grid-column: 1 / -1;
80
+
81
+ &.is-open {
82
+ background-color: $gray-100;
83
+ }
84
+
85
+ .block-editor-global-styles-background-panel__image-tools-panel-item {
86
+ flex-grow: 1;
87
+ border: 0;
88
+ .components-dropdown {
89
+ display: block;
90
+ }
91
+ }
92
+
93
+ .block-editor-global-styles-background-panel__inspector-preview-inner {
94
+ height: 100%;
95
+ }
96
+
97
+ .components-dropdown {
98
+ display: block;
99
+ height: 36px;
100
+ }
101
+ }
102
+
103
+ .block-editor-global-styles-background-panel__image-tools-panel-item {
104
+ border: 1px solid $gray-300;
105
+ border-radius: 2px;
106
+ // Full width. ToolsPanel lays out children in a grid.
107
+ grid-column: 1 / -1;
76
108
  // Since there is no option to skip rendering the drag'n'drop icon in drop
77
109
  // zone, we hide it for now.
78
110
  .components-drop-zone__content-icon {
79
111
  display: none;
80
112
  }
81
113
 
114
+ .components-dropdown {
115
+ display: block;
116
+ height: 36px;
117
+ }
118
+
82
119
  button.components-button {
83
120
  color: $gray-900;
84
- box-shadow: inset 0 0 0 $border-width $gray-400;
85
121
  width: 100%;
86
122
  display: block;
87
- height: $grid-unit-50;
88
123
 
89
124
  &:hover {
90
125
  color: var(--wp-admin-theme-color);
@@ -94,28 +129,37 @@
94
129
  box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
95
130
  }
96
131
  }
132
+ }
97
133
 
98
- .block-editor-global-styles-background-panel__inspector-media-replace-title {
99
- word-break: break-all;
100
- // The Button component is white-space: nowrap, and that won't work with line-clamp.
101
- white-space: normal;
134
+ .block-editor-global-styles-background-panel__image-preview-content,
135
+ .block-editor-global-styles-background-panel__dropdown-toggle {
136
+ height: 100%;
137
+ width: 100%;
138
+ padding-left: $grid-unit-15;
139
+ }
102
140
 
103
- // Without this, the ellipsis can sometimes be partially hidden by the Button padding.
104
- text-align: start;
105
- text-align-last: center;
106
- }
141
+ .block-editor-global-styles-background-panel__dropdown-toggle {
142
+ cursor: pointer;
143
+ background: transparent;
144
+ border: none;
145
+ }
107
146
 
108
- .components-dropdown {
109
- display: block;
110
- }
147
+ .block-editor-global-styles-background-panel__inspector-media-replace-title {
148
+ word-break: break-all;
149
+ // The Button component is white-space: nowrap, and that won't work with line-clamp.
150
+ white-space: normal;
151
+
152
+ // Without this, the ellipsis can sometimes be partially hidden by the Button padding.
153
+ text-align: start;
154
+ text-align-last: center;
111
155
  }
112
156
 
113
- .block-editor-global-styles-background-panel__inspector-image-indicator-wrapper {
114
- display: block;
115
- width: 20px;
116
- height: 20px;
117
- flex: none;
118
- background: #fff;
157
+ .block-editor-global-styles-background-panel__inspector-preview-inner {
158
+ .block-editor-global-styles-background-panel__inspector-image-indicator-wrapper {
159
+ width: 20px;
160
+ height: 20px;
161
+ min-width: auto;
162
+ }
119
163
  }
120
164
 
121
165
  .block-editor-global-styles-background-panel__inspector-image-indicator {
@@ -141,3 +185,44 @@
141
185
  box-sizing: inherit;
142
186
  }
143
187
 
188
+ .block-editor-global-styles-background-panel__dropdown-content-wrapper {
189
+ min-width: 260px;
190
+ overflow-x: hidden;
191
+ .components-base-control__help,
192
+ .components-toggle-control {
193
+ margin-bottom: 0;
194
+ }
195
+ .components-focal-point-picker-wrapper {
196
+ background-color: $gray-100;
197
+ width: 100%;
198
+ border-radius: $radius-block-ui;
199
+ border: $border-width solid $gray-300;
200
+ }
201
+ .components-focal-point-picker__media--image {
202
+ max-height: 180px;
203
+ }
204
+ }
205
+
206
+ .block-editor-global-styles-background-panel__hidden-tools-panel-item {
207
+ height: 0;
208
+ width: 0;
209
+ position: absolute;
210
+ }
211
+
212
+ // Push control panel into the background when the media modal is open.
213
+ .modal-open .block-editor-global-styles-background-panel__popover {
214
+ z-index: z-index(".block-editor-global-styles-background-panel__popover");
215
+ }
216
+
217
+ .block-editor-global-styles-background-panel__media-replace-popover {
218
+ .components-popover__content {
219
+ // width of block-editor-global-styles-background-panel__dropdown-content-wrapper minus padding.
220
+ width: 226px;
221
+ }
222
+ .components-button {
223
+ padding: 0 $grid-unit-10;
224
+ }
225
+ .components-button .components-menu-items__item-icon.has-icon-right {
226
+ margin-left: $grid-unit-30 - $grid-unit-10;
227
+ }
228
+ }
@@ -4,6 +4,8 @@
4
4
  import {
5
5
  getTypographyFontSizeValue,
6
6
  getFluidTypographyOptionsFromSettings,
7
+ getMergedFontFamiliesAndFontFamilyFaces,
8
+ findNearestFontWeight,
7
9
  } from '../typography-utils';
8
10
 
9
11
  describe( 'typography utils', () => {
@@ -682,6 +684,273 @@ describe( 'typography utils', () => {
682
684
  } );
683
685
  } );
684
686
 
687
+ describe( 'getMergedFontFamiliesAndFontFamilyFaces', () => {
688
+ [
689
+ {
690
+ message:
691
+ 'should return empty arrays when settings and fontFamily are empty',
692
+ settings: {},
693
+ fontFamily: '',
694
+ expected: {
695
+ fontFamilies: [],
696
+ fontFamilyFaces: [],
697
+ },
698
+ },
699
+
700
+ {
701
+ message:
702
+ 'should return empty arrays when only settings is `undefined`',
703
+ settings: undefined,
704
+ fontFamily: 'ABeeZee, sans-serif',
705
+ expected: {
706
+ fontFamilies: [],
707
+ fontFamilyFaces: [],
708
+ },
709
+ },
710
+
711
+ {
712
+ message:
713
+ 'should return fontFamilies array and an empty fontFamilyFaces array when fontfamily is empty',
714
+ settings: {
715
+ typography: {
716
+ fontFamilies: {
717
+ custom: [
718
+ {
719
+ name: 'ABeeZee',
720
+ slug: 'abeezee',
721
+ fontFamily: 'ABeeZee, sans-serif',
722
+ fontFace: [
723
+ {
724
+ src: 'http://www.wordpress.org/wp-content/uploads/fonts/esDT31xSG-6AGleN2tCkkJUCGpG-GQ.woff2',
725
+ fontWeight: '400',
726
+ fontStyle: 'italic',
727
+ fontFamily: 'ABeeZee',
728
+ },
729
+ ],
730
+ },
731
+ ],
732
+ },
733
+ },
734
+ },
735
+ fontFamily: '',
736
+ expected: {
737
+ fontFamilies: [
738
+ {
739
+ fontFace: [
740
+ {
741
+ fontFamily: 'ABeeZee',
742
+ fontStyle: 'italic',
743
+ fontWeight: '400',
744
+ src: 'http://www.wordpress.org/wp-content/uploads/fonts/esDT31xSG-6AGleN2tCkkJUCGpG-GQ.woff2',
745
+ },
746
+ ],
747
+ fontFamily: 'ABeeZee, sans-serif',
748
+ name: 'ABeeZee',
749
+ slug: 'abeezee',
750
+ },
751
+ ],
752
+ fontFamilyFaces: [],
753
+ },
754
+ },
755
+
756
+ {
757
+ message:
758
+ 'should return font families and font faces when both settings and fontFamily are defined',
759
+ settings: {
760
+ typography: {
761
+ fontFamilies: {
762
+ theme: [
763
+ {
764
+ fontFace: [
765
+ {
766
+ fontFamily: 'PT Sans',
767
+ fontStyle: 'normal',
768
+ fontWeight: '400',
769
+ src: [
770
+ 'file:./assets/fonts/pt-sans_normal_400.ttf',
771
+ ],
772
+ },
773
+ {
774
+ fontFamily: 'PT Sans',
775
+ fontStyle: 'normal',
776
+ fontWeight: '700',
777
+ src: [
778
+ 'file:./assets/fonts/pt-sans_normal_700.ttf',
779
+ ],
780
+ },
781
+ {
782
+ fontFamily: 'PT Sans',
783
+ fontStyle: 'italic',
784
+ fontWeight: '400',
785
+ src: [
786
+ 'file:./assets/fonts/pt-sans_italic_400.ttf',
787
+ ],
788
+ },
789
+ {
790
+ fontFamily: 'PT Sans',
791
+ fontStyle: 'italic',
792
+ fontWeight: '700',
793
+ src: [
794
+ 'file:./assets/fonts/pt-sans_italic_700.ttf',
795
+ ],
796
+ },
797
+ ],
798
+ fontFamily: 'PT Sans',
799
+ name: 'PT Sans',
800
+ slug: 'pt-sans',
801
+ },
802
+ ],
803
+ custom: [
804
+ {
805
+ name: 'ABeeZee',
806
+ slug: 'abeezee',
807
+ fontFamily: 'ABeeZee, sans-serif',
808
+ fontFace: [
809
+ {
810
+ src: 'http://www.wordpress.org/wp-content/uploads/fonts/esDT31xSG-6AGleN2tCkkJUCGpG-GQ.woff2',
811
+ fontWeight: '400',
812
+ fontStyle: 'italic',
813
+ fontFamily: 'ABeeZee',
814
+ },
815
+ ],
816
+ },
817
+ ],
818
+ },
819
+ },
820
+ },
821
+ fontFamily: 'ABeeZee, sans-serif',
822
+ expected: {
823
+ fontFamilyFaces: [
824
+ {
825
+ fontFamily: 'ABeeZee',
826
+ fontStyle: 'italic',
827
+ fontWeight: '400',
828
+ src: 'http://www.wordpress.org/wp-content/uploads/fonts/esDT31xSG-6AGleN2tCkkJUCGpG-GQ.woff2',
829
+ },
830
+ ],
831
+ fontFamilies: [
832
+ {
833
+ fontFace: [
834
+ {
835
+ fontFamily: 'PT Sans',
836
+ fontStyle: 'normal',
837
+ fontWeight: '400',
838
+ src: [
839
+ 'file:./assets/fonts/pt-sans_normal_400.ttf',
840
+ ],
841
+ },
842
+ {
843
+ fontFamily: 'PT Sans',
844
+ fontStyle: 'normal',
845
+ fontWeight: '700',
846
+ src: [
847
+ 'file:./assets/fonts/pt-sans_normal_700.ttf',
848
+ ],
849
+ },
850
+ {
851
+ fontFamily: 'PT Sans',
852
+ fontStyle: 'italic',
853
+ fontWeight: '400',
854
+ src: [
855
+ 'file:./assets/fonts/pt-sans_italic_400.ttf',
856
+ ],
857
+ },
858
+ {
859
+ fontFamily: 'PT Sans',
860
+ fontStyle: 'italic',
861
+ fontWeight: '700',
862
+ src: [
863
+ 'file:./assets/fonts/pt-sans_italic_700.ttf',
864
+ ],
865
+ },
866
+ ],
867
+ fontFamily: 'PT Sans',
868
+ name: 'PT Sans',
869
+ slug: 'pt-sans',
870
+ },
871
+ {
872
+ fontFace: [
873
+ {
874
+ fontFamily: 'ABeeZee',
875
+ fontStyle: 'italic',
876
+ fontWeight: '400',
877
+ src: 'http://www.wordpress.org/wp-content/uploads/fonts/esDT31xSG-6AGleN2tCkkJUCGpG-GQ.woff2',
878
+ },
879
+ ],
880
+ fontFamily: 'ABeeZee, sans-serif',
881
+ name: 'ABeeZee',
882
+ slug: 'abeezee',
883
+ },
884
+ ],
885
+ },
886
+ },
887
+ ].forEach( ( { message, settings, fontFamily, expected } ) => {
888
+ it( `${ message }`, () => {
889
+ expect(
890
+ getMergedFontFamiliesAndFontFamilyFaces(
891
+ settings,
892
+ fontFamily
893
+ )
894
+ ).toEqual( expected );
895
+ } );
896
+ } );
897
+ } );
898
+
899
+ describe( 'findNearestFontWeight', () => {
900
+ [
901
+ {
902
+ message:
903
+ 'should return empty string when newFontWeightValue is `undefined`',
904
+ availableFontWeights: undefined,
905
+ newFontWeightValue: undefined,
906
+ expected: '',
907
+ },
908
+ {
909
+ message:
910
+ 'should return newFontWeightValue value when availableFontWeights is empty',
911
+ availableFontWeights: [],
912
+ newFontWeightValue: '300',
913
+ expected: '300',
914
+ },
915
+ {
916
+ message: 'should return correct nearest higher font weight',
917
+ availableFontWeights: [
918
+ { name: 'Regular', value: '400' },
919
+ { name: 'Bold', value: '700' },
920
+ { name: 'Black', value: '900' },
921
+ ],
922
+ newFontWeightValue: '300',
923
+ expected: '400',
924
+ },
925
+ {
926
+ message: 'should return correct nearest lower font weight',
927
+ availableFontWeights: [
928
+ { name: 'Thin', value: '100' },
929
+ { name: 'Light', value: '300' },
930
+ { name: 'Regular', value: '400' },
931
+ ],
932
+ newFontWeightValue: '900',
933
+ expected: '400',
934
+ },
935
+ ].forEach(
936
+ ( {
937
+ message,
938
+ availableFontWeights,
939
+ newFontWeightValue,
940
+ expected,
941
+ } ) => {
942
+ it( `${ message }`, () => {
943
+ expect(
944
+ findNearestFontWeight(
945
+ availableFontWeights,
946
+ newFontWeightValue
947
+ )
948
+ ).toEqual( expected );
949
+ } );
950
+ }
951
+ );
952
+ } );
953
+
685
954
  describe( 'typography utils', () => {
686
955
  [
687
956
  {
@@ -8,7 +8,7 @@ import {
8
8
  __experimentalToolsPanelItem as ToolsPanelItem,
9
9
  } from '@wordpress/components';
10
10
  import { __ } from '@wordpress/i18n';
11
- import { useCallback, useMemo } from '@wordpress/element';
11
+ import { useCallback, useMemo, useEffect } from '@wordpress/element';
12
12
 
13
13
  /**
14
14
  * Internal dependencies
@@ -21,8 +21,13 @@ import TextAlignmentControl from '../text-alignment-control';
21
21
  import TextTransformControl from '../text-transform-control';
22
22
  import TextDecorationControl from '../text-decoration-control';
23
23
  import WritingModeControl from '../writing-mode-control';
24
- import { getValueFromVariable, TOOLSPANEL_DROPDOWNMENU_PROPS } from './utils';
24
+ import { getValueFromVariable, useToolsPanelDropdownMenuProps } from './utils';
25
25
  import { setImmutably } from '../../utils/object';
26
+ import {
27
+ getMergedFontFamiliesAndFontFamilyFaces,
28
+ findNearestFontWeight,
29
+ } from './typography-utils';
30
+ import { getFontStylesAndWeights } from '../../utils/get-font-styles-and-weights';
26
31
 
27
32
  const MIN_TEXT_COLUMNS = 1;
28
33
  const MAX_TEXT_COLUMNS = 6;
@@ -135,6 +140,7 @@ function TypographyToolsPanel( {
135
140
  panelId,
136
141
  children,
137
142
  } ) {
143
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
138
144
  const resetAll = () => {
139
145
  const updatedValue = resetAllFilter( value );
140
146
  onChange( updatedValue );
@@ -145,7 +151,7 @@ function TypographyToolsPanel( {
145
151
  label={ __( 'Typography' ) }
146
152
  resetAll={ resetAll }
147
153
  panelId={ panelId }
148
- dropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }
154
+ dropdownMenuProps={ dropdownMenuProps }
149
155
  >
150
156
  { children }
151
157
  </ToolsPanel>
@@ -179,15 +185,13 @@ export default function TypographyPanel( {
179
185
 
180
186
  // Font Family
181
187
  const hasFontFamilyEnabled = useHasFontFamilyControl( settings );
182
- const fontFamilies = settings?.typography?.fontFamilies;
183
- const mergedFontFamilies = useMemo( () => {
184
- return [ 'default', 'theme', 'custom' ].flatMap(
185
- ( key ) => fontFamilies?.[ key ] ?? []
186
- );
187
- }, [ fontFamilies ] );
188
188
  const fontFamily = decodeValue( inheritedValue?.typography?.fontFamily );
189
+ const { fontFamilies, fontFamilyFaces } = useMemo( () => {
190
+ return getMergedFontFamiliesAndFontFamilyFaces( settings, fontFamily );
191
+ }, [ settings, fontFamily ] );
192
+
189
193
  const setFontFamily = ( newValue ) => {
190
- const slug = mergedFontFamilies?.find(
194
+ const slug = fontFamilies?.find(
191
195
  ( { fontFamily: f } ) => f === newValue
192
196
  )?.slug;
193
197
  onChange(
@@ -251,6 +255,39 @@ export default function TypographyPanel( {
251
255
  setFontAppearance( {} );
252
256
  };
253
257
 
258
+ // Check if previous font style and weight values are available in the new font family
259
+ useEffect( () => {
260
+ const { fontStyles, fontWeights, isSystemFont } =
261
+ getFontStylesAndWeights( fontFamilyFaces );
262
+ const hasFontStyle = fontStyles?.some(
263
+ ( { value: fs } ) => fs === fontStyle
264
+ );
265
+ const hasFontWeight = fontWeights?.some(
266
+ ( { value: fw } ) => fw === fontWeight
267
+ );
268
+
269
+ // Try to set nearest available font weight
270
+ if ( ! hasFontWeight && fontWeight ) {
271
+ setFontAppearance( {
272
+ fontStyle,
273
+ fontWeight: findNearestFontWeight( fontWeights, fontWeight ),
274
+ } );
275
+ }
276
+
277
+ // Set the same weight and style values if the font family is a system font or if both are the same
278
+ if ( isSystemFont || ( hasFontStyle && hasFontWeight ) ) {
279
+ setFontAppearance( {
280
+ fontStyle,
281
+ fontWeight,
282
+ } );
283
+ }
284
+
285
+ // Reset font appearance if the font family does not have the selected font style
286
+ if ( ! hasFontStyle ) {
287
+ resetFontAppearance();
288
+ }
289
+ }, [ fontFamily ] );
290
+
254
291
  // Line Height
255
292
  const hasLineHeightEnabled = useHasLineHeightControl( settings );
256
293
  const lineHeight = decodeValue( inheritedValue?.typography?.lineHeight );
@@ -386,7 +423,7 @@ export default function TypographyPanel( {
386
423
  panelId={ panelId }
387
424
  >
388
425
  <FontFamilyControl
389
- fontFamilies={ mergedFontFamilies }
426
+ fontFamilies={ fontFamilies }
390
427
  value={ fontFamily }
391
428
  onChange={ setFontFamily }
392
429
  size="__unstable-large"
@@ -430,8 +467,8 @@ export default function TypographyPanel( {
430
467
  onChange={ setFontAppearance }
431
468
  hasFontStyles={ hasFontStyles }
432
469
  hasFontWeights={ hasFontWeights }
470
+ fontFamilyFaces={ fontFamilyFaces }
433
471
  size="__unstable-large"
434
- __nextHasNoMarginBottom
435
472
  />
436
473
  </ToolsPanelItem>
437
474
  ) }
@@ -122,3 +122,66 @@ export function getFluidTypographyOptionsFromSettings( settings ) {
122
122
  fluid: typographySettings?.fluid,
123
123
  };
124
124
  }
125
+
126
+ /**
127
+ * Returns an object of merged font families and the font faces from the selected font family
128
+ * based on the theme.json settings object and the currently selected font family.
129
+ *
130
+ * @param {Object} settings Theme.json settings
131
+ * @param {string} selectedFontFamily Decoded font family string
132
+ * @return {Object} Merged font families and font faces from the selected font family
133
+ */
134
+ export function getMergedFontFamiliesAndFontFamilyFaces(
135
+ settings,
136
+ selectedFontFamily
137
+ ) {
138
+ const fontFamiliesFromSettings = settings?.typography?.fontFamilies;
139
+
140
+ const fontFamilies = [ 'default', 'theme', 'custom' ].flatMap(
141
+ ( key ) => fontFamiliesFromSettings?.[ key ] ?? []
142
+ );
143
+
144
+ const fontFamilyFaces =
145
+ fontFamilies.find(
146
+ ( family ) => family.fontFamily === selectedFontFamily
147
+ )?.fontFace ?? [];
148
+
149
+ return { fontFamilies, fontFamilyFaces };
150
+ }
151
+
152
+ /**
153
+ * Returns the nearest font weight value from the available font weight list based on the new font weight.
154
+ * The nearest font weight is the one with the smallest difference from the new font weight.
155
+ *
156
+ * @param {Array} availableFontWeights Array of available font weights
157
+ * @param {string} newFontWeightValue New font weight value
158
+ * @return {string} Nearest font weight
159
+ */
160
+
161
+ export function findNearestFontWeight(
162
+ availableFontWeights,
163
+ newFontWeightValue
164
+ ) {
165
+ if ( ! newFontWeightValue || typeof newFontWeightValue !== 'string' ) {
166
+ return '';
167
+ }
168
+
169
+ if ( ! availableFontWeights || availableFontWeights.length === 0 ) {
170
+ return newFontWeightValue;
171
+ }
172
+
173
+ const nearestFontWeight = availableFontWeights?.reduce(
174
+ ( nearest, { value: fw } ) => {
175
+ const currentDiff = Math.abs(
176
+ parseInt( fw ) - parseInt( newFontWeightValue )
177
+ );
178
+ const nearestDiff = Math.abs(
179
+ parseInt( nearest ) - parseInt( newFontWeightValue )
180
+ );
181
+ return currentDiff < nearestDiff ? fw : nearest;
182
+ },
183
+ availableFontWeights[ 0 ]?.value
184
+ );
185
+
186
+ return nearestFontWeight;
187
+ }