@wordpress/block-editor 13.1.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 (437) hide show
  1. package/CHANGELOG.md +21 -17
  2. package/README.md +1 -2
  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/modal.js +67 -67
  6. package/build/components/block-lock/modal.js.map +1 -1
  7. package/build/components/block-lock/toolbar.js +0 -1
  8. package/build/components/block-lock/toolbar.js.map +1 -1
  9. package/build/components/block-mover/button.js +1 -1
  10. package/build/components/block-mover/button.js.map +1 -1
  11. package/build/components/block-mover/index.js +12 -6
  12. package/build/components/block-mover/index.js.map +1 -1
  13. package/build/components/block-pattern-setup/setup-toolbar.js +2 -2
  14. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  15. package/build/components/block-patterns-paging/index.js +5 -7
  16. package/build/components/block-patterns-paging/index.js.map +1 -1
  17. package/build/components/block-quick-navigation/index.js +20 -17
  18. package/build/components/block-quick-navigation/index.js.map +1 -1
  19. package/build/components/block-rename/modal.js +4 -12
  20. package/build/components/block-rename/modal.js.map +1 -1
  21. package/build/components/block-toolbar/shuffle.js +4 -1
  22. package/build/components/block-toolbar/shuffle.js.map +1 -1
  23. package/build/components/block-tools/block-selection-button.js +7 -58
  24. package/build/components/block-tools/block-selection-button.js.map +1 -1
  25. package/build/components/block-tools/block-toolbar-breadcrumb.js +9 -2
  26. package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
  27. package/build/components/block-tools/index.js +14 -1
  28. package/build/components/block-tools/index.js.map +1 -1
  29. package/build/components/block-tools/use-show-block-tools.js +4 -2
  30. package/build/components/block-tools/use-show-block-tools.js.map +1 -1
  31. package/build/components/block-tools/zoom-out-mode-inserters.js +5 -4
  32. package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  33. package/build/components/block-tools/zoom-out-popover.js +57 -0
  34. package/build/components/block-tools/zoom-out-popover.js.map +1 -0
  35. package/build/components/block-tools/zoom-out-toolbar.js +138 -0
  36. package/build/components/block-tools/zoom-out-toolbar.js.map +1 -0
  37. package/build/components/button-block-appender/index.js +3 -1
  38. package/build/components/button-block-appender/index.js.map +1 -1
  39. package/build/components/child-layout-control/index.js +193 -127
  40. package/build/components/child-layout-control/index.js.map +1 -1
  41. package/build/components/date-format-picker/index.js +10 -1
  42. package/build/components/date-format-picker/index.js.map +1 -1
  43. package/build/components/dimensions-tool/index.js +6 -4
  44. package/build/components/dimensions-tool/index.js.map +1 -1
  45. package/build/components/font-appearance-control/index.js +26 -61
  46. package/build/components/font-appearance-control/index.js.map +1 -1
  47. package/build/components/global-styles/background-panel.js +178 -116
  48. package/build/components/global-styles/background-panel.js.map +1 -1
  49. package/build/components/global-styles/border-panel.js +2 -1
  50. package/build/components/global-styles/border-panel.js.map +1 -1
  51. package/build/components/global-styles/color-panel.js +2 -1
  52. package/build/components/global-styles/color-panel.js.map +1 -1
  53. package/build/components/global-styles/dimensions-panel.js +2 -1
  54. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  55. package/build/components/global-styles/filters-panel.js +2 -1
  56. package/build/components/global-styles/filters-panel.js.map +1 -1
  57. package/build/components/global-styles/hooks.js +8 -0
  58. package/build/components/global-styles/hooks.js.map +1 -1
  59. package/build/components/global-styles/image-settings-panel.js +2 -1
  60. package/build/components/global-styles/image-settings-panel.js.map +1 -1
  61. package/build/components/global-styles/typography-panel.js +50 -12
  62. package/build/components/global-styles/typography-panel.js.map +1 -1
  63. package/build/components/global-styles/typography-utils.js +50 -0
  64. package/build/components/global-styles/typography-utils.js.map +1 -1
  65. package/build/components/global-styles/use-global-styles-output.js +25 -9
  66. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  67. package/build/components/global-styles/utils.js +17 -7
  68. package/build/components/global-styles/utils.js.map +1 -1
  69. package/build/components/grid/grid-item-movers.js +94 -0
  70. package/build/components/grid/grid-item-movers.js.map +1 -0
  71. package/build/components/{grid-visualizer → grid}/grid-item-resizer.js +18 -56
  72. package/build/components/grid/grid-item-resizer.js.map +1 -0
  73. package/build/components/grid/grid-visualizer.js +305 -0
  74. package/build/components/grid/grid-visualizer.js.map +1 -0
  75. package/build/components/{grid-visualizer → grid}/index.js +14 -0
  76. package/build/components/grid/index.js.map +1 -0
  77. package/build/components/grid/use-get-number-of-blocks-before-cell.js +40 -0
  78. package/build/components/grid/use-get-number-of-blocks-before-cell.js.map +1 -0
  79. package/build/components/grid/use-grid-layout-sync.js +169 -0
  80. package/build/components/grid/use-grid-layout-sync.js.map +1 -0
  81. package/build/components/grid/utils.js +145 -0
  82. package/build/components/grid/utils.js.map +1 -0
  83. package/build/components/image-editor/aspect-ratio-dropdown.js +0 -1
  84. package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  85. package/build/components/inner-blocks/index.js +1 -1
  86. package/build/components/inner-blocks/index.js.map +1 -1
  87. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -19
  88. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
  89. package/build/components/inserter/menu.js +26 -4
  90. package/build/components/inserter/menu.js.map +1 -1
  91. package/build/components/inserter/quick-inserter.js +2 -1
  92. package/build/components/inserter/quick-inserter.js.map +1 -1
  93. package/build/components/inspector-controls/block-support-tools-panel.js +2 -1
  94. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  95. package/build/components/link-control/link-preview.js +1 -1
  96. package/build/components/link-control/link-preview.js.map +1 -1
  97. package/build/components/media-placeholder/index.js +19 -23
  98. package/build/components/media-placeholder/index.js.map +1 -1
  99. package/build/components/navigable-toolbar/index.js +3 -1
  100. package/build/components/navigable-toolbar/index.js.map +1 -1
  101. package/build/components/rich-text/event-listeners/input-rules.js +1 -0
  102. package/build/components/rich-text/event-listeners/input-rules.js.map +1 -1
  103. package/build/components/rich-text/index.native.js +10 -4
  104. package/build/components/rich-text/index.native.js.map +1 -1
  105. package/build/components/rich-text/native/index.native.js +14 -0
  106. package/build/components/rich-text/native/index.native.js.map +1 -1
  107. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +5 -1
  108. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  109. package/build/components/tabbed-sidebar/index.js +66 -0
  110. package/build/components/tabbed-sidebar/index.js.map +1 -0
  111. package/build/components/url-popover/index.js +3 -0
  112. package/build/components/url-popover/index.js.map +1 -1
  113. package/build/hooks/background.js +26 -4
  114. package/build/hooks/background.js.map +1 -1
  115. package/build/hooks/block-hooks.js +11 -17
  116. package/build/hooks/block-hooks.js.map +1 -1
  117. package/build/hooks/block-style-variation.js +195 -11
  118. package/build/hooks/block-style-variation.js.map +1 -1
  119. package/build/hooks/duotone.js +16 -11
  120. package/build/hooks/duotone.js.map +1 -1
  121. package/build/hooks/grid-visualizer.js +65 -0
  122. package/build/hooks/grid-visualizer.js.map +1 -0
  123. package/build/hooks/index.js +15 -2
  124. package/build/hooks/index.js.map +1 -1
  125. package/build/hooks/layout-child.js +65 -40
  126. package/build/hooks/layout-child.js.map +1 -1
  127. package/build/hooks/position.js +2 -9
  128. package/build/hooks/position.js.map +1 -1
  129. package/build/hooks/use-bindings-attributes.js +16 -6
  130. package/build/hooks/use-bindings-attributes.js.map +1 -1
  131. package/build/hooks/utils.js +5 -2
  132. package/build/hooks/utils.js.map +1 -1
  133. package/build/layouts/constrained.js +44 -2
  134. package/build/layouts/constrained.js.map +1 -1
  135. package/build/layouts/grid.js +92 -76
  136. package/build/layouts/grid.js.map +1 -1
  137. package/build/lock-unlock.js +1 -1
  138. package/build/lock-unlock.js.map +1 -1
  139. package/build/private-apis.js +6 -1
  140. package/build/private-apis.js.map +1 -1
  141. package/build/store/actions.js +17 -1
  142. package/build/store/actions.js.map +1 -1
  143. package/build/store/defaults.js +0 -2
  144. package/build/store/defaults.js.map +1 -1
  145. package/build/store/defaults.native.js +0 -3
  146. package/build/store/defaults.native.js.map +1 -1
  147. package/build/store/private-keys.js +2 -1
  148. package/build/store/private-keys.js.map +1 -1
  149. package/build/utils/format-font-style.js +45 -0
  150. package/build/utils/format-font-style.js.map +1 -0
  151. package/build/utils/format-font-weight.js +68 -0
  152. package/build/utils/format-font-weight.js.map +1 -0
  153. package/build/utils/get-editor-region.js +34 -0
  154. package/build/utils/get-editor-region.js.map +1 -0
  155. package/build/utils/get-font-styles-and-weights.js +167 -0
  156. package/build/utils/get-font-styles-and-weights.js.map +1 -0
  157. package/build/utils/pasting.js +5 -13
  158. package/build/utils/pasting.js.map +1 -1
  159. package/build-module/components/block-breadcrumb/index.js +12 -1
  160. package/build-module/components/block-breadcrumb/index.js.map +1 -1
  161. package/build-module/components/block-lock/modal.js +67 -67
  162. package/build-module/components/block-lock/modal.js.map +1 -1
  163. package/build-module/components/block-lock/toolbar.js +0 -1
  164. package/build-module/components/block-lock/toolbar.js.map +1 -1
  165. package/build-module/components/block-mover/button.js +1 -1
  166. package/build-module/components/block-mover/button.js.map +1 -1
  167. package/build-module/components/block-mover/index.js +12 -6
  168. package/build-module/components/block-mover/index.js.map +1 -1
  169. package/build-module/components/block-pattern-setup/setup-toolbar.js +2 -2
  170. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  171. package/build-module/components/block-patterns-paging/index.js +5 -7
  172. package/build-module/components/block-patterns-paging/index.js.map +1 -1
  173. package/build-module/components/block-quick-navigation/index.js +20 -17
  174. package/build-module/components/block-quick-navigation/index.js.map +1 -1
  175. package/build-module/components/block-rename/modal.js +5 -13
  176. package/build-module/components/block-rename/modal.js.map +1 -1
  177. package/build-module/components/block-toolbar/shuffle.js +4 -1
  178. package/build-module/components/block-toolbar/shuffle.js.map +1 -1
  179. package/build-module/components/block-tools/block-selection-button.js +10 -61
  180. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  181. package/build-module/components/block-tools/block-toolbar-breadcrumb.js +9 -2
  182. package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
  183. package/build-module/components/block-tools/index.js +14 -1
  184. package/build-module/components/block-tools/index.js.map +1 -1
  185. package/build-module/components/block-tools/use-show-block-tools.js +4 -2
  186. package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
  187. package/build-module/components/block-tools/zoom-out-mode-inserters.js +5 -4
  188. package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  189. package/build-module/components/block-tools/zoom-out-popover.js +48 -0
  190. package/build-module/components/block-tools/zoom-out-popover.js.map +1 -0
  191. package/build-module/components/block-tools/zoom-out-toolbar.js +131 -0
  192. package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -0
  193. package/build-module/components/button-block-appender/index.js +3 -1
  194. package/build-module/components/button-block-appender/index.js.map +1 -1
  195. package/build-module/components/child-layout-control/index.js +194 -128
  196. package/build-module/components/child-layout-control/index.js.map +1 -1
  197. package/build-module/components/date-format-picker/index.js +11 -3
  198. package/build-module/components/date-format-picker/index.js.map +1 -1
  199. package/build-module/components/dimensions-tool/index.js +6 -4
  200. package/build-module/components/dimensions-tool/index.js.map +1 -1
  201. package/build-module/components/font-appearance-control/index.js +28 -63
  202. package/build-module/components/font-appearance-control/index.js.map +1 -1
  203. package/build-module/components/global-styles/background-panel.js +181 -119
  204. package/build-module/components/global-styles/background-panel.js.map +1 -1
  205. package/build-module/components/global-styles/border-panel.js +3 -2
  206. package/build-module/components/global-styles/border-panel.js.map +1 -1
  207. package/build-module/components/global-styles/color-panel.js +3 -2
  208. package/build-module/components/global-styles/color-panel.js.map +1 -1
  209. package/build-module/components/global-styles/dimensions-panel.js +3 -2
  210. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  211. package/build-module/components/global-styles/filters-panel.js +3 -2
  212. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  213. package/build-module/components/global-styles/hooks.js +8 -0
  214. package/build-module/components/global-styles/hooks.js.map +1 -1
  215. package/build-module/components/global-styles/image-settings-panel.js +3 -2
  216. package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
  217. package/build-module/components/global-styles/typography-panel.js +52 -14
  218. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  219. package/build-module/components/global-styles/typography-utils.js +48 -0
  220. package/build-module/components/global-styles/typography-utils.js.map +1 -1
  221. package/build-module/components/global-styles/use-global-styles-output.js +25 -9
  222. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  223. package/build-module/components/global-styles/utils.js +15 -6
  224. package/build-module/components/global-styles/utils.js.map +1 -1
  225. package/build-module/components/grid/grid-item-movers.js +87 -0
  226. package/build-module/components/grid/grid-item-movers.js.map +1 -0
  227. package/build-module/components/{grid-visualizer → grid}/grid-item-resizer.js +13 -51
  228. package/build-module/components/grid/grid-item-resizer.js.map +1 -0
  229. package/build-module/components/grid/grid-visualizer.js +297 -0
  230. package/build-module/components/grid/grid-visualizer.js.map +1 -0
  231. package/build-module/components/grid/index.js +5 -0
  232. package/build-module/components/grid/index.js.map +1 -0
  233. package/build-module/components/grid/use-get-number-of-blocks-before-cell.js +33 -0
  234. package/build-module/components/grid/use-get-number-of-blocks-before-cell.js.map +1 -0
  235. package/build-module/components/grid/use-grid-layout-sync.js +162 -0
  236. package/build-module/components/grid/use-grid-layout-sync.js.map +1 -0
  237. package/build-module/components/grid/utils.js +131 -0
  238. package/build-module/components/grid/utils.js.map +1 -0
  239. package/build-module/components/image-editor/aspect-ratio-dropdown.js +0 -1
  240. package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  241. package/build-module/components/inner-blocks/index.js +1 -1
  242. package/build-module/components/inner-blocks/index.js.map +1 -1
  243. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -19
  244. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
  245. package/build-module/components/inserter/menu.js +26 -4
  246. package/build-module/components/inserter/menu.js.map +1 -1
  247. package/build-module/components/inserter/quick-inserter.js +2 -1
  248. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  249. package/build-module/components/inspector-controls/block-support-tools-panel.js +3 -2
  250. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  251. package/build-module/components/link-control/link-preview.js +1 -1
  252. package/build-module/components/link-control/link-preview.js.map +1 -1
  253. package/build-module/components/media-placeholder/index.js +19 -23
  254. package/build-module/components/media-placeholder/index.js.map +1 -1
  255. package/build-module/components/navigable-toolbar/index.js +3 -1
  256. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  257. package/build-module/components/rich-text/event-listeners/input-rules.js +1 -1
  258. package/build-module/components/rich-text/event-listeners/input-rules.js.map +1 -1
  259. package/build-module/components/rich-text/index.native.js +11 -5
  260. package/build-module/components/rich-text/index.native.js.map +1 -1
  261. package/build-module/components/rich-text/native/index.native.js +14 -0
  262. package/build-module/components/rich-text/native/index.native.js.map +1 -1
  263. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +5 -1
  264. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  265. package/build-module/components/tabbed-sidebar/index.js +60 -0
  266. package/build-module/components/tabbed-sidebar/index.js.map +1 -0
  267. package/build-module/components/url-popover/index.js +3 -0
  268. package/build-module/components/url-popover/index.js.map +1 -1
  269. package/build-module/hooks/background.js +26 -4
  270. package/build-module/hooks/background.js.map +1 -1
  271. package/build-module/hooks/block-hooks.js +11 -17
  272. package/build-module/hooks/block-hooks.js.map +1 -1
  273. package/build-module/hooks/block-style-variation.js +193 -11
  274. package/build-module/hooks/block-style-variation.js.map +1 -1
  275. package/build-module/hooks/duotone.js +16 -11
  276. package/build-module/hooks/duotone.js.map +1 -1
  277. package/build-module/hooks/grid-visualizer.js +64 -0
  278. package/build-module/hooks/grid-visualizer.js.map +1 -0
  279. package/build-module/hooks/index.js +3 -0
  280. package/build-module/hooks/index.js.map +1 -1
  281. package/build-module/hooks/layout-child.js +63 -38
  282. package/build-module/hooks/layout-child.js.map +1 -1
  283. package/build-module/hooks/position.js +2 -9
  284. package/build-module/hooks/position.js.map +1 -1
  285. package/build-module/hooks/use-bindings-attributes.js +16 -6
  286. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  287. package/build-module/hooks/utils.js +5 -2
  288. package/build-module/hooks/utils.js.map +1 -1
  289. package/build-module/layouts/constrained.js +44 -2
  290. package/build-module/layouts/constrained.js.map +1 -1
  291. package/build-module/layouts/grid.js +92 -76
  292. package/build-module/layouts/grid.js.map +1 -1
  293. package/build-module/lock-unlock.js +1 -1
  294. package/build-module/lock-unlock.js.map +1 -1
  295. package/build-module/private-apis.js +8 -3
  296. package/build-module/private-apis.js.map +1 -1
  297. package/build-module/store/actions.js +17 -1
  298. package/build-module/store/actions.js.map +1 -1
  299. package/build-module/store/defaults.js +0 -2
  300. package/build-module/store/defaults.js.map +1 -1
  301. package/build-module/store/defaults.native.js +0 -3
  302. package/build-module/store/defaults.native.js.map +1 -1
  303. package/build-module/store/private-keys.js +1 -0
  304. package/build-module/store/private-keys.js.map +1 -1
  305. package/build-module/utils/format-font-style.js +39 -0
  306. package/build-module/utils/format-font-style.js.map +1 -0
  307. package/build-module/utils/format-font-weight.js +62 -0
  308. package/build-module/utils/format-font-weight.js.map +1 -0
  309. package/build-module/utils/get-editor-region.js +28 -0
  310. package/build-module/utils/get-editor-region.js.map +1 -0
  311. package/build-module/utils/get-font-styles-and-weights.js +160 -0
  312. package/build-module/utils/get-font-styles-and-weights.js.map +1 -0
  313. package/build-module/utils/pasting.js +5 -13
  314. package/build-module/utils/pasting.js.map +1 -1
  315. package/build-style/content-rtl.css +1 -0
  316. package/build-style/content.css +1 -0
  317. package/build-style/style-rtl.css +238 -106
  318. package/build-style/style.css +238 -106
  319. package/package.json +32 -32
  320. package/src/components/block-breadcrumb/index.js +16 -1
  321. package/src/components/block-lock/modal.js +95 -82
  322. package/src/components/block-lock/style.scss +11 -1
  323. package/src/components/block-lock/toolbar.js +0 -1
  324. package/src/components/block-mover/button.js +1 -1
  325. package/src/components/block-mover/index.js +37 -24
  326. package/src/components/block-pattern-setup/setup-toolbar.js +2 -2
  327. package/src/components/block-patterns-paging/index.js +8 -11
  328. package/src/components/block-patterns-paging/style.scss +18 -0
  329. package/src/components/block-quick-navigation/index.js +21 -28
  330. package/src/components/block-rename/modal.js +2 -8
  331. package/src/components/block-switcher/test/index.js +6 -6
  332. package/src/components/block-toolbar/shuffle.js +4 -1
  333. package/src/components/block-toolbar/style.scss +1 -11
  334. package/src/components/block-tools/block-selection-button.js +11 -83
  335. package/src/components/block-tools/block-toolbar-breadcrumb.js +9 -4
  336. package/src/components/block-tools/index.js +21 -1
  337. package/src/components/block-tools/style.scss +15 -0
  338. package/src/components/block-tools/use-show-block-tools.js +14 -6
  339. package/src/components/block-tools/zoom-out-mode-inserters.js +5 -4
  340. package/src/components/block-tools/zoom-out-popover.js +49 -0
  341. package/src/components/block-tools/zoom-out-toolbar.js +140 -0
  342. package/src/components/button-block-appender/index.js +2 -1
  343. package/src/components/child-layout-control/index.js +243 -160
  344. package/src/components/date-format-picker/index.js +10 -1
  345. package/src/components/date-format-picker/style.scss +0 -9
  346. package/src/components/dimensions-tool/index.js +97 -89
  347. package/src/components/font-appearance-control/index.js +29 -83
  348. package/src/components/font-appearance-control/style.scss +3 -5
  349. package/src/components/global-styles/background-panel.js +249 -170
  350. package/src/components/global-styles/border-panel.js +3 -2
  351. package/src/components/global-styles/color-panel.js +3 -2
  352. package/src/components/global-styles/dimensions-panel.js +3 -2
  353. package/src/components/global-styles/filters-panel.js +3 -2
  354. package/src/components/global-styles/hooks.js +9 -0
  355. package/src/components/global-styles/image-settings-panel.js +3 -2
  356. package/src/components/global-styles/style.scss +105 -20
  357. package/src/components/global-styles/test/typography-utils.js +269 -0
  358. package/src/components/global-styles/test/use-global-styles-output.js +38 -3
  359. package/src/components/global-styles/typography-panel.js +49 -12
  360. package/src/components/global-styles/typography-utils.js +63 -0
  361. package/src/components/global-styles/use-global-styles-output.js +25 -9
  362. package/src/components/global-styles/utils.js +17 -6
  363. package/src/components/grid/grid-item-movers.js +112 -0
  364. package/src/components/{grid-visualizer → grid}/grid-item-resizer.js +15 -52
  365. package/src/components/grid/grid-visualizer.js +384 -0
  366. package/src/components/grid/index.js +4 -0
  367. package/src/components/grid/style.scss +98 -0
  368. package/src/components/grid/use-get-number-of-blocks-before-cell.js +30 -0
  369. package/src/components/grid/use-grid-layout-sync.js +170 -0
  370. package/src/components/grid/utils.js +178 -0
  371. package/src/components/iframe/content.scss +1 -0
  372. package/src/components/image-editor/aspect-ratio-dropdown.js +0 -1
  373. package/src/components/inner-blocks/index.js +4 -1
  374. package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -16
  375. package/src/components/inserter/menu.js +47 -13
  376. package/src/components/inserter/quick-inserter.js +6 -1
  377. package/src/components/inserter/style.scss +1 -49
  378. package/src/components/inspector-controls/block-support-tools-panel.js +3 -3
  379. package/src/components/link-control/link-preview.js +1 -1
  380. package/src/components/media-placeholder/index.js +22 -32
  381. package/src/components/navigable-toolbar/index.js +3 -1
  382. package/src/components/rich-text/event-listeners/input-rules.js +1 -1
  383. package/src/components/rich-text/index.native.js +10 -8
  384. package/src/components/rich-text/native/index.native.js +17 -0
  385. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +6 -1
  386. package/src/components/tabbed-sidebar/README.md +76 -0
  387. package/src/components/tabbed-sidebar/index.js +70 -0
  388. package/src/components/tabbed-sidebar/style.scss +53 -0
  389. package/src/components/url-popover/index.js +3 -0
  390. package/src/hooks/background.js +25 -10
  391. package/src/hooks/block-hooks.js +9 -16
  392. package/src/hooks/block-style-variation.js +226 -9
  393. package/src/hooks/duotone.js +16 -12
  394. package/src/hooks/grid-visualizer.js +64 -0
  395. package/src/hooks/index.js +3 -0
  396. package/src/hooks/layout-child.js +75 -39
  397. package/src/hooks/position.js +3 -10
  398. package/src/hooks/test/get-variation-styles-with-ref-values.js +91 -0
  399. package/src/hooks/use-bindings-attributes.js +18 -4
  400. package/src/hooks/utils.js +5 -1
  401. package/src/layouts/constrained.js +43 -2
  402. package/src/layouts/grid.js +175 -88
  403. package/src/lock-unlock.js +1 -1
  404. package/src/private-apis.js +12 -1
  405. package/src/store/actions.js +21 -1
  406. package/src/store/defaults.js +0 -2
  407. package/src/store/defaults.native.js +0 -3
  408. package/src/store/private-keys.js +1 -0
  409. package/src/style.scss +2 -2
  410. package/src/utils/format-font-style.js +40 -0
  411. package/src/utils/format-font-weight.js +63 -0
  412. package/src/utils/get-editor-region.js +31 -0
  413. package/src/utils/get-font-styles-and-weights.js +191 -0
  414. package/src/utils/pasting.js +5 -12
  415. package/src/utils/test/format-font-style.js +34 -0
  416. package/src/utils/test/format-font-weight.js +66 -0
  417. package/src/utils/test/get-font-styles-and-weights.js +513 -0
  418. package/tsconfig.tsbuildinfo +1 -1
  419. package/build/components/grid-visualizer/grid-item-resizer.js.map +0 -1
  420. package/build/components/grid-visualizer/grid-visualizer.js +0 -92
  421. package/build/components/grid-visualizer/grid-visualizer.js.map +0 -1
  422. package/build/components/grid-visualizer/index.js.map +0 -1
  423. package/build/components/grid-visualizer/utils.js +0 -10
  424. package/build/components/grid-visualizer/utils.js.map +0 -1
  425. package/build-module/components/grid-visualizer/grid-item-resizer.js.map +0 -1
  426. package/build-module/components/grid-visualizer/grid-visualizer.js +0 -84
  427. package/build-module/components/grid-visualizer/grid-visualizer.js.map +0 -1
  428. package/build-module/components/grid-visualizer/index.js +0 -3
  429. package/build-module/components/grid-visualizer/index.js.map +0 -1
  430. package/build-module/components/grid-visualizer/utils.js +0 -4
  431. package/build-module/components/grid-visualizer/utils.js.map +0 -1
  432. package/src/components/grid-visualizer/grid-visualizer.js +0 -101
  433. package/src/components/grid-visualizer/index.js +0 -2
  434. package/src/components/grid-visualizer/style.scss +0 -34
  435. package/src/components/grid-visualizer/utils.js +0 -5
  436. package/src/hooks/position.scss +0 -18
  437. /package/src/components/font-sizes/{README.MD → README.md} +0 -0
@@ -0,0 +1,76 @@
1
+ # Tabbed Panel
2
+
3
+ The `TabbedPanel` component is used to create the secondary panels in the editor.
4
+
5
+ ## Development guidelines
6
+
7
+ This acts as a wrapper for the `Tabs` component, but adding conventions that can be shared between all secondary panels, for example:
8
+
9
+ - A close button
10
+ - Tabs that fill the panel
11
+ - Custom scollbars
12
+
13
+ ### Usage
14
+
15
+ Renders a block alignment toolbar with alignments options.
16
+
17
+ ```jsx
18
+ import { TabbedSidebar } from '@wordpress/components';
19
+
20
+ const MyTabbedSidebar = () => (
21
+ <TabbedSidebar
22
+ tabs={ [
23
+ {
24
+ name: 'slug-1',
25
+ title: _x( 'Title 1', 'context' ),
26
+ panel: <PanelContents>,
27
+ panelRef: useRef('an-optional-ref'),
28
+ },
29
+ {
30
+ name: 'slug-2',
31
+ title: _x( 'Title 2', 'context' ),
32
+ panel: <PanelContents />,
33
+ },
34
+ ] }
35
+ onClose={ onClickCloseButton }
36
+ onSelect={ onSelectTab }
37
+ defaultTabId="slug-1"
38
+ ref={ tabsRef }
39
+ />
40
+ );
41
+ ```
42
+
43
+ ### Props
44
+
45
+ ### `defaultTabId`
46
+
47
+ - **Type:** `String`
48
+ - **Default:** `undefined`
49
+
50
+ This is passed to the `Tabs` component so it can handle the tab to select by default when it component renders.
51
+
52
+ ### `onClose`
53
+
54
+ - **Type:** `Function`
55
+
56
+ The function that is called when the close button is clicked.
57
+
58
+ ### `onSelect`
59
+
60
+ - **Type:** `Function`
61
+
62
+ This is passed to the `Tabs` component - it will be called when a tab has been selected. It is passed the selected tab's ID as an argument.
63
+
64
+ ### `selectedTab`
65
+
66
+ - **Type:** `String`
67
+ - **Default:** `undefined`
68
+
69
+ This is passed to the `Tabs` component - it will display this tab as selected.
70
+
71
+ ### `tabs`
72
+
73
+ - **Type:** `Array`
74
+ - **Default:** `undefined`
75
+
76
+ An array of tabs which will be rendered as `TabList` and `TabPanel` components.
@@ -0,0 +1,70 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ Button,
6
+ privateApis as componentsPrivateApis,
7
+ } from '@wordpress/components';
8
+ import { forwardRef } from '@wordpress/element';
9
+ import { closeSmall } from '@wordpress/icons';
10
+
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+ import { unlock } from '../../lock-unlock';
15
+
16
+ const { Tabs } = unlock( componentsPrivateApis );
17
+
18
+ function TabbedSidebar(
19
+ { defaultTabId, onClose, onSelect, selectedTab, tabs, closeButtonLabel },
20
+ ref
21
+ ) {
22
+ return (
23
+ <div className="block-editor-tabbed-sidebar">
24
+ <Tabs
25
+ selectOnMove={ false }
26
+ defaultTabId={ defaultTabId }
27
+ onSelect={ onSelect }
28
+ selectedTabId={ selectedTab }
29
+ >
30
+ <div className="block-editor-tabbed-sidebar__tablist-and-close-button">
31
+ <Button
32
+ className="block-editor-tabbed-sidebar__close-button"
33
+ icon={ closeSmall }
34
+ label={ closeButtonLabel }
35
+ onClick={ () => onClose() }
36
+ size="small"
37
+ />
38
+
39
+ <Tabs.TabList
40
+ className="block-editor-tabbed-sidebar__tablist"
41
+ ref={ ref }
42
+ >
43
+ { tabs.map( ( tab ) => (
44
+ <Tabs.Tab
45
+ key={ tab.name }
46
+ tabId={ tab.name }
47
+ className="block-editor-tabbed-sidebar__tab"
48
+ >
49
+ { tab.title }
50
+ </Tabs.Tab>
51
+ ) ) }
52
+ </Tabs.TabList>
53
+ </div>
54
+ { tabs.map( ( tab ) => (
55
+ <Tabs.TabPanel
56
+ key={ tab.name }
57
+ tabId={ tab.name }
58
+ focusable={ false }
59
+ className="block-editor-tabbed-sidebar__tabpanel"
60
+ ref={ tab.panelRef }
61
+ >
62
+ { tab.panel }
63
+ </Tabs.TabPanel>
64
+ ) ) }
65
+ </Tabs>
66
+ </div>
67
+ );
68
+ }
69
+
70
+ export default forwardRef( TabbedSidebar );
@@ -0,0 +1,53 @@
1
+ .block-editor-tabbed-sidebar {
2
+ height: 100%;
3
+ display: flex;
4
+ flex-direction: column;
5
+ flex-grow: 1;
6
+ overflow: hidden;
7
+
8
+ @include break-medium() {
9
+ width: 350px;
10
+ }
11
+ }
12
+
13
+ .block-editor-tabbed-sidebar__tablist-and-close-button {
14
+ border-bottom: $border-width solid $gray-300;
15
+ display: flex;
16
+ justify-content: space-between;
17
+ padding-right: $grid-unit-15;
18
+ }
19
+
20
+
21
+ .block-editor-tabbed-sidebar__close-button {
22
+ background: $white;
23
+ /* stylelint-disable-next-line property-disallowed-list -- This should be removed when https://github.com/WordPress/gutenberg/issues/59013 is fixed. */
24
+ order: 1;
25
+ align-self: center;
26
+ }
27
+
28
+ .block-editor-tabbed-sidebar__tablist {
29
+ box-sizing: border-box;
30
+ flex-grow: 1;
31
+ margin-bottom: -$border-width;
32
+ width: 100%;
33
+ }
34
+
35
+ .block-editor-tabbed-sidebar__tab {
36
+ flex-grow: 1;
37
+ margin-bottom: -$border-width;
38
+
39
+ &[id$="reusable"] {
40
+ flex-grow: inherit;
41
+ // These are to align the `reusable` icon with the search icon.
42
+ padding-left: $grid-unit-20;
43
+ padding-right: $grid-unit-20;
44
+ }
45
+ }
46
+
47
+ .block-editor-tabbed-sidebar__tabpanel {
48
+ display: flex;
49
+ flex-grow: 1;
50
+ flex-direction: column;
51
+ overflow-y: auto;
52
+ scrollbar-gutter: auto;
53
+ }
@@ -71,6 +71,9 @@ const URLPopover = forwardRef(
71
71
  return (
72
72
  <Popover
73
73
  ref={ ref }
74
+ role="dialog"
75
+ aria-modal="true"
76
+ aria-label={ __( 'Edit URL' ) }
74
77
  className="block-editor-url-popover"
75
78
  focusOnMount={ focusOnMount }
76
79
  placement={ computedPlacement }
@@ -16,6 +16,10 @@ import {
16
16
  useHasBackgroundPanel,
17
17
  hasBackgroundImageValue,
18
18
  } from '../components/global-styles/background-panel';
19
+ import {
20
+ globalStylesDataKey,
21
+ globalStylesLinksDataKey,
22
+ } from '../store/private-keys';
19
23
 
20
24
  export const BACKGROUND_SUPPORT_KEY = 'background';
21
25
 
@@ -134,10 +138,25 @@ export function BackgroundImagePanel( {
134
138
  setAttributes,
135
139
  settings,
136
140
  } ) {
137
- const style = useSelect(
138
- ( select ) =>
139
- select( blockEditorStore ).getBlockAttributes( clientId )?.style,
140
- [ clientId ]
141
+ const { style, inheritedValue, _links } = useSelect(
142
+ ( select ) => {
143
+ const { getBlockAttributes, getSettings } =
144
+ select( blockEditorStore );
145
+ const _settings = getSettings();
146
+ return {
147
+ style: getBlockAttributes( clientId )?.style,
148
+ _links: _settings[ globalStylesLinksDataKey ],
149
+ /*
150
+ * @TODO 1. Pass inherited value down to all block style controls,
151
+ * See: packages/block-editor/src/hooks/style.js
152
+ * @TODO 2. Add support for block style variations,
153
+ * See implementation: packages/block-editor/src/hooks/block-style-variation.js
154
+ */
155
+ inheritedValue:
156
+ _settings[ globalStylesDataKey ]?.blocks?.[ name ],
157
+ };
158
+ },
159
+ [ clientId, name ]
141
160
  );
142
161
 
143
162
  if (
@@ -147,11 +166,6 @@ export function BackgroundImagePanel( {
147
166
  return null;
148
167
  }
149
168
 
150
- const defaultControls = getBlockSupport( name, [
151
- BACKGROUND_SUPPORT_KEY,
152
- '__experimentalDefaultControls',
153
- ] );
154
-
155
169
  const onChange = ( newStyle ) => {
156
170
  setAttributes( {
157
171
  style: cleanEmptyObject( newStyle ),
@@ -170,13 +184,14 @@ export function BackgroundImagePanel( {
170
184
 
171
185
  return (
172
186
  <StylesBackgroundPanel
187
+ inheritedValue={ inheritedValue }
173
188
  as={ BackgroundInspectorControl }
174
189
  panelId={ clientId }
175
- defaultControls={ defaultControls }
176
190
  defaultValues={ BACKGROUND_DEFAULT_VALUES }
177
191
  settings={ updatedSettings }
178
192
  onChange={ onChange }
179
193
  value={ style }
194
+ themeFileURIs={ _links?.[ 'wp:theme-file' ] }
180
195
  />
181
196
  );
182
197
  }
@@ -43,25 +43,12 @@ function BlockHooksControlPure( {
43
43
  [ blockTypes, name, ignoredHookedBlocks ]
44
44
  );
45
45
 
46
- const { blockIndex, rootClientId, innerBlocksLength } = useSelect(
47
- ( select ) => {
48
- const { getBlocks, getBlockIndex, getBlockRootClientId } =
49
- select( blockEditorStore );
50
-
51
- return {
52
- blockIndex: getBlockIndex( clientId ),
53
- innerBlocksLength: getBlocks( clientId )?.length,
54
- rootClientId: getBlockRootClientId( clientId ),
55
- };
56
- },
57
- [ clientId ]
58
- );
59
-
60
46
  const hookedBlockClientIds = useSelect(
61
47
  ( select ) => {
62
- const { getBlocks, getGlobalBlockCount } =
48
+ const { getBlocks, getBlockRootClientId, getGlobalBlockCount } =
63
49
  select( blockEditorStore );
64
50
 
51
+ const rootClientId = getBlockRootClientId( clientId );
65
52
  const _hookedBlockClientIds = hookedBlocksForCurrentBlock.reduce(
66
53
  ( clientIds, block ) => {
67
54
  // If the block doesn't exist anywhere in the block tree,
@@ -127,9 +114,11 @@ function BlockHooksControlPure( {
127
114
 
128
115
  return EMPTY_OBJECT;
129
116
  },
130
- [ hookedBlocksForCurrentBlock, name, clientId, rootClientId ]
117
+ [ hookedBlocksForCurrentBlock, name, clientId ]
131
118
  );
132
119
 
120
+ const { getBlockIndex, getBlockCount, getBlockRootClientId } =
121
+ useSelect( blockEditorStore );
133
122
  const { insertBlock, removeBlock } = useDispatch( blockEditorStore );
134
123
 
135
124
  if ( ! hookedBlocksForCurrentBlock.length ) {
@@ -150,6 +139,10 @@ function BlockHooksControlPure( {
150
139
  );
151
140
 
152
141
  const insertBlockIntoDesignatedLocation = ( block, relativePosition ) => {
142
+ const blockIndex = getBlockIndex( clientId );
143
+ const innerBlocksLength = getBlockCount( clientId );
144
+ const rootClientId = getBlockRootClientId( clientId );
145
+
153
146
  switch ( relativePosition ) {
154
147
  case 'before':
155
148
  case 'after':
@@ -14,8 +14,27 @@ import {
14
14
  getBlockSelectors,
15
15
  } from '../components/global-styles';
16
16
  import { useStyleOverride } from './utils';
17
+ import { getValueFromObjectPath } from '../utils/object';
17
18
  import { store as blockEditorStore } from '../store';
18
19
  import { globalStylesDataKey } from '../store/private-keys';
20
+ import { unlock } from '../lock-unlock';
21
+
22
+ const VARIATION_PREFIX = 'is-style-';
23
+
24
+ function getVariationMatches( className ) {
25
+ if ( ! className ) {
26
+ return [];
27
+ }
28
+ return className.split( /\s+/ ).reduce( ( matches, name ) => {
29
+ if ( name.startsWith( VARIATION_PREFIX ) ) {
30
+ const match = name.slice( VARIATION_PREFIX.length );
31
+ if ( match !== 'default' ) {
32
+ matches.push( match );
33
+ }
34
+ }
35
+ return matches;
36
+ }, [] );
37
+ }
19
38
 
20
39
  /**
21
40
  * Get the first block style variation that has been registered from the class string.
@@ -28,14 +47,13 @@ import { globalStylesDataKey } from '../store/private-keys';
28
47
  function getVariationNameFromClass( className, registeredStyles = [] ) {
29
48
  // The global flag affects how capturing groups work in JS. So the regex
30
49
  // below will only return full CSS classes not just the variation name.
31
- const matches = className?.match( /\bis-style-(?!default)(\S+)\b/g );
50
+ const matches = getVariationMatches( className );
32
51
 
33
52
  if ( ! matches ) {
34
53
  return null;
35
54
  }
36
55
 
37
- for ( const variationClass of matches ) {
38
- const variation = variationClass.substring( 9 ); // Remove 'is-style-' prefix.
56
+ for ( const variation of matches ) {
39
57
  if ( registeredStyles.some( ( style ) => style.name === variation ) ) {
40
58
  return variation;
41
59
  }
@@ -43,6 +61,197 @@ function getVariationNameFromClass( className, registeredStyles = [] ) {
43
61
  return null;
44
62
  }
45
63
 
64
+ // A helper component to apply a style override using the useStyleOverride hook.
65
+ function OverrideStyles( { override } ) {
66
+ useStyleOverride( override );
67
+ }
68
+
69
+ /**
70
+ * This component is used to generate new block style variation overrides
71
+ * based on an incoming theme config. If a matching style is found in the config,
72
+ * a new override is created and returned. The overrides can be used in conjunction with
73
+ * useStyleOverride to apply the new styles to the editor. Its use is
74
+ * subject to change.
75
+ *
76
+ * @param {Object} props Props.
77
+ * @param {Object} props.config A global styles object, containing settings and styles.
78
+ * @return {JSX.Element|undefined} An array of new block variation overrides.
79
+ */
80
+ export function __unstableBlockStyleVariationOverridesWithConfig( { config } ) {
81
+ const { getBlockStyles, overrides } = useSelect(
82
+ ( select ) => ( {
83
+ getBlockStyles: select( blocksStore ).getBlockStyles,
84
+ overrides: unlock( select( blockEditorStore ) ).getStyleOverrides(),
85
+ } ),
86
+ []
87
+ );
88
+ const { getBlockName } = useSelect( blockEditorStore );
89
+
90
+ const overridesWithConfig = useMemo( () => {
91
+ if ( ! overrides?.length ) {
92
+ return;
93
+ }
94
+ const newOverrides = [];
95
+ const overriddenClientIds = [];
96
+ for ( const [ , override ] of overrides ) {
97
+ if (
98
+ override?.variation &&
99
+ override?.clientId &&
100
+ /*
101
+ * Because this component overwrites existing style overrides,
102
+ * filter out any overrides that are already present in the store.
103
+ */
104
+ ! overriddenClientIds.includes( override.clientId )
105
+ ) {
106
+ const blockName = getBlockName( override.clientId );
107
+ const configStyles =
108
+ config?.styles?.blocks?.[ blockName ]?.variations?.[
109
+ override.variation
110
+ ];
111
+ if ( configStyles ) {
112
+ const variationConfig = {
113
+ settings: config?.settings,
114
+ // The variation style data is all that is needed to generate
115
+ // the styles for the current application to a block. The variation
116
+ // name is updated to match the instance specific class name.
117
+ styles: {
118
+ blocks: {
119
+ [ blockName ]: {
120
+ variations: {
121
+ [ `${ override.variation }-${ override.clientId }` ]:
122
+ configStyles,
123
+ },
124
+ },
125
+ },
126
+ },
127
+ };
128
+ const blockSelectors = getBlockSelectors(
129
+ getBlockTypes(),
130
+ getBlockStyles,
131
+ override.clientId
132
+ );
133
+ const hasBlockGapSupport = false;
134
+ const hasFallbackGapSupport = true;
135
+ const disableLayoutStyles = true;
136
+ const disableRootPadding = true;
137
+ const variationStyles = toStyles(
138
+ variationConfig,
139
+ blockSelectors,
140
+ hasBlockGapSupport,
141
+ hasFallbackGapSupport,
142
+ disableLayoutStyles,
143
+ disableRootPadding,
144
+ {
145
+ blockGap: false,
146
+ blockStyles: true,
147
+ layoutStyles: false,
148
+ marginReset: false,
149
+ presets: false,
150
+ rootPadding: false,
151
+ variationStyles: true,
152
+ }
153
+ );
154
+ newOverrides.push( {
155
+ id: `${ override.variation }-${ override.clientId }`,
156
+ css: variationStyles,
157
+ __unstableType: 'variation',
158
+ variation: override.variation,
159
+ // The clientId will be stored with the override and used to ensure
160
+ // the order of overrides matches the order of blocks so that the
161
+ // correct CSS cascade is maintained.
162
+ clientId: override.clientId,
163
+ } );
164
+ overriddenClientIds.push( override.clientId );
165
+ }
166
+ }
167
+ }
168
+ return newOverrides;
169
+ }, [ config, overrides, getBlockStyles, getBlockName ] );
170
+
171
+ if ( ! overridesWithConfig || ! overridesWithConfig.length ) {
172
+ return;
173
+ }
174
+
175
+ return (
176
+ <>
177
+ { overridesWithConfig.map( ( override ) => (
178
+ <OverrideStyles key={ override.id } override={ override } />
179
+ ) ) }
180
+ </>
181
+ );
182
+ }
183
+
184
+ /**
185
+ * Retrieves any variation styles data and resolves any referenced values.
186
+ *
187
+ * @param {Object} globalStyles A complete global styles object, containing settings and styles.
188
+ * @param {string} name The name of the desired block type.
189
+ * @param {variation} variation The of the block style variation to retrieve data for.
190
+ *
191
+ * @return {Object|undefined} The global styles data for the specified variation.
192
+ */
193
+ export function getVariationStylesWithRefValues(
194
+ globalStyles,
195
+ name,
196
+ variation
197
+ ) {
198
+ if ( ! globalStyles?.styles?.blocks?.[ name ]?.variations?.[ variation ] ) {
199
+ return;
200
+ }
201
+
202
+ // Helper to recursively look for `ref` values to resolve.
203
+ const replaceRefs = ( variationStyles ) => {
204
+ Object.keys( variationStyles ).forEach( ( key ) => {
205
+ const value = variationStyles[ key ];
206
+
207
+ // Only process objects.
208
+ if ( typeof value === 'object' && value !== null ) {
209
+ // Process `ref` value if present.
210
+ if ( value.ref !== undefined ) {
211
+ if (
212
+ typeof value.ref !== 'string' ||
213
+ value.ref.trim() === ''
214
+ ) {
215
+ // Remove invalid ref.
216
+ delete variationStyles[ key ];
217
+ } else {
218
+ // Resolve `ref` value.
219
+ const refValue = getValueFromObjectPath(
220
+ globalStyles,
221
+ value.ref
222
+ );
223
+
224
+ if ( refValue ) {
225
+ variationStyles[ key ] = refValue;
226
+ } else {
227
+ delete variationStyles[ key ];
228
+ }
229
+ }
230
+ } else {
231
+ // Recursively resolve `ref` values in nested objects.
232
+ replaceRefs( value );
233
+
234
+ // After recursion, if value is empty due to explicitly
235
+ // `undefined` ref value, remove it.
236
+ if ( Object.keys( value ).length === 0 ) {
237
+ delete variationStyles[ key ];
238
+ }
239
+ }
240
+ }
241
+ } );
242
+ };
243
+
244
+ // Deep clone variation node to avoid mutating it within global styles and losing refs.
245
+ const styles = JSON.parse(
246
+ JSON.stringify(
247
+ globalStyles.styles.blocks[ name ].variations[ variation ]
248
+ )
249
+ );
250
+ replaceRefs( styles );
251
+
252
+ return styles;
253
+ }
254
+
46
255
  function useBlockStyleVariation( name, variation, clientId ) {
47
256
  // Prefer global styles data in GlobalStylesContext, which are available
48
257
  // if in the site editor. Otherwise fall back to whatever is in the
@@ -57,9 +266,14 @@ function useBlockStyleVariation( name, variation, clientId ) {
57
266
  }, [] );
58
267
 
59
268
  return useMemo( () => {
60
- const styles = mergedConfig?.styles ?? globalStyles;
61
- const variationStyles =
62
- styles?.blocks?.[ name ]?.variations?.[ variation ];
269
+ const variationStyles = getVariationStylesWithRefValues(
270
+ {
271
+ settings: mergedConfig?.settings ?? globalSettings,
272
+ styles: mergedConfig?.styles ?? globalStyles,
273
+ },
274
+ name,
275
+ variation
276
+ );
63
277
 
64
278
  return {
65
279
  settings: mergedConfig?.settings ?? globalSettings,
@@ -94,7 +308,7 @@ function useBlockProps( { name, className, clientId } ) {
94
308
 
95
309
  const registeredStyles = getBlockStyles( name );
96
310
  const variation = getVariationNameFromClass( className, registeredStyles );
97
- const variationClass = `is-style-${ variation }-${ clientId }`;
311
+ const variationClass = `${ VARIATION_PREFIX }${ variation }-${ clientId }`;
98
312
 
99
313
  const { settings, styles } = useBlockStyleVariation(
100
314
  name,
@@ -116,7 +330,7 @@ function useBlockProps( { name, className, clientId } ) {
116
330
  const hasBlockGapSupport = false;
117
331
  const hasFallbackGapSupport = true;
118
332
  const disableLayoutStyles = true;
119
- const isTemplate = true;
333
+ const disableRootPadding = true;
120
334
 
121
335
  return toStyles(
122
336
  variationConfig,
@@ -124,7 +338,7 @@ function useBlockProps( { name, className, clientId } ) {
124
338
  hasBlockGapSupport,
125
339
  hasFallbackGapSupport,
126
340
  disableLayoutStyles,
127
- isTemplate,
341
+ disableRootPadding,
128
342
  {
129
343
  blockGap: false,
130
344
  blockStyles: true,
@@ -132,6 +346,7 @@ function useBlockProps( { name, className, clientId } ) {
132
346
  marginReset: false,
133
347
  presets: false,
134
348
  rootPadding: false,
349
+ variationStyles: true,
135
350
  }
136
351
  );
137
352
  }, [ variation, settings, styles, getBlockStyles, clientId ] );
@@ -140,6 +355,7 @@ function useBlockProps( { name, className, clientId } ) {
140
355
  id: `variation-${ clientId }`,
141
356
  css: variationStyles,
142
357
  __unstableType: 'variation',
358
+ variation,
143
359
  // The clientId will be stored with the override and used to ensure
144
360
  // the order of overrides matches the order of blocks so that the
145
361
  // correct CSS cascade is maintained.
@@ -152,5 +368,6 @@ function useBlockProps( { name, className, clientId } ) {
152
368
  export default {
153
369
  hasSupport: () => true,
154
370
  attributeKeys: [ 'className' ],
371
+ isMatch: ( { className } ) => getVariationMatches( className ).length > 0,
155
372
  useBlockProps,
156
373
  };
@@ -295,26 +295,30 @@ function useDuotoneStyles( {
295
295
  return;
296
296
  }
297
297
 
298
- // Safari does not always update the duotone filter when the duotone colors
299
- // are changed. When using Safari, force the block element to be repainted by
300
- // the browser to ensure any changes are reflected visually. This logic matches
301
- // that used on the site frontend in `block-supports/duotone.php`.
298
+ // Safari does not always update the duotone filter when the duotone
299
+ // colors are changed. When using Safari, force the block element to be
300
+ // repainted by the browser to ensure any changes are reflected
301
+ // visually. This logic matches that used on the site frontend in
302
+ // `block-supports/duotone.php`.
302
303
  if ( blockElement && isSafari ) {
303
304
  const display = blockElement.style.display;
304
- // Switch to `inline-block` to force a repaint. In the editor, `inline-block`
305
- // is used instead of `none` to ensure that scroll position is not affected,
306
- // as `none` results in the editor scrolling to the top of the block.
305
+ // Switch to `inline-block` to force a repaint. In the editor,
306
+ // `inline-block` is used instead of `none` to ensure that scroll
307
+ // position is not affected, as `none` results in the editor
308
+ // scrolling to the top of the block.
307
309
  blockElement.style.display = 'inline-block';
308
- // Simply accessing el.offsetHeight flushes layout and style
309
- // changes in WebKit without having to wait for setTimeout.
310
+ // Simply accessing el.offsetHeight flushes layout and style changes
311
+ // in WebKit without having to wait for setTimeout.
310
312
  // eslint-disable-next-line no-unused-expressions
311
313
  blockElement.offsetHeight;
312
314
  blockElement.style.display = display;
313
315
  }
314
- }, [ isValidFilter, blockElement ] );
316
+ // `colors` must be a dependency so this effect runs when the colors
317
+ // change in Safari.
318
+ }, [ isValidFilter, blockElement, colors ] );
315
319
  }
316
320
 
317
- function useBlockProps( { name, style } ) {
321
+ function useBlockProps( { clientId, name, style } ) {
318
322
  const id = useInstanceId( useBlockProps );
319
323
  const selector = useMemo( () => {
320
324
  const blockType = getBlockType( name );
@@ -362,7 +366,7 @@ function useBlockProps( { name, style } ) {
362
366
  const shouldRender = selector && attribute;
363
367
 
364
368
  useDuotoneStyles( {
365
- clientId: id,
369
+ clientId,
366
370
  id: filterClass,
367
371
  selector,
368
372
  attribute,