@wordpress/block-editor 13.2.0 → 13.4.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 (538) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +0 -5
  3. package/build/components/alignment-control/ui.js +2 -2
  4. package/build/components/alignment-control/ui.js.map +1 -1
  5. package/build/components/block-alignment-control/ui.js +1 -1
  6. package/build/components/block-alignment-control/ui.js.map +1 -1
  7. package/build/components/block-alignment-control/ui.native.js +1 -1
  8. package/build/components/block-alignment-control/ui.native.js.map +1 -1
  9. package/build/components/block-breadcrumb/index.js +12 -1
  10. package/build/components/block-breadcrumb/index.js.map +1 -1
  11. package/build/components/block-inspector/index.js +6 -3
  12. package/build/components/block-inspector/index.js.map +1 -1
  13. package/build/components/block-list/use-block-props/index.js +3 -1
  14. package/build/components/block-list/use-block-props/index.js.map +1 -1
  15. package/build/components/block-list/use-block-props/use-block-refs.js +9 -2
  16. package/build/components/block-list/use-block-props/use-block-refs.js.map +1 -1
  17. package/build/components/block-list/use-block-props/use-is-hovered.js +25 -9
  18. package/build/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
  19. package/build/components/block-list/use-in-between-inserter.js +3 -2
  20. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  21. package/build/components/block-lock/modal.js +2 -0
  22. package/build/components/block-lock/modal.js.map +1 -1
  23. package/build/components/block-lock/toolbar.js +0 -1
  24. package/build/components/block-lock/toolbar.js.map +1 -1
  25. package/build/components/block-mover/button.js +1 -1
  26. package/build/components/block-mover/button.js.map +1 -1
  27. package/build/components/block-mover/index.js +1 -1
  28. package/build/components/block-mover/index.js.map +1 -1
  29. package/build/components/block-pattern-setup/setup-toolbar.js +2 -2
  30. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  31. package/build/components/block-patterns-paging/index.js +5 -7
  32. package/build/components/block-patterns-paging/index.js.map +1 -1
  33. package/build/components/block-quick-navigation/index.js +20 -17
  34. package/build/components/block-quick-navigation/index.js.map +1 -1
  35. package/build/components/block-removal-warning-modal/index.js +2 -0
  36. package/build/components/block-removal-warning-modal/index.js.map +1 -1
  37. package/build/components/block-rename/modal.js +4 -12
  38. package/build/components/block-rename/modal.js.map +1 -1
  39. package/build/components/block-switcher/index.js +1 -1
  40. package/build/components/block-switcher/index.js.map +1 -1
  41. package/build/components/block-switcher/pattern-transformations-menu.js +11 -12
  42. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  43. package/build/components/block-switcher/preview-block-popover.js +20 -17
  44. package/build/components/block-switcher/preview-block-popover.js.map +1 -1
  45. package/build/components/block-toolbar/shuffle.js +6 -2
  46. package/build/components/block-toolbar/shuffle.js.map +1 -1
  47. package/build/components/block-tools/block-selection-button.js +7 -58
  48. package/build/components/block-tools/block-selection-button.js.map +1 -1
  49. package/build/components/block-tools/block-toolbar-breadcrumb.js +9 -2
  50. package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
  51. package/build/components/block-tools/index.js +14 -1
  52. package/build/components/block-tools/index.js.map +1 -1
  53. package/build/components/block-tools/use-show-block-tools.js +9 -8
  54. package/build/components/block-tools/use-show-block-tools.js.map +1 -1
  55. package/build/components/block-tools/zoom-out-mode-inserter-button.js +45 -0
  56. package/build/components/block-tools/zoom-out-mode-inserter-button.js.map +1 -0
  57. package/build/components/block-tools/zoom-out-mode-inserters.js +29 -28
  58. package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  59. package/build/components/block-tools/zoom-out-popover.js +58 -0
  60. package/build/components/block-tools/zoom-out-popover.js.map +1 -0
  61. package/build/components/block-tools/zoom-out-toolbar.js +138 -0
  62. package/build/components/block-tools/zoom-out-toolbar.js.map +1 -0
  63. package/build/components/button-block-appender/index.js +3 -1
  64. package/build/components/button-block-appender/index.js.map +1 -1
  65. package/build/components/child-layout-control/index.js +26 -18
  66. package/build/components/child-layout-control/index.js.map +1 -1
  67. package/build/components/date-format-picker/index.js +1 -1
  68. package/build/components/date-format-picker/index.js.map +1 -1
  69. package/build/components/default-block-appender/index.js +7 -4
  70. package/build/components/default-block-appender/index.js.map +1 -1
  71. package/build/components/dimensions-tool/index.js +6 -4
  72. package/build/components/dimensions-tool/index.js.map +1 -1
  73. package/build/components/font-appearance-control/index.js +22 -62
  74. package/build/components/font-appearance-control/index.js.map +1 -1
  75. package/build/components/global-styles/background-panel.js +185 -116
  76. package/build/components/global-styles/background-panel.js.map +1 -1
  77. package/build/components/global-styles/border-panel.js +2 -1
  78. package/build/components/global-styles/border-panel.js.map +1 -1
  79. package/build/components/global-styles/color-panel.js +2 -1
  80. package/build/components/global-styles/color-panel.js.map +1 -1
  81. package/build/components/global-styles/dimensions-panel.js +2 -1
  82. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  83. package/build/components/global-styles/filters-panel.js +2 -1
  84. package/build/components/global-styles/filters-panel.js.map +1 -1
  85. package/build/components/global-styles/hooks.js +13 -1
  86. package/build/components/global-styles/hooks.js.map +1 -1
  87. package/build/components/global-styles/image-settings-panel.js +2 -1
  88. package/build/components/global-styles/image-settings-panel.js.map +1 -1
  89. package/build/components/global-styles/typography-panel.js +45 -24
  90. package/build/components/global-styles/typography-panel.js.map +1 -1
  91. package/build/components/global-styles/typography-utils.js +121 -0
  92. package/build/components/global-styles/typography-utils.js.map +1 -1
  93. package/build/components/global-styles/use-global-styles-output.js +47 -13
  94. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  95. package/build/components/global-styles/utils.js +17 -7
  96. package/build/components/global-styles/utils.js.map +1 -1
  97. package/build/components/grid/grid-item-movers.js +90 -48
  98. package/build/components/grid/grid-item-movers.js.map +1 -1
  99. package/build/components/grid/grid-item-resizer.js +2 -2
  100. package/build/components/grid/grid-item-resizer.js.map +1 -1
  101. package/build/components/grid/grid-visualizer.js +117 -37
  102. package/build/components/grid/grid-visualizer.js.map +1 -1
  103. package/build/components/grid/use-grid-layout-sync.js +60 -41
  104. package/build/components/grid/use-grid-layout-sync.js.map +1 -1
  105. package/build/components/index.js +1 -9
  106. package/build/components/index.js.map +1 -1
  107. package/build/components/inner-blocks/index.js +2 -2
  108. package/build/components/inner-blocks/index.js.map +1 -1
  109. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -19
  110. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
  111. package/build/components/inserter/block-patterns-tab/patterns-filter.js +20 -23
  112. package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  113. package/build/components/inserter/media-tab/media-panel.js +1 -0
  114. package/build/components/inserter/media-tab/media-panel.js.map +1 -1
  115. package/build/components/inserter/menu.js +26 -4
  116. package/build/components/inserter/menu.js.map +1 -1
  117. package/build/components/inserter/preview-panel.js +20 -3
  118. package/build/components/inserter/preview-panel.js.map +1 -1
  119. package/build/components/inserter/quick-inserter.js +2 -1
  120. package/build/components/inserter/quick-inserter.js.map +1 -1
  121. package/build/components/inserter-draggable-blocks/index.js +10 -3
  122. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  123. package/build/components/inspector-controls/block-support-tools-panel.js +2 -1
  124. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  125. package/build/components/inspector-controls-tabs/settings-tab.js +1 -2
  126. package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  127. package/build/components/link-control/link-preview.js +1 -1
  128. package/build/components/link-control/link-preview.js.map +1 -1
  129. package/build/components/list-view/block-select-button.js +2 -6
  130. package/build/components/list-view/block-select-button.js.map +1 -1
  131. package/build/components/list-view/block.js +2 -2
  132. package/build/components/list-view/block.js.map +1 -1
  133. package/build/components/list-view/utils.js +3 -1
  134. package/build/components/list-view/utils.js.map +1 -1
  135. package/build/components/media-placeholder/index.js +19 -23
  136. package/build/components/media-placeholder/index.js.map +1 -1
  137. package/build/components/navigable-toolbar/index.js +3 -1
  138. package/build/components/navigable-toolbar/index.js.map +1 -1
  139. package/build/components/rich-text/format-toolbar/index.js +1 -1
  140. package/build/components/rich-text/format-toolbar/index.js.map +1 -1
  141. package/build/components/rich-text/index.js +1 -1
  142. package/build/components/rich-text/index.js.map +1 -1
  143. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +9 -3
  144. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  145. package/build/components/tabbed-sidebar/index.js +66 -0
  146. package/build/components/tabbed-sidebar/index.js.map +1 -0
  147. package/build/components/url-popover/image-url-input-ui.js +3 -3
  148. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  149. package/build/components/url-popover/index.js +3 -0
  150. package/build/components/url-popover/index.js.map +1 -1
  151. package/build/hooks/background.js +26 -4
  152. package/build/hooks/background.js.map +1 -1
  153. package/build/hooks/block-hooks.js +11 -17
  154. package/build/hooks/block-hooks.js.map +1 -1
  155. package/build/hooks/block-style-variation.js +169 -4
  156. package/build/hooks/block-style-variation.js.map +1 -1
  157. package/build/hooks/duotone.js +16 -11
  158. package/build/hooks/duotone.js.map +1 -1
  159. package/build/hooks/grid-visualizer.js +62 -0
  160. package/build/hooks/grid-visualizer.js.map +1 -0
  161. package/build/hooks/index.js +15 -2
  162. package/build/hooks/index.js.map +1 -1
  163. package/build/hooks/layout-child.js +47 -23
  164. package/build/hooks/layout-child.js.map +1 -1
  165. package/build/hooks/position.js +4 -15
  166. package/build/hooks/position.js.map +1 -1
  167. package/build/hooks/use-bindings-attributes.js +96 -55
  168. package/build/hooks/use-bindings-attributes.js.map +1 -1
  169. package/build/hooks/utils.js +2 -0
  170. package/build/hooks/utils.js.map +1 -1
  171. package/build/layouts/constrained.js +50 -4
  172. package/build/layouts/constrained.js.map +1 -1
  173. package/build/layouts/grid.js +92 -51
  174. package/build/layouts/grid.js.map +1 -1
  175. package/build/private-apis.js +6 -4
  176. package/build/private-apis.js.map +1 -1
  177. package/build/store/actions.js +18 -1
  178. package/build/store/actions.js.map +1 -1
  179. package/build/store/defaults.js +0 -2
  180. package/build/store/defaults.js.map +1 -1
  181. package/build/store/defaults.native.js +0 -3
  182. package/build/store/defaults.native.js.map +1 -1
  183. package/build/store/private-keys.js +2 -1
  184. package/build/store/private-keys.js.map +1 -1
  185. package/build/store/reducer.js +19 -1
  186. package/build/store/reducer.js.map +1 -1
  187. package/build/store/selectors.js +13 -1
  188. package/build/store/selectors.js.map +1 -1
  189. package/build/utils/format-font-style.js +45 -0
  190. package/build/utils/format-font-style.js.map +1 -0
  191. package/build/utils/format-font-weight.js +68 -0
  192. package/build/utils/format-font-weight.js.map +1 -0
  193. package/build/utils/get-editor-region.js +34 -0
  194. package/build/utils/get-editor-region.js.map +1 -0
  195. package/build/utils/get-font-styles-and-weights.js +167 -0
  196. package/build/utils/get-font-styles-and-weights.js.map +1 -0
  197. package/build/utils/pasting.js +5 -13
  198. package/build/utils/pasting.js.map +1 -1
  199. package/build-module/components/alignment-control/ui.js +2 -2
  200. package/build-module/components/alignment-control/ui.js.map +1 -1
  201. package/build-module/components/block-alignment-control/ui.js +1 -1
  202. package/build-module/components/block-alignment-control/ui.js.map +1 -1
  203. package/build-module/components/block-alignment-control/ui.native.js +1 -1
  204. package/build-module/components/block-alignment-control/ui.native.js.map +1 -1
  205. package/build-module/components/block-breadcrumb/index.js +12 -1
  206. package/build-module/components/block-breadcrumb/index.js.map +1 -1
  207. package/build-module/components/block-inspector/index.js +6 -3
  208. package/build-module/components/block-inspector/index.js.map +1 -1
  209. package/build-module/components/block-list/use-block-props/index.js +3 -1
  210. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  211. package/build-module/components/block-list/use-block-props/use-block-refs.js +11 -4
  212. package/build-module/components/block-list/use-block-props/use-block-refs.js.map +1 -1
  213. package/build-module/components/block-list/use-block-props/use-is-hovered.js +26 -9
  214. package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
  215. package/build-module/components/block-list/use-in-between-inserter.js +3 -2
  216. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  217. package/build-module/components/block-lock/modal.js +2 -0
  218. package/build-module/components/block-lock/modal.js.map +1 -1
  219. package/build-module/components/block-lock/toolbar.js +0 -1
  220. package/build-module/components/block-lock/toolbar.js.map +1 -1
  221. package/build-module/components/block-mover/button.js +1 -1
  222. package/build-module/components/block-mover/button.js.map +1 -1
  223. package/build-module/components/block-mover/index.js +1 -1
  224. package/build-module/components/block-mover/index.js.map +1 -1
  225. package/build-module/components/block-pattern-setup/setup-toolbar.js +2 -2
  226. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  227. package/build-module/components/block-patterns-paging/index.js +5 -7
  228. package/build-module/components/block-patterns-paging/index.js.map +1 -1
  229. package/build-module/components/block-quick-navigation/index.js +20 -17
  230. package/build-module/components/block-quick-navigation/index.js.map +1 -1
  231. package/build-module/components/block-removal-warning-modal/index.js +2 -0
  232. package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
  233. package/build-module/components/block-rename/modal.js +5 -13
  234. package/build-module/components/block-rename/modal.js.map +1 -1
  235. package/build-module/components/block-switcher/index.js +1 -1
  236. package/build-module/components/block-switcher/index.js.map +1 -1
  237. package/build-module/components/block-switcher/pattern-transformations-menu.js +12 -13
  238. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  239. package/build-module/components/block-switcher/preview-block-popover.js +20 -17
  240. package/build-module/components/block-switcher/preview-block-popover.js.map +1 -1
  241. package/build-module/components/block-toolbar/shuffle.js +6 -2
  242. package/build-module/components/block-toolbar/shuffle.js.map +1 -1
  243. package/build-module/components/block-tools/block-selection-button.js +10 -61
  244. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  245. package/build-module/components/block-tools/block-toolbar-breadcrumb.js +9 -2
  246. package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
  247. package/build-module/components/block-tools/index.js +14 -1
  248. package/build-module/components/block-tools/index.js.map +1 -1
  249. package/build-module/components/block-tools/use-show-block-tools.js +9 -8
  250. package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
  251. package/build-module/components/block-tools/zoom-out-mode-inserter-button.js +37 -0
  252. package/build-module/components/block-tools/zoom-out-mode-inserter-button.js.map +1 -0
  253. package/build-module/components/block-tools/zoom-out-mode-inserters.js +30 -29
  254. package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  255. package/build-module/components/block-tools/zoom-out-popover.js +49 -0
  256. package/build-module/components/block-tools/zoom-out-popover.js.map +1 -0
  257. package/build-module/components/block-tools/zoom-out-toolbar.js +131 -0
  258. package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -0
  259. package/build-module/components/button-block-appender/index.js +3 -1
  260. package/build-module/components/button-block-appender/index.js.map +1 -1
  261. package/build-module/components/child-layout-control/index.js +27 -19
  262. package/build-module/components/child-layout-control/index.js.map +1 -1
  263. package/build-module/components/date-format-picker/index.js +2 -2
  264. package/build-module/components/date-format-picker/index.js.map +1 -1
  265. package/build-module/components/default-block-appender/index.js +7 -4
  266. package/build-module/components/default-block-appender/index.js.map +1 -1
  267. package/build-module/components/dimensions-tool/index.js +6 -4
  268. package/build-module/components/dimensions-tool/index.js.map +1 -1
  269. package/build-module/components/font-appearance-control/index.js +24 -62
  270. package/build-module/components/font-appearance-control/index.js.map +1 -1
  271. package/build-module/components/global-styles/background-panel.js +188 -119
  272. package/build-module/components/global-styles/background-panel.js.map +1 -1
  273. package/build-module/components/global-styles/border-panel.js +3 -2
  274. package/build-module/components/global-styles/border-panel.js.map +1 -1
  275. package/build-module/components/global-styles/color-panel.js +3 -2
  276. package/build-module/components/global-styles/color-panel.js.map +1 -1
  277. package/build-module/components/global-styles/dimensions-panel.js +3 -2
  278. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  279. package/build-module/components/global-styles/filters-panel.js +3 -2
  280. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  281. package/build-module/components/global-styles/hooks.js +13 -1
  282. package/build-module/components/global-styles/hooks.js.map +1 -1
  283. package/build-module/components/global-styles/image-settings-panel.js +3 -2
  284. package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
  285. package/build-module/components/global-styles/typography-panel.js +47 -26
  286. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  287. package/build-module/components/global-styles/typography-utils.js +117 -0
  288. package/build-module/components/global-styles/typography-utils.js.map +1 -1
  289. package/build-module/components/global-styles/use-global-styles-output.js +47 -13
  290. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  291. package/build-module/components/global-styles/utils.js +15 -6
  292. package/build-module/components/global-styles/utils.js.map +1 -1
  293. package/build-module/components/grid/grid-item-movers.js +93 -50
  294. package/build-module/components/grid/grid-item-movers.js.map +1 -1
  295. package/build-module/components/grid/grid-item-resizer.js +2 -2
  296. package/build-module/components/grid/grid-item-resizer.js.map +1 -1
  297. package/build-module/components/grid/grid-visualizer.js +118 -38
  298. package/build-module/components/grid/grid-visualizer.js.map +1 -1
  299. package/build-module/components/grid/use-grid-layout-sync.js +61 -42
  300. package/build-module/components/grid/use-grid-layout-sync.js.map +1 -1
  301. package/build-module/components/index.js +0 -5
  302. package/build-module/components/index.js.map +1 -1
  303. package/build-module/components/inner-blocks/index.js +2 -2
  304. package/build-module/components/inner-blocks/index.js.map +1 -1
  305. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -19
  306. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
  307. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js +20 -23
  308. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  309. package/build-module/components/inserter/media-tab/media-panel.js +1 -0
  310. package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
  311. package/build-module/components/inserter/menu.js +26 -4
  312. package/build-module/components/inserter/menu.js.map +1 -1
  313. package/build-module/components/inserter/preview-panel.js +20 -3
  314. package/build-module/components/inserter/preview-panel.js.map +1 -1
  315. package/build-module/components/inserter/quick-inserter.js +2 -1
  316. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  317. package/build-module/components/inserter-draggable-blocks/index.js +10 -3
  318. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  319. package/build-module/components/inspector-controls/block-support-tools-panel.js +3 -2
  320. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  321. package/build-module/components/inspector-controls-tabs/settings-tab.js +1 -2
  322. package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  323. package/build-module/components/link-control/link-preview.js +1 -1
  324. package/build-module/components/link-control/link-preview.js.map +1 -1
  325. package/build-module/components/list-view/block-select-button.js +3 -7
  326. package/build-module/components/list-view/block-select-button.js.map +1 -1
  327. package/build-module/components/list-view/block.js +2 -2
  328. package/build-module/components/list-view/block.js.map +1 -1
  329. package/build-module/components/list-view/utils.js +3 -1
  330. package/build-module/components/list-view/utils.js.map +1 -1
  331. package/build-module/components/media-placeholder/index.js +19 -23
  332. package/build-module/components/media-placeholder/index.js.map +1 -1
  333. package/build-module/components/navigable-toolbar/index.js +3 -1
  334. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  335. package/build-module/components/rich-text/format-toolbar/index.js +1 -1
  336. package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
  337. package/build-module/components/rich-text/index.js +1 -1
  338. package/build-module/components/rich-text/index.js.map +1 -1
  339. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +9 -3
  340. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  341. package/build-module/components/tabbed-sidebar/index.js +60 -0
  342. package/build-module/components/tabbed-sidebar/index.js.map +1 -0
  343. package/build-module/components/url-popover/image-url-input-ui.js +3 -3
  344. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  345. package/build-module/components/url-popover/index.js +3 -0
  346. package/build-module/components/url-popover/index.js.map +1 -1
  347. package/build-module/hooks/background.js +26 -4
  348. package/build-module/hooks/background.js.map +1 -1
  349. package/build-module/hooks/block-hooks.js +11 -17
  350. package/build-module/hooks/block-hooks.js.map +1 -1
  351. package/build-module/hooks/block-style-variation.js +168 -4
  352. package/build-module/hooks/block-style-variation.js.map +1 -1
  353. package/build-module/hooks/duotone.js +16 -11
  354. package/build-module/hooks/duotone.js.map +1 -1
  355. package/build-module/hooks/grid-visualizer.js +61 -0
  356. package/build-module/hooks/grid-visualizer.js.map +1 -0
  357. package/build-module/hooks/index.js +3 -0
  358. package/build-module/hooks/index.js.map +1 -1
  359. package/build-module/hooks/layout-child.js +47 -23
  360. package/build-module/hooks/layout-child.js.map +1 -1
  361. package/build-module/hooks/position.js +4 -15
  362. package/build-module/hooks/position.js.map +1 -1
  363. package/build-module/hooks/use-bindings-attributes.js +96 -56
  364. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  365. package/build-module/hooks/utils.js +2 -0
  366. package/build-module/hooks/utils.js.map +1 -1
  367. package/build-module/layouts/constrained.js +50 -4
  368. package/build-module/layouts/constrained.js.map +1 -1
  369. package/build-module/layouts/grid.js +92 -51
  370. package/build-module/layouts/grid.js.map +1 -1
  371. package/build-module/private-apis.js +8 -6
  372. package/build-module/private-apis.js.map +1 -1
  373. package/build-module/store/actions.js +15 -0
  374. package/build-module/store/actions.js.map +1 -1
  375. package/build-module/store/defaults.js +0 -2
  376. package/build-module/store/defaults.js.map +1 -1
  377. package/build-module/store/defaults.native.js +0 -3
  378. package/build-module/store/defaults.native.js.map +1 -1
  379. package/build-module/store/private-keys.js +1 -0
  380. package/build-module/store/private-keys.js.map +1 -1
  381. package/build-module/store/reducer.js +18 -1
  382. package/build-module/store/reducer.js.map +1 -1
  383. package/build-module/store/selectors.js +10 -0
  384. package/build-module/store/selectors.js.map +1 -1
  385. package/build-module/utils/format-font-style.js +39 -0
  386. package/build-module/utils/format-font-style.js.map +1 -0
  387. package/build-module/utils/format-font-weight.js +62 -0
  388. package/build-module/utils/format-font-weight.js.map +1 -0
  389. package/build-module/utils/get-editor-region.js +28 -0
  390. package/build-module/utils/get-editor-region.js.map +1 -0
  391. package/build-module/utils/get-font-styles-and-weights.js +160 -0
  392. package/build-module/utils/get-font-styles-and-weights.js.map +1 -0
  393. package/build-module/utils/pasting.js +5 -13
  394. package/build-module/utils/pasting.js.map +1 -1
  395. package/build-style/content-rtl.css +7 -6
  396. package/build-style/content.css +7 -6
  397. package/build-style/style-rtl.css +356 -181
  398. package/build-style/style.css +356 -181
  399. package/build-types/components/block-context/index.d.ts +2 -2
  400. package/build-types/components/block-context/index.d.ts.map +1 -1
  401. package/build-types/utils/dom.d.ts.map +1 -1
  402. package/package.json +32 -32
  403. package/src/components/alignment-control/ui.js +2 -2
  404. package/src/components/block-alignment-control/ui.js +1 -1
  405. package/src/components/block-alignment-control/ui.native.js +1 -1
  406. package/src/components/block-breadcrumb/index.js +16 -1
  407. package/src/components/block-context/README.md +4 -4
  408. package/src/components/block-inspector/index.js +8 -4
  409. package/src/components/block-list/content.scss +2 -16
  410. package/src/components/block-list/use-block-props/index.js +1 -1
  411. package/src/components/block-list/use-block-props/use-block-refs.js +19 -3
  412. package/src/components/block-list/use-block-props/use-is-hovered.js +26 -11
  413. package/src/components/block-list/use-in-between-inserter.js +5 -1
  414. package/src/components/block-lock/modal.js +10 -2
  415. package/src/components/block-lock/style.scss +4 -8
  416. package/src/components/block-lock/toolbar.js +0 -1
  417. package/src/components/block-mover/button.js +1 -1
  418. package/src/components/block-mover/index.js +1 -1
  419. package/src/components/block-pattern-setup/setup-toolbar.js +2 -2
  420. package/src/components/block-patterns-paging/index.js +8 -11
  421. package/src/components/block-patterns-paging/style.scss +0 -5
  422. package/src/components/block-quick-navigation/index.js +21 -28
  423. package/src/components/block-removal-warning-modal/index.js +10 -2
  424. package/src/components/block-rename/modal.js +2 -8
  425. package/src/components/block-switcher/index.js +1 -1
  426. package/src/components/block-switcher/pattern-transformations-menu.js +17 -15
  427. package/src/components/block-switcher/preview-block-popover.js +20 -14
  428. package/src/components/block-switcher/style.scss +8 -17
  429. package/src/components/block-switcher/test/index.js +6 -6
  430. package/src/components/block-toolbar/shuffle.js +9 -1
  431. package/src/components/block-toolbar/style.scss +1 -11
  432. package/src/components/block-tools/block-selection-button.js +11 -83
  433. package/src/components/block-tools/block-toolbar-breadcrumb.js +9 -4
  434. package/src/components/block-tools/index.js +21 -1
  435. package/src/components/block-tools/style.scss +23 -0
  436. package/src/components/block-tools/use-show-block-tools.js +21 -10
  437. package/src/components/block-tools/zoom-out-mode-inserter-button.js +47 -0
  438. package/src/components/block-tools/zoom-out-mode-inserters.js +44 -33
  439. package/src/components/block-tools/zoom-out-popover.js +50 -0
  440. package/src/components/block-tools/zoom-out-toolbar.js +140 -0
  441. package/src/components/button-block-appender/index.js +2 -1
  442. package/src/components/child-layout-control/index.js +41 -23
  443. package/src/components/date-format-picker/index.js +2 -2
  444. package/src/components/date-format-picker/style.scss +0 -9
  445. package/src/components/default-block-appender/index.js +11 -4
  446. package/src/components/dimensions-tool/index.js +97 -89
  447. package/src/components/font-appearance-control/index.js +24 -82
  448. package/src/components/font-appearance-control/style.scss +3 -5
  449. package/src/components/global-styles/background-panel.js +266 -167
  450. package/src/components/global-styles/border-panel.js +3 -2
  451. package/src/components/global-styles/color-panel.js +3 -2
  452. package/src/components/global-styles/dimensions-panel.js +3 -2
  453. package/src/components/global-styles/filters-panel.js +3 -2
  454. package/src/components/global-styles/hooks.js +14 -1
  455. package/src/components/global-styles/image-settings-panel.js +3 -2
  456. package/src/components/global-styles/style.scss +116 -19
  457. package/src/components/global-styles/test/typography-utils.js +594 -0
  458. package/src/components/global-styles/test/use-global-styles-output.js +3 -1
  459. package/src/components/global-styles/typography-panel.js +56 -27
  460. package/src/components/global-styles/typography-utils.js +159 -0
  461. package/src/components/global-styles/use-global-styles-output.js +45 -10
  462. package/src/components/global-styles/utils.js +17 -6
  463. package/src/components/grid/grid-item-movers.js +140 -86
  464. package/src/components/grid/grid-item-resizer.js +3 -2
  465. package/src/components/grid/grid-visualizer.js +172 -55
  466. package/src/components/grid/style.scss +157 -8
  467. package/src/components/grid/use-grid-layout-sync.js +88 -46
  468. package/src/components/iframe/content.scss +2 -1
  469. package/src/components/index.js +0 -5
  470. package/src/components/inner-blocks/index.js +6 -2
  471. package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -16
  472. package/src/components/inserter/block-patterns-tab/patterns-filter.js +40 -44
  473. package/src/components/inserter/media-tab/media-panel.js +1 -0
  474. package/src/components/inserter/menu.js +47 -13
  475. package/src/components/inserter/preview-panel.js +27 -4
  476. package/src/components/inserter/quick-inserter.js +6 -1
  477. package/src/components/inserter/style.scss +58 -92
  478. package/src/components/inserter-draggable-blocks/index.js +11 -3
  479. package/src/components/inspector-controls/block-support-tools-panel.js +3 -3
  480. package/src/components/inspector-controls-tabs/settings-tab.js +0 -2
  481. package/src/components/inspector-controls-tabs/style.scss +0 -21
  482. package/src/components/link-control/link-preview.js +1 -1
  483. package/src/components/list-view/block-select-button.js +3 -13
  484. package/src/components/list-view/block.js +10 -3
  485. package/src/components/list-view/style.scss +2 -1
  486. package/src/components/list-view/utils.js +13 -2
  487. package/src/components/media-placeholder/index.js +22 -32
  488. package/src/components/navigable-toolbar/index.js +3 -1
  489. package/src/components/rich-text/format-toolbar/index.js +1 -1
  490. package/src/components/rich-text/index.js +1 -1
  491. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +9 -2
  492. package/src/components/tabbed-sidebar/README.md +76 -0
  493. package/src/components/tabbed-sidebar/index.js +70 -0
  494. package/src/components/tabbed-sidebar/style.scss +53 -0
  495. package/src/components/url-popover/image-url-input-ui.js +3 -3
  496. package/src/components/url-popover/index.js +3 -0
  497. package/src/components/url-popover/style.scss +1 -0
  498. package/src/hooks/background.js +25 -10
  499. package/src/hooks/block-hooks.js +9 -16
  500. package/src/hooks/block-style-variation.js +202 -3
  501. package/src/hooks/duotone.js +16 -12
  502. package/src/hooks/grid-visualizer.js +62 -0
  503. package/src/hooks/index.js +3 -0
  504. package/src/hooks/layout-child.js +64 -39
  505. package/src/hooks/position.js +3 -20
  506. package/src/hooks/test/get-variation-styles-with-ref-values.js +91 -0
  507. package/src/hooks/use-bindings-attributes.js +107 -63
  508. package/src/hooks/utils.js +2 -0
  509. package/src/layouts/constrained.js +53 -4
  510. package/src/layouts/grid.js +148 -51
  511. package/src/private-apis.js +12 -7
  512. package/src/store/actions.js +15 -0
  513. package/src/store/defaults.js +0 -2
  514. package/src/store/defaults.native.js +0 -3
  515. package/src/store/private-keys.js +1 -0
  516. package/src/store/reducer.js +18 -0
  517. package/src/store/selectors.js +10 -0
  518. package/src/style.scss +1 -1
  519. package/src/utils/format-font-style.js +40 -0
  520. package/src/utils/format-font-weight.js +63 -0
  521. package/src/utils/get-editor-region.js +31 -0
  522. package/src/utils/get-font-styles-and-weights.js +191 -0
  523. package/src/utils/pasting.js +5 -12
  524. package/src/utils/test/format-font-style.js +34 -0
  525. package/src/utils/test/format-font-weight.js +66 -0
  526. package/src/utils/test/get-font-styles-and-weights.js +513 -0
  527. package/tsconfig.tsbuildinfo +1 -1
  528. package/build/components/inserter/reusable-block-rename-hint.js +0 -71
  529. package/build/components/inserter/reusable-block-rename-hint.js.map +0 -1
  530. package/build/components/inspector-controls-tabs/settings-tab-hint.js +0 -53
  531. package/build/components/inspector-controls-tabs/settings-tab-hint.js.map +0 -1
  532. package/build-module/components/inserter/reusable-block-rename-hint.js +0 -64
  533. package/build-module/components/inserter/reusable-block-rename-hint.js.map +0 -1
  534. package/build-module/components/inspector-controls-tabs/settings-tab-hint.js +0 -47
  535. package/build-module/components/inspector-controls-tabs/settings-tab-hint.js.map +0 -1
  536. package/src/components/inserter/reusable-block-rename-hint.js +0 -69
  537. package/src/components/inspector-controls-tabs/settings-tab-hint.js +0 -52
  538. package/src/hooks/position.scss +0 -18
@@ -25,7 +25,6 @@ var _useSettings = require("../components/use-settings");
25
25
  var _inspectorControls = _interopRequireDefault(require("../components/inspector-controls"));
26
26
  var _useBlockDisplayInformation = _interopRequireDefault(require("../components/use-block-display-information"));
27
27
  var _utils = require("./utils");
28
- var _lockUnlock = require("../lock-unlock");
29
28
  var _store = require("../store");
30
29
  var _jsxRuntime = require("react/jsx-runtime");
31
30
  /**
@@ -40,30 +39,23 @@ var _jsxRuntime = require("react/jsx-runtime");
40
39
  * Internal dependencies
41
40
  */
42
41
 
43
- const {
44
- CustomSelectControl
45
- } = (0, _lockUnlock.unlock)(_components.privateApis);
46
42
  const POSITION_SUPPORT_KEY = 'position';
47
- const OPTION_CLASSNAME = 'block-editor-hooks__position-selection__select-control__option';
48
43
  const DEFAULT_OPTION = {
49
44
  key: 'default',
50
45
  value: '',
51
- name: (0, _i18n.__)('Default'),
52
- className: OPTION_CLASSNAME
46
+ name: (0, _i18n.__)('Default')
53
47
  };
54
48
  const STICKY_OPTION = {
55
49
  key: 'sticky',
56
50
  value: 'sticky',
57
51
  name: (0, _i18n._x)('Sticky', 'Name for the value of the CSS position property'),
58
- className: OPTION_CLASSNAME,
59
- __experimentalHint: (0, _i18n.__)('The block will stick to the top of the window instead of scrolling.')
52
+ hint: (0, _i18n.__)('The block will stick to the top of the window instead of scrolling.')
60
53
  };
61
54
  const FIXED_OPTION = {
62
55
  key: 'fixed',
63
56
  value: 'fixed',
64
57
  name: (0, _i18n._x)('Fixed', 'Name for the value of the CSS position property'),
65
- className: OPTION_CLASSNAME,
66
- __experimentalHint: (0, _i18n.__)('The block will not move when the page is scrolled.')
58
+ hint: (0, _i18n.__)('The block will not move when the page is scrolled.')
67
59
  };
68
60
  const POSITION_SIDES = ['top', 'right', 'bottom', 'left'];
69
61
  const VALID_POSITION_TYPES = ['sticky', 'fixed'];
@@ -271,12 +263,10 @@ function PositionPanelPure({
271
263
  web: options.length > 1 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_inspectorControls.default, {
272
264
  group: "position",
273
265
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.BaseControl, {
274
- className: "block-editor-hooks__position-selection",
275
266
  __nextHasNoMarginBottom: true,
276
267
  help: stickyHelpText,
277
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(CustomSelectControl, {
268
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.CustomSelectControl, {
278
269
  __next40pxDefaultSize: true,
279
- className: "block-editor-hooks__position-selection__select-control",
280
270
  label: (0, _i18n.__)('Position'),
281
271
  hideLabelFromVision: true,
282
272
  describedBy: (0, _i18n.sprintf)(
@@ -284,7 +274,6 @@ function PositionPanelPure({
284
274
  (0, _i18n.__)('Currently selected position: %s'), selectedOption.name),
285
275
  options: options,
286
276
  value: selectedOption,
287
- __experimentalShowSelectedHint: true,
288
277
  onChange: ({
289
278
  selectedItem
290
279
  }) => {
@@ -1 +1 @@
1
- {"version":3,"names":["_clsx","_interopRequireDefault","require","_i18n","_blocks","_components","_compose","_data","_element","_useSettings","_inspectorControls","_useBlockDisplayInformation","_utils","_lockUnlock","_store","_jsxRuntime","CustomSelectControl","unlock","componentsPrivateApis","POSITION_SUPPORT_KEY","OPTION_CLASSNAME","DEFAULT_OPTION","key","value","name","__","className","STICKY_OPTION","_x","__experimentalHint","FIXED_OPTION","POSITION_SIDES","VALID_POSITION_TYPES","getPositionCSS","selector","style","output","type","positionType","position","includes","forEach","side","undefined","hasStickyPositionSupport","blockType","support","getBlockSupport","sticky","hasFixedPositionSupport","fixed","hasPositionSupport","hasPositionValue","props","attributes","hasStickyOrFixedPositionValue","resetPosition","setAttributes","cleanEmptyObject","top","right","bottom","left","useIsPositionDisabled","blockName","allowFixed","allowSticky","useSettings","isDisabled","PositionPanelPure","clientId","firstParentClientId","useSelect","select","getBlockParents","blockEditorStore","parents","length","blockInformation","useBlockDisplayInformation","stickyHelpText","sprintf","title","options","useMemo","availableOptions","push","onChangeType","next","placementValue","newStyle","selectedOption","find","option","Platform","web","jsx","default","group","children","BaseControl","__nextHasNoMarginBottom","help","__next40pxDefaultSize","label","hideLabelFromVision","describedBy","__experimentalShowSelectedHint","onChange","selectedItem","size","native","_default","exports","edit","Edit","isPositionDisabled","useBlockProps","attributeKeys","hasSupport","hasBlockSupport","hasPositionBlockSupport","allowPositionStyles","id","useInstanceId","positionSelector","css","clsx","useStyleOverride"],"sources":["@wordpress/block-editor/src/hooks/position.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport {\n\tBaseControl,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo, Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../components/use-settings';\nimport InspectorControls from '../components/inspector-controls';\nimport useBlockDisplayInformation from '../components/use-block-display-information';\nimport { cleanEmptyObject, useStyleOverride } from './utils';\nimport { unlock } from '../lock-unlock';\nimport { store as blockEditorStore } from '../store';\n\nconst { CustomSelectControl } = unlock( componentsPrivateApis );\n\nconst POSITION_SUPPORT_KEY = 'position';\n\nconst OPTION_CLASSNAME =\n\t'block-editor-hooks__position-selection__select-control__option';\n\nconst DEFAULT_OPTION = {\n\tkey: 'default',\n\tvalue: '',\n\tname: __( 'Default' ),\n\tclassName: OPTION_CLASSNAME,\n};\n\nconst STICKY_OPTION = {\n\tkey: 'sticky',\n\tvalue: 'sticky',\n\tname: _x( 'Sticky', 'Name for the value of the CSS position property' ),\n\tclassName: OPTION_CLASSNAME,\n\t__experimentalHint: __(\n\t\t'The block will stick to the top of the window instead of scrolling.'\n\t),\n};\n\nconst FIXED_OPTION = {\n\tkey: 'fixed',\n\tvalue: 'fixed',\n\tname: _x( 'Fixed', 'Name for the value of the CSS position property' ),\n\tclassName: OPTION_CLASSNAME,\n\t__experimentalHint: __(\n\t\t'The block will not move when the page is scrolled.'\n\t),\n};\n\nconst POSITION_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nconst VALID_POSITION_TYPES = [ 'sticky', 'fixed' ];\n\n/**\n * Get calculated position CSS.\n *\n * @param {Object} props Component props.\n * @param {string} props.selector Selector to use.\n * @param {Object} props.style Style object.\n * @return {string} The generated CSS rules.\n */\nexport function getPositionCSS( { selector, style } ) {\n\tlet output = '';\n\n\tconst { type: positionType } = style?.position || {};\n\n\tif ( ! VALID_POSITION_TYPES.includes( positionType ) ) {\n\t\treturn output;\n\t}\n\n\toutput += `${ selector } {`;\n\toutput += `position: ${ positionType };`;\n\n\tPOSITION_SIDES.forEach( ( side ) => {\n\t\tif ( style?.position?.[ side ] !== undefined ) {\n\t\t\toutput += `${ side }: ${ style.position[ side ] };`;\n\t\t}\n\t} );\n\n\tif ( positionType === 'sticky' || positionType === 'fixed' ) {\n\t\t// TODO: Replace hard-coded z-index value with a z-index preset approach in theme.json.\n\t\toutput += `z-index: 10`;\n\t}\n\toutput += `}`;\n\n\treturn output;\n}\n\n/**\n * Determines if there is sticky position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasStickyPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.sticky );\n}\n\n/**\n * Determines if there is fixed position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasFixedPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.fixed );\n}\n\n/**\n * Determines if there is position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! support;\n}\n\n/**\n * Checks if there is a current value in the position block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a position value set.\n */\nexport function hasPositionValue( props ) {\n\treturn props.attributes.style?.position?.type !== undefined;\n}\n\n/**\n * Checks if the block is currently set to a sticky or fixed position.\n * This check is helpful for determining how to position block toolbars or other elements.\n *\n * @param {Object} attributes Block attributes.\n * @return {boolean} Whether or not the block is set to a sticky or fixed position.\n */\nexport function hasStickyOrFixedPositionValue( attributes ) {\n\tconst positionType = attributes?.style?.position?.type;\n\treturn positionType === 'sticky' || positionType === 'fixed';\n}\n\n/**\n * Resets the position block support attributes. This can be used when disabling\n * the position support controls for a block via a `ToolsPanel`.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetPosition( { attributes = {}, setAttributes } ) {\n\tconst { style = {} } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: undefined,\n\t\t\t\ttop: undefined,\n\t\t\t\tright: undefined,\n\t\t\t\tbottom: undefined,\n\t\t\t\tleft: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if position settings have been disabled.\n *\n * @param {string} name The name of the block.\n *\n * @return {boolean} Whether padding setting is disabled.\n */\nexport function useIsPositionDisabled( { name: blockName } = {} ) {\n\tconst [ allowFixed, allowSticky ] = useSettings(\n\t\t'position.fixed',\n\t\t'position.sticky'\n\t);\n\tconst isDisabled = ! allowFixed && ! allowSticky;\n\n\treturn ! hasPositionSupport( blockName ) || isDisabled;\n}\n\n/*\n * Position controls rendered in an inspector control panel.\n *\n * @param {Object} props\n *\n * @return {Element} Position panel.\n */\nexport function PositionPanelPure( {\n\tstyle = {},\n\tclientId,\n\tname: blockName,\n\tsetAttributes,\n} ) {\n\tconst allowFixed = hasFixedPositionSupport( blockName );\n\tconst allowSticky = hasStickyPositionSupport( blockName );\n\tconst value = style?.position?.type;\n\n\tconst { firstParentClientId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParents } = select( blockEditorStore );\n\t\t\tconst parents = getBlockParents( clientId );\n\t\t\treturn { firstParentClientId: parents[ parents.length - 1 ] };\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst blockInformation = useBlockDisplayInformation( firstParentClientId );\n\tconst stickyHelpText =\n\t\tallowSticky && value === STICKY_OPTION.value && blockInformation\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %s: the name of the parent block. */\n\t\t\t\t\t__(\n\t\t\t\t\t\t'The block will stick to the scrollable area of the parent %s block.'\n\t\t\t\t\t),\n\t\t\t\t\tblockInformation.title\n\t\t\t )\n\t\t\t: null;\n\n\tconst options = useMemo( () => {\n\t\tconst availableOptions = [ DEFAULT_OPTION ];\n\t\t// Display options if they are allowed, or if a block already has a valid value set.\n\t\t// This allows for a block to be switched off from a position type that is not allowed.\n\t\tif ( allowSticky || value === STICKY_OPTION.value ) {\n\t\t\tavailableOptions.push( STICKY_OPTION );\n\t\t}\n\t\tif ( allowFixed || value === FIXED_OPTION.value ) {\n\t\t\tavailableOptions.push( FIXED_OPTION );\n\t\t}\n\t\treturn availableOptions;\n\t}, [ allowFixed, allowSticky, value ] );\n\n\tconst onChangeType = ( next ) => {\n\t\t// For now, use a hard-coded `0px` value for the position.\n\t\t// `0px` is preferred over `0` as it can be used in `calc()` functions.\n\t\t// In the future, it could be useful to allow for an offset value.\n\t\tconst placementValue = '0px';\n\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: next,\n\t\t\t\ttop:\n\t\t\t\t\tnext === 'sticky' || next === 'fixed'\n\t\t\t\t\t\t? placementValue\n\t\t\t\t\t\t: undefined,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\tconst selectedOption = value\n\t\t? options.find( ( option ) => option.value === value ) || DEFAULT_OPTION\n\t\t: DEFAULT_OPTION;\n\n\t// Only display position controls if there is at least one option to choose from.\n\treturn Platform.select( {\n\t\tweb:\n\t\t\toptions.length > 1 ? (\n\t\t\t\t<InspectorControls group=\"position\">\n\t\t\t\t\t<BaseControl\n\t\t\t\t\t\tclassName=\"block-editor-hooks__position-selection\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\thelp={ stickyHelpText }\n\t\t\t\t\t>\n\t\t\t\t\t\t<CustomSelectControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tclassName=\"block-editor-hooks__position-selection__select-control\"\n\t\t\t\t\t\t\tlabel={ __( 'Position' ) }\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\tdescribedBy={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Currently selected position.\n\t\t\t\t\t\t\t\t__( 'Currently selected position: %s' ),\n\t\t\t\t\t\t\t\tselectedOption.name\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\toptions={ options }\n\t\t\t\t\t\t\tvalue={ selectedOption }\n\t\t\t\t\t\t\t__experimentalShowSelectedHint\n\t\t\t\t\t\t\tonChange={ ( { selectedItem } ) => {\n\t\t\t\t\t\t\t\tonChangeType( selectedItem.value );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BaseControl>\n\t\t\t\t</InspectorControls>\n\t\t\t) : null,\n\t\tnative: null,\n\t} );\n}\n\nexport default {\n\tedit: function Edit( props ) {\n\t\tconst isPositionDisabled = useIsPositionDisabled( props );\n\t\tif ( isPositionDisabled ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn <PositionPanelPure { ...props } />;\n\t},\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, POSITION_SUPPORT_KEY );\n\t},\n};\n\nfunction useBlockProps( { name, style } ) {\n\tconst hasPositionBlockSupport = hasBlockSupport(\n\t\tname,\n\t\tPOSITION_SUPPORT_KEY\n\t);\n\tconst isPositionDisabled = useIsPositionDisabled( { name } );\n\tconst allowPositionStyles = hasPositionBlockSupport && ! isPositionDisabled;\n\n\tconst id = useInstanceId( useBlockProps );\n\n\t// Higher specificity to override defaults in editor UI.\n\tconst positionSelector = `.wp-container-${ id }.wp-container-${ id }`;\n\n\t// Get CSS string for the current position values.\n\tlet css;\n\tif ( allowPositionStyles ) {\n\t\tcss =\n\t\t\tgetPositionCSS( {\n\t\t\t\tselector: positionSelector,\n\t\t\t\tstyle,\n\t\t\t} ) || '';\n\t}\n\n\t// Attach a `wp-container-` id-based class name.\n\tconst className = clsx( {\n\t\t[ `wp-container-${ id }` ]: allowPositionStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t[ `is-position-${ style?.position?.type }` ]:\n\t\t\tallowPositionStyles && !! css && !! style?.position?.type,\n\t} );\n\n\tuseStyleOverride( { css } );\n\n\treturn { className };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAIA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAKA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,2BAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,WAAA,GAAAX,OAAA;AACA,IAAAY,MAAA,GAAAZ,OAAA;AAAqD,IAAAa,WAAA,GAAAb,OAAA;AA1BrD;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;;AAQA,MAAM;EAAEc;AAAoB,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;AAE/D,MAAMC,oBAAoB,GAAG,UAAU;AAEvC,MAAMC,gBAAgB,GACrB,gEAAgE;AAEjE,MAAMC,cAAc,GAAG;EACtBC,GAAG,EAAE,SAAS;EACdC,KAAK,EAAE,EAAE;EACTC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Ae3F,KAAK,EAAEI,QAAQ,EAAEF,IAAM,EAAC,GACzCqF,mBAAmB,IAAI,CAAC,CAAEI,GAAG,IAAI,CAAC,CAAE3F,KAAK,EAAEI,QAAQ,EAAEF;EACvD,CAAE,CAAC;EAEH,IAAA2F,uBAAgB,EAAE;IAAEF;EAAI,CAAE,CAAC;EAE3B,OAAO;IAAEpG;EAAU,CAAC;AACrB","ignoreList":[]}
1
+ {"version":3,"names":["_clsx","_interopRequireDefault","require","_i18n","_blocks","_components","_compose","_data","_element","_useSettings","_inspectorControls","_useBlockDisplayInformation","_utils","_store","_jsxRuntime","POSITION_SUPPORT_KEY","DEFAULT_OPTION","key","value","name","__","STICKY_OPTION","_x","hint","FIXED_OPTION","POSITION_SIDES","VALID_POSITION_TYPES","getPositionCSS","selector","style","output","type","positionType","position","includes","forEach","side","undefined","hasStickyPositionSupport","blockType","support","getBlockSupport","sticky","hasFixedPositionSupport","fixed","hasPositionSupport","hasPositionValue","props","attributes","hasStickyOrFixedPositionValue","resetPosition","setAttributes","cleanEmptyObject","top","right","bottom","left","useIsPositionDisabled","blockName","allowFixed","allowSticky","useSettings","isDisabled","PositionPanelPure","clientId","firstParentClientId","useSelect","select","getBlockParents","blockEditorStore","parents","length","blockInformation","useBlockDisplayInformation","stickyHelpText","sprintf","title","options","useMemo","availableOptions","push","onChangeType","next","placementValue","newStyle","selectedOption","find","option","Platform","web","jsx","default","group","children","BaseControl","__nextHasNoMarginBottom","help","CustomSelectControl","__next40pxDefaultSize","label","hideLabelFromVision","describedBy","onChange","selectedItem","size","native","_default","exports","edit","Edit","isPositionDisabled","useBlockProps","attributeKeys","hasSupport","hasBlockSupport","hasPositionBlockSupport","allowPositionStyles","id","useInstanceId","positionSelector","css","className","clsx","useStyleOverride"],"sources":["@wordpress/block-editor/src/hooks/position.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { BaseControl, CustomSelectControl } from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo, Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../components/use-settings';\nimport InspectorControls from '../components/inspector-controls';\nimport useBlockDisplayInformation from '../components/use-block-display-information';\nimport { cleanEmptyObject, useStyleOverride } from './utils';\nimport { store as blockEditorStore } from '../store';\n\nconst POSITION_SUPPORT_KEY = 'position';\n\nconst DEFAULT_OPTION = {\n\tkey: 'default',\n\tvalue: '',\n\tname: __( 'Default' ),\n};\n\nconst STICKY_OPTION = {\n\tkey: 'sticky',\n\tvalue: 'sticky',\n\tname: _x( 'Sticky', 'Name for the value of the CSS position property' ),\n\thint: __(\n\t\t'The block will stick to the top of the window instead of scrolling.'\n\t),\n};\n\nconst FIXED_OPTION = {\n\tkey: 'fixed',\n\tvalue: 'fixed',\n\tname: _x( 'Fixed', 'Name for the value of the CSS position property' ),\n\thint: __( 'The block will not move when the page is scrolled.' ),\n};\n\nconst POSITION_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nconst VALID_POSITION_TYPES = [ 'sticky', 'fixed' ];\n\n/**\n * Get calculated position CSS.\n *\n * @param {Object} props Component props.\n * @param {string} props.selector Selector to use.\n * @param {Object} props.style Style object.\n * @return {string} The generated CSS rules.\n */\nexport function getPositionCSS( { selector, style } ) {\n\tlet output = '';\n\n\tconst { type: positionType } = style?.position || {};\n\n\tif ( ! VALID_POSITION_TYPES.includes( positionType ) ) {\n\t\treturn output;\n\t}\n\n\toutput += `${ selector } {`;\n\toutput += `position: ${ positionType };`;\n\n\tPOSITION_SIDES.forEach( ( side ) => {\n\t\tif ( style?.position?.[ side ] !== undefined ) {\n\t\t\toutput += `${ side }: ${ style.position[ side ] };`;\n\t\t}\n\t} );\n\n\tif ( positionType === 'sticky' || positionType === 'fixed' ) {\n\t\t// TODO: Replace hard-coded z-index value with a z-index preset approach in theme.json.\n\t\toutput += `z-index: 10`;\n\t}\n\toutput += `}`;\n\n\treturn output;\n}\n\n/**\n * Determines if there is sticky position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasStickyPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.sticky );\n}\n\n/**\n * Determines if there is fixed position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasFixedPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.fixed );\n}\n\n/**\n * Determines if there is position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! support;\n}\n\n/**\n * Checks if there is a current value in the position block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a position value set.\n */\nexport function hasPositionValue( props ) {\n\treturn props.attributes.style?.position?.type !== undefined;\n}\n\n/**\n * Checks if the block is currently set to a sticky or fixed position.\n * This check is helpful for determining how to position block toolbars or other elements.\n *\n * @param {Object} attributes Block attributes.\n * @return {boolean} Whether or not the block is set to a sticky or fixed position.\n */\nexport function hasStickyOrFixedPositionValue( attributes ) {\n\tconst positionType = attributes?.style?.position?.type;\n\treturn positionType === 'sticky' || positionType === 'fixed';\n}\n\n/**\n * Resets the position block support attributes. This can be used when disabling\n * the position support controls for a block via a `ToolsPanel`.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetPosition( { attributes = {}, setAttributes } ) {\n\tconst { style = {} } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: undefined,\n\t\t\t\ttop: undefined,\n\t\t\t\tright: undefined,\n\t\t\t\tbottom: undefined,\n\t\t\t\tleft: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if position settings have been disabled.\n *\n * @param {string} name The name of the block.\n *\n * @return {boolean} Whether padding setting is disabled.\n */\nexport function useIsPositionDisabled( { name: blockName } = {} ) {\n\tconst [ allowFixed, allowSticky ] = useSettings(\n\t\t'position.fixed',\n\t\t'position.sticky'\n\t);\n\tconst isDisabled = ! allowFixed && ! allowSticky;\n\n\treturn ! hasPositionSupport( blockName ) || isDisabled;\n}\n\n/*\n * Position controls rendered in an inspector control panel.\n *\n * @param {Object} props\n *\n * @return {Element} Position panel.\n */\nexport function PositionPanelPure( {\n\tstyle = {},\n\tclientId,\n\tname: blockName,\n\tsetAttributes,\n} ) {\n\tconst allowFixed = hasFixedPositionSupport( blockName );\n\tconst allowSticky = hasStickyPositionSupport( blockName );\n\tconst value = style?.position?.type;\n\n\tconst { firstParentClientId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParents } = select( blockEditorStore );\n\t\t\tconst parents = getBlockParents( clientId );\n\t\t\treturn { firstParentClientId: parents[ parents.length - 1 ] };\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst blockInformation = useBlockDisplayInformation( firstParentClientId );\n\tconst stickyHelpText =\n\t\tallowSticky && value === STICKY_OPTION.value && blockInformation\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %s: the name of the parent block. */\n\t\t\t\t\t__(\n\t\t\t\t\t\t'The block will stick to the scrollable area of the parent %s block.'\n\t\t\t\t\t),\n\t\t\t\t\tblockInformation.title\n\t\t\t )\n\t\t\t: null;\n\n\tconst options = useMemo( () => {\n\t\tconst availableOptions = [ DEFAULT_OPTION ];\n\t\t// Display options if they are allowed, or if a block already has a valid value set.\n\t\t// This allows for a block to be switched off from a position type that is not allowed.\n\t\tif ( allowSticky || value === STICKY_OPTION.value ) {\n\t\t\tavailableOptions.push( STICKY_OPTION );\n\t\t}\n\t\tif ( allowFixed || value === FIXED_OPTION.value ) {\n\t\t\tavailableOptions.push( FIXED_OPTION );\n\t\t}\n\t\treturn availableOptions;\n\t}, [ allowFixed, allowSticky, value ] );\n\n\tconst onChangeType = ( next ) => {\n\t\t// For now, use a hard-coded `0px` value for the position.\n\t\t// `0px` is preferred over `0` as it can be used in `calc()` functions.\n\t\t// In the future, it could be useful to allow for an offset value.\n\t\tconst placementValue = '0px';\n\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: next,\n\t\t\t\ttop:\n\t\t\t\t\tnext === 'sticky' || next === 'fixed'\n\t\t\t\t\t\t? placementValue\n\t\t\t\t\t\t: undefined,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\tconst selectedOption = value\n\t\t? options.find( ( option ) => option.value === value ) || DEFAULT_OPTION\n\t\t: DEFAULT_OPTION;\n\n\t// Only display position controls if there is at least one option to choose from.\n\treturn Platform.select( {\n\t\tweb:\n\t\t\toptions.length > 1 ? (\n\t\t\t\t<InspectorControls group=\"position\">\n\t\t\t\t\t<BaseControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\thelp={ stickyHelpText }\n\t\t\t\t\t>\n\t\t\t\t\t\t<CustomSelectControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tlabel={ __( 'Position' ) }\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\tdescribedBy={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Currently selected position.\n\t\t\t\t\t\t\t\t__( 'Currently selected position: %s' ),\n\t\t\t\t\t\t\t\tselectedOption.name\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\toptions={ options }\n\t\t\t\t\t\t\tvalue={ selectedOption }\n\t\t\t\t\t\t\tonChange={ ( { selectedItem } ) => {\n\t\t\t\t\t\t\t\tonChangeType( selectedItem.value );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BaseControl>\n\t\t\t\t</InspectorControls>\n\t\t\t) : null,\n\t\tnative: null,\n\t} );\n}\n\nexport default {\n\tedit: function Edit( props ) {\n\t\tconst isPositionDisabled = useIsPositionDisabled( props );\n\t\tif ( isPositionDisabled ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn <PositionPanelPure { ...props } />;\n\t},\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, POSITION_SUPPORT_KEY );\n\t},\n};\n\nfunction useBlockProps( { name, style } ) {\n\tconst hasPositionBlockSupport = hasBlockSupport(\n\t\tname,\n\t\tPOSITION_SUPPORT_KEY\n\t);\n\tconst isPositionDisabled = useIsPositionDisabled( { name } );\n\tconst allowPositionStyles = hasPositionBlockSupport && ! isPositionDisabled;\n\n\tconst id = useInstanceId( useBlockProps );\n\n\t// Higher specificity to override defaults in editor UI.\n\tconst positionSelector = `.wp-container-${ id }.wp-container-${ id }`;\n\n\t// Get CSS string for the current position values.\n\tlet css;\n\tif ( allowPositionStyles ) {\n\t\tcss =\n\t\t\tgetPositionCSS( {\n\t\t\t\tselector: positionSelector,\n\t\t\t\tstyle,\n\t\t\t} ) || '';\n\t}\n\n\t// Attach a `wp-container-` id-based class name.\n\tconst className = clsx( {\n\t\t[ `wp-container-${ id }` ]: allowPositionStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t[ `is-position-${ style?.position?.type }` ]:\n\t\t\tallowPositionStyles && !! css && !! style?.position?.type,\n\t} );\n\n\tuseStyleOverride( { css } );\n\n\treturn { className };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAGA,IA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B,IAAI,CAAEL,kBAAkB;EAE3E,MAAMO,EAAE,GAAG,IAAAC,sBAAa,EAAEP,aAAc,CAAC;;EAEzC;EACA,MAAMQ,gBAAgB,GAAI,iBAAiBF,EAAI,iBAAiBA,EAAI,EAAC;;EAErE;EACA,IAAIG,GAAG;EACP,IAAKJ,mBAAmB,EAAG;IAC1BI,GAAG,GACF7F,cAAc,CAAE;MACfC,QAAQ,EAAE2F,gBAAgB;MAC1B1F;IACD,CAAE,CAAC,IAAI,EAAE;EACX;;EAEA;EACA,MAAM4F,SAAS,GAAG,IAAAC,aAAI,EAAE;IACvB,CAAG,gBAAgBL,EAAI,EAAC,GAAID,mBAAmB,IAAI,CAAC,CAAEI,GAAG;IAAE;IAC3D,CAAG,eAAe3F,KAAK,EAAEI,QAAQ,EAAEF,IAAM,EAAC,GACzCqF,mBAAmB,IAAI,CAAC,CAAEI,GAAG,IAAI,CAAC,CAAE3F,KAAK,EAAEI,QAAQ,EAAEF;EACvD,CAAE,CAAC;EAEH,IAAA4F,uBAAgB,EAAE;IAAEH;EAAI,CAAE,CAAC;EAE3B,OAAO;IAAEC;EAAU,CAAC;AACrB","ignoreList":[]}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
@@ -12,6 +13,7 @@ var _data = require("@wordpress/data");
12
13
  var _element = require("@wordpress/element");
13
14
  var _hooks = require("@wordpress/hooks");
14
15
  var _lockUnlock = require("../lock-unlock");
16
+ var _blockContext = _interopRequireDefault(require("../components/block-context"));
15
17
  var _jsxRuntime = require("react/jsx-runtime");
16
18
  /**
17
19
  * WordPress dependencies
@@ -90,105 +92,144 @@ function canBindAttribute(blockName, attributeName) {
90
92
  }
91
93
  const withBlockBindingSupport = exports.withBlockBindingSupport = (0, _compose.createHigherOrderComponent)(BlockEdit => props => {
92
94
  const registry = (0, _data.useRegistry)();
95
+ const blockContext = (0, _element.useContext)(_blockContext.default);
93
96
  const sources = (0, _data.useSelect)(select => (0, _lockUnlock.unlock)(select(_blocks.store)).getAllBlockBindingsSources());
94
97
  const {
95
98
  name,
96
- clientId,
97
- context
99
+ clientId
98
100
  } = props;
101
+ const hasParentPattern = !!props.context['pattern/overrides'];
99
102
  const hasPatternOverridesDefaultBinding = props.attributes.metadata?.bindings?.[DEFAULT_ATTRIBUTE]?.source === 'core/pattern-overrides';
100
- const bindings = (0, _element.useMemo)(() => replacePatternOverrideDefaultBindings(name, props.attributes.metadata?.bindings), [props.attributes.metadata?.bindings, name]);
103
+ const blockBindings = (0, _element.useMemo)(() => replacePatternOverrideDefaultBindings(name, props.attributes.metadata?.bindings), [props.attributes.metadata?.bindings, name]);
104
+
105
+ // While this hook doesn't directly call any selectors, `useSelect` is
106
+ // used purposely here to ensure `boundAttributes` is updated whenever
107
+ // there are attribute updates.
108
+ // `source.getValues` may also call a selector via `registry.select`.
101
109
  const boundAttributes = (0, _data.useSelect)(() => {
102
- if (!bindings) {
110
+ if (!blockBindings) {
103
111
  return;
104
112
  }
105
113
  const attributes = {};
106
- for (const [attributeName, boundAttribute] of Object.entries(bindings)) {
107
- const source = sources[boundAttribute.source];
108
- if (!source?.getValue || !canBindAttribute(name, attributeName)) {
114
+ const blockBindingsBySource = new Map();
115
+ for (const [attributeName, binding] of Object.entries(blockBindings)) {
116
+ const {
117
+ source: sourceName,
118
+ args: sourceArgs
119
+ } = binding;
120
+ const source = sources[sourceName];
121
+ if (!source?.getValues || !canBindAttribute(name, attributeName)) {
109
122
  continue;
110
123
  }
111
- const args = {
112
- registry,
113
- context,
114
- clientId,
115
- attributeName,
116
- args: boundAttribute.args
117
- };
118
- attributes[attributeName] = source.getValue(args);
119
- if (attributes[attributeName] === undefined) {
120
- if (attributeName === 'url') {
121
- attributes[attributeName] = null;
122
- } else {
123
- attributes[attributeName] = source.getPlaceholder?.(args);
124
+ blockBindingsBySource.set(source, {
125
+ ...blockBindingsBySource.get(source),
126
+ [attributeName]: {
127
+ args: sourceArgs
128
+ }
129
+ });
130
+ }
131
+ if (blockBindingsBySource.size) {
132
+ for (const [source, bindings] of blockBindingsBySource) {
133
+ // Populate context.
134
+ const context = {};
135
+ if (source.usesContext?.length) {
136
+ for (const key of source.usesContext) {
137
+ context[key] = blockContext[key];
138
+ }
139
+ }
140
+
141
+ // Get values in batch if the source supports it.
142
+ const values = source.getValues({
143
+ registry,
144
+ context,
145
+ clientId,
146
+ bindings
147
+ });
148
+ for (const [attributeName, value] of Object.entries(values)) {
149
+ // Use placeholder when value is undefined.
150
+ if (value === undefined) {
151
+ if (attributeName === 'url') {
152
+ attributes[attributeName] = null;
153
+ } else {
154
+ attributes[attributeName] = source.getPlaceholder?.({
155
+ registry,
156
+ context,
157
+ clientId,
158
+ attributeName,
159
+ args: bindings[attributeName].args
160
+ });
161
+ }
162
+ } else {
163
+ attributes[attributeName] = value;
164
+ }
124
165
  }
125
166
  }
126
167
  }
127
168
  return attributes;
128
- }, [bindings, name, clientId, context, registry, sources]);
169
+ }, [blockBindings, name, clientId, blockContext, registry, sources]);
129
170
  const {
130
171
  setAttributes
131
172
  } = props;
132
173
  const _setAttributes = (0, _element.useCallback)(nextAttributes => {
133
174
  registry.batch(() => {
134
- if (!bindings) {
175
+ if (!blockBindings) {
135
176
  setAttributes(nextAttributes);
136
177
  return;
137
178
  }
138
179
  const keptAttributes = {
139
180
  ...nextAttributes
140
181
  };
141
- const updatesBySource = new Map();
182
+ const blockBindingsBySource = new Map();
142
183
 
143
184
  // Loop only over the updated attributes to avoid modifying the bound ones that haven't changed.
144
185
  for (const [attributeName, newValue] of Object.entries(keptAttributes)) {
145
- if (!bindings[attributeName] || !canBindAttribute(name, attributeName)) {
186
+ if (!blockBindings[attributeName] || !canBindAttribute(name, attributeName)) {
146
187
  continue;
147
188
  }
148
- const binding = bindings[attributeName];
189
+ const binding = blockBindings[attributeName];
149
190
  const source = sources[binding?.source];
150
- if (!source?.setValue && !source?.setValues) {
191
+ if (!source?.setValues) {
151
192
  continue;
152
193
  }
153
- updatesBySource.set(source, {
154
- ...updatesBySource.get(source),
155
- [attributeName]: newValue
194
+ blockBindingsBySource.set(source, {
195
+ ...blockBindingsBySource.get(source),
196
+ [attributeName]: {
197
+ args: binding.args,
198
+ newValue
199
+ }
156
200
  });
157
201
  delete keptAttributes[attributeName];
158
202
  }
159
- if (updatesBySource.size) {
160
- for (const [source, attributes] of updatesBySource) {
161
- if (source.setValues) {
162
- source.setValues({
163
- registry,
164
- context,
165
- clientId,
166
- attributes
167
- });
168
- } else {
169
- for (const [attributeName, value] of Object.entries(attributes)) {
170
- const binding = bindings[attributeName];
171
- source.setValue({
172
- registry,
173
- context,
174
- clientId,
175
- attributeName,
176
- args: binding.args,
177
- value
178
- });
203
+ if (blockBindingsBySource.size) {
204
+ for (const [source, bindings] of blockBindingsBySource) {
205
+ // Populate context.
206
+ const context = {};
207
+ if (source.usesContext?.length) {
208
+ for (const key of source.usesContext) {
209
+ context[key] = blockContext[key];
179
210
  }
180
211
  }
212
+ source.setValues({
213
+ registry,
214
+ context,
215
+ clientId,
216
+ bindings
217
+ });
181
218
  }
182
219
  }
183
-
184
- // Only apply normal attribute updates to blocks
185
- // that have partial bindings. Currently this is
186
- // only skipped for pattern overrides sources.
187
- if (!hasPatternOverridesDefaultBinding && Object.keys(keptAttributes).length) {
220
+ if (
221
+ // Don't update non-connected attributes if the block is using pattern overrides
222
+ // and the editing is happening while overriding the pattern (not editing the original).
223
+ !(hasPatternOverridesDefaultBinding && hasParentPattern) && Object.keys(keptAttributes).length) {
224
+ // Don't update caption and href until they are supported.
225
+ if (hasPatternOverridesDefaultBinding) {
226
+ delete keptAttributes?.caption;
227
+ delete keptAttributes?.href;
228
+ }
188
229
  setAttributes(keptAttributes);
189
230
  }
190
231
  });
191
- }, [registry, bindings, name, clientId, context, setAttributes, sources, hasPatternOverridesDefaultBinding]);
232
+ }, [registry, blockBindings, name, clientId, blockContext, setAttributes, sources, hasPatternOverridesDefaultBinding, hasParentPattern]);
192
233
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
193
234
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(BlockEdit, {
194
235
  ...props,
@@ -1 +1 @@
1
- {"version":3,"names":["_blocks","require","_compose","_data","_element","_hooks","_lockUnlock","_jsxRuntime","BLOCK_BINDINGS_ALLOWED_BLOCKS","DEFAULT_ATTRIBUTE","replacePatternOverrideDefaultBindings","blockName","bindings","source","supportedAttributes","bindingsWithDefaults","attributeName","bindingSource","canBindBlock","canBindAttribute","includes","withBlockBindingSupport","exports","createHigherOrderComponent","BlockEdit","props","registry","useRegistry","sources","useSelect","select","unlock","blocksStore","getAllBlockBindingsSources","name","clientId","context","hasPatternOverridesDefaultBinding","attributes","metadata","useMemo","boundAttributes","boundAttribute","Object","entries","getValue","args","undefined","getPlaceholder","setAttributes","_setAttributes","useCallback","nextAttributes","batch","keptAttributes","updatesBySource","Map","newValue","binding","setValue","setValues","set","get","size","value","keys","length","jsx","Fragment","children","shimAttributeSource","settings","edit","addFilter"],"sources":["@wordpress/block-editor/src/hooks/use-bindings-attributes.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\n/** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */\n/** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */\n\n/**\n * Given a binding of block attributes, returns a higher order component that\n * overrides its `attributes` and `setAttributes` props to sync any changes needed.\n *\n * @return {WPHigherOrderComponent} Higher-order component.\n */\n\nconst BLOCK_BINDINGS_ALLOWED_BLOCKS = {\n\t'core/paragraph': [ 'content' ],\n\t'core/heading': [ 'content' ],\n\t'core/image': [ 'id', 'url', 'title', 'alt' ],\n\t'core/button': [ 'url', 'text', 'linkTarget', 'rel' ],\n};\n\nconst DEFAULT_ATTRIBUTE = '__default';\n\n/**\n * Returns the bindings with the `__default` binding for pattern overrides\n * replaced with the full-set of supported attributes. e.g.:\n *\n * bindings passed in: `{ __default: { source: 'core/pattern-overrides' } }`\n * bindings returned: `{ content: { source: 'core/pattern-overrides' } }`\n *\n * @param {string} blockName The block name (e.g. 'core/paragraph').\n * @param {Object} bindings A block's bindings from the metadata attribute.\n *\n * @return {Object} The bindings with default replaced for pattern overrides.\n */\nfunction replacePatternOverrideDefaultBindings( blockName, bindings ) {\n\t// The `__default` binding currently only works for pattern overrides.\n\tif (\n\t\tbindings?.[ DEFAULT_ATTRIBUTE ]?.source === 'core/pattern-overrides'\n\t) {\n\t\tconst supportedAttributes = BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];\n\t\tconst bindingsWithDefaults = {};\n\t\tfor ( const attributeName of supportedAttributes ) {\n\t\t\t// If the block has mixed binding sources, retain any non pattern override bindings.\n\t\t\tconst bindingSource = bindings[ attributeName ]\n\t\t\t\t? bindings[ attributeName ]\n\t\t\t\t: { source: 'core/pattern-overrides' };\n\t\t\tbindingsWithDefaults[ attributeName ] = bindingSource;\n\t\t}\n\n\t\treturn bindingsWithDefaults;\n\t}\n\n\treturn bindings;\n}\n\n/**\n * Based on the given block name,\n * check if it is possible to bind the block.\n *\n * @param {string} blockName - The block name.\n * @return {boolean} Whether it is possible to bind the block to sources.\n */\nexport function canBindBlock( blockName ) {\n\treturn blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS;\n}\n\n/**\n * Based on the given block name and attribute name,\n * check if it is possible to bind the block attribute.\n *\n * @param {string} blockName - The block name.\n * @param {string} attributeName - The attribute name.\n * @return {boolean} Whether it is possible to bind the block attribute.\n */\nexport function canBindAttribute( blockName, attributeName ) {\n\treturn (\n\t\tcanBindBlock( blockName ) &&\n\t\tBLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ].includes( attributeName )\n\t);\n}\n\nexport const withBlockBindingSupport = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst registry = useRegistry();\n\t\tconst sources = useSelect( ( select ) =>\n\t\t\tunlock( select( blocksStore ) ).getAllBlockBindingsSources()\n\t\t);\n\t\tconst { name, clientId, context } = props;\n\t\tconst hasPatternOverridesDefaultBinding =\n\t\t\tprops.attributes.metadata?.bindings?.[ DEFAULT_ATTRIBUTE ]\n\t\t\t\t?.source === 'core/pattern-overrides';\n\t\tconst bindings = useMemo(\n\t\t\t() =>\n\t\t\t\treplacePatternOverrideDefaultBindings(\n\t\t\t\t\tname,\n\t\t\t\t\tprops.attributes.metadata?.bindings\n\t\t\t\t),\n\t\t\t[ props.attributes.metadata?.bindings, name ]\n\t\t);\n\t\tconst boundAttributes = useSelect( () => {\n\t\t\tif ( ! bindings ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst attributes = {};\n\n\t\t\tfor ( const [ attributeName, boundAttribute ] of Object.entries(\n\t\t\t\tbindings\n\t\t\t) ) {\n\t\t\t\tconst source = sources[ boundAttribute.source ];\n\t\t\t\tif (\n\t\t\t\t\t! source?.getValue ||\n\t\t\t\t\t! canBindAttribute( name, attributeName )\n\t\t\t\t) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst args = {\n\t\t\t\t\tregistry,\n\t\t\t\t\tcontext,\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeName,\n\t\t\t\t\targs: boundAttribute.args,\n\t\t\t\t};\n\n\t\t\t\tattributes[ attributeName ] = source.getValue( args );\n\n\t\t\t\tif ( attributes[ attributeName ] === undefined ) {\n\t\t\t\t\tif ( attributeName === 'url' ) {\n\t\t\t\t\t\tattributes[ attributeName ] = null;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tattributes[ attributeName ] =\n\t\t\t\t\t\t\tsource.getPlaceholder?.( args );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn attributes;\n\t\t}, [ bindings, name, clientId, context, registry, sources ] );\n\n\t\tconst { setAttributes } = props;\n\n\t\tconst _setAttributes = useCallback(\n\t\t\t( nextAttributes ) => {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tif ( ! bindings ) {\n\t\t\t\t\t\tsetAttributes( nextAttributes );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst keptAttributes = { ...nextAttributes };\n\t\t\t\t\tconst updatesBySource = new Map();\n\n\t\t\t\t\t// Loop only over the updated attributes to avoid modifying the bound ones that haven't changed.\n\t\t\t\t\tfor ( const [ attributeName, newValue ] of Object.entries(\n\t\t\t\t\t\tkeptAttributes\n\t\t\t\t\t) ) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t! bindings[ attributeName ] ||\n\t\t\t\t\t\t\t! canBindAttribute( name, attributeName )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst binding = bindings[ attributeName ];\n\t\t\t\t\t\tconst source = sources[ binding?.source ];\n\t\t\t\t\t\tif ( ! source?.setValue && ! source?.setValues ) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tupdatesBySource.set( source, {\n\t\t\t\t\t\t\t...updatesBySource.get( source ),\n\t\t\t\t\t\t\t[ attributeName ]: newValue,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tdelete keptAttributes[ attributeName ];\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( updatesBySource.size ) {\n\t\t\t\t\t\tfor ( const [\n\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t\tattributes,\n\t\t\t\t\t\t] of updatesBySource ) {\n\t\t\t\t\t\t\tif ( source.setValues ) {\n\t\t\t\t\t\t\t\tsource.setValues( {\n\t\t\t\t\t\t\t\t\tregistry,\n\t\t\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\t\tattributes,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tfor ( const [\n\t\t\t\t\t\t\t\t\tattributeName,\n\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t] of Object.entries( attributes ) ) {\n\t\t\t\t\t\t\t\t\tconst binding = bindings[ attributeName ];\n\t\t\t\t\t\t\t\t\tsource.setValue( {\n\t\t\t\t\t\t\t\t\t\tregistry,\n\t\t\t\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\t\t\tattributeName,\n\t\t\t\t\t\t\t\t\t\targs: binding.args,\n\t\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Only apply normal attribute updates to blocks\n\t\t\t\t\t// that have partial bindings. Currently this is\n\t\t\t\t\t// only skipped for pattern overrides sources.\n\t\t\t\t\tif (\n\t\t\t\t\t\t! hasPatternOverridesDefaultBinding &&\n\t\t\t\t\t\tObject.keys( keptAttributes ).length\n\t\t\t\t\t) {\n\t\t\t\t\t\tsetAttributes( keptAttributes );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[\n\t\t\t\tregistry,\n\t\t\t\tbindings,\n\t\t\t\tname,\n\t\t\t\tclientId,\n\t\t\t\tcontext,\n\t\t\t\tsetAttributes,\n\t\t\t\tsources,\n\t\t\t\thasPatternOverridesDefaultBinding,\n\t\t\t]\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tattributes={ { ...props.attributes, ...boundAttributes } }\n\t\t\t\t\tsetAttributes={ _setAttributes }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n\t'withBlockBindingSupport'\n);\n\n/**\n * Filters a registered block's settings to enhance a block's `edit` component\n * to upgrade bound attributes.\n *\n * @param {WPBlockSettings} settings - Registered block settings.\n * @param {string} name - Block name.\n * @return {WPBlockSettings} Filtered block settings.\n */\nfunction shimAttributeSource( settings, name ) {\n\tif ( ! canBindBlock( name ) ) {\n\t\treturn settings;\n\t}\n\n\treturn {\n\t\t...settings,\n\t\tedit: withBlockBindingSupport( settings.edit ),\n\t};\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/custom-sources-backwards-compatibility/shim-attribute-source',\n\tshimAttributeSource\n);\n"],"mappings":";;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAKA,IAAAK,WAAA,GAAAL,OAAA;AAAwC,IAAAM,WAAA,GAAAN,OAAA;AAZxC;AACA;AACA;;AAOA;AACA;AACA;;AAGA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAEA,MAAMO,6BAA6B,GAAG;EACrC,gBAAgB,EAAE,CAAE,SAAS,CAAE;EAC/B,cAAc,EAAE,CAAE,SAAS,CAAE;EAC7B,YAAY,EAAE,CAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAE;EAC7C,aAAa,EAAE,CAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK;AACpD,CAAC;AAED,MAAMC,iBAAiB,GAAG,WAAW;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,qCAAqCA,CAAEC,SAAS,EAAEC,QAAQ,EAAG;EACrE;EACA,IACCA,QAAQ,GAAIH,iBAAiB,CAAE,EAAEI,MAAM,KAAK,wBAAwB,EACnE;IACD,M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B,EAC1B,0EAA0E,EAC1EH,mBACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_blocks","require","_compose","_data","_element","_hooks","_lockUnlock","_blockContext","_interopRequireDefault","_jsxRuntime","BLOCK_BINDINGS_ALLOWED_BLOCKS","DEFAULT_ATTRIBUTE","replacePatternOverrideDefaultBindings","blockName","bindings","source","supportedAttributes","bindingsWithDefaults","attributeName","bindingSource","canBindBlock","canBindAttribute","includes","withBlockBindingSupport","exports","createHigherOrderComponent","BlockEdit","props","registry","useRegistry","blockContext","useContext","BlockContext","sources","useSelect","select","unlock","blocksStore","getAllBlockBindingsSources","name","clientId","hasParentPattern","context","hasPatternOverridesDefaultBinding","attributes","metadata","blockBindings","useMemo","boundAttributes","blockBindingsBySource","Map","binding","Object","entries","sourceName","args","sourceArgs","getValues","set","get","size","usesContext","length","key","values","value","undefined","getPlaceholder","setAttributes","_setAttributes","useCallback","nextAttributes","batch","keptAttributes","newValue","setValues","keys","caption","href","jsx","Fragment","children","shimAttributeSource","settings","edit","addFilter"],"sources":["@wordpress/block-editor/src/hooks/use-bindings-attributes.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useCallback, useMemo, useContext } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport BlockContext from '../components/block-context';\n\n/** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */\n/** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */\n\n/**\n * Given a binding of block attributes, returns a higher order component that\n * overrides its `attributes` and `setAttributes` props to sync any changes needed.\n *\n * @return {WPHigherOrderComponent} Higher-order component.\n */\n\nconst BLOCK_BINDINGS_ALLOWED_BLOCKS = {\n\t'core/paragraph': [ 'content' ],\n\t'core/heading': [ 'content' ],\n\t'core/image': [ 'id', 'url', 'title', 'alt' ],\n\t'core/button': [ 'url', 'text', 'linkTarget', 'rel' ],\n};\n\nconst DEFAULT_ATTRIBUTE = '__default';\n\n/**\n * Returns the bindings with the `__default` binding for pattern overrides\n * replaced with the full-set of supported attributes. e.g.:\n *\n * bindings passed in: `{ __default: { source: 'core/pattern-overrides' } }`\n * bindings returned: `{ content: { source: 'core/pattern-overrides' } }`\n *\n * @param {string} blockName The block name (e.g. 'core/paragraph').\n * @param {Object} bindings A block's bindings from the metadata attribute.\n *\n * @return {Object} The bindings with default replaced for pattern overrides.\n */\nfunction replacePatternOverrideDefaultBindings( blockName, bindings ) {\n\t// The `__default` binding currently only works for pattern overrides.\n\tif (\n\t\tbindings?.[ DEFAULT_ATTRIBUTE ]?.source === 'core/pattern-overrides'\n\t) {\n\t\tconst supportedAttributes = BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];\n\t\tconst bindingsWithDefaults = {};\n\t\tfor ( const attributeName of supportedAttributes ) {\n\t\t\t// If the block has mixed binding sources, retain any non pattern override bindings.\n\t\t\tconst bindingSource = bindings[ attributeName ]\n\t\t\t\t? bindings[ attributeName ]\n\t\t\t\t: { source: 'core/pattern-overrides' };\n\t\t\tbindingsWithDefaults[ attributeName ] = bindingSource;\n\t\t}\n\n\t\treturn bindingsWithDefaults;\n\t}\n\n\treturn bindings;\n}\n\n/**\n * Based on the given block name,\n * check if it is possible to bind the block.\n *\n * @param {string} blockName - The block name.\n * @return {boolean} Whether it is possible to bind the block to sources.\n */\nexport function canBindBlock( blockName ) {\n\treturn blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS;\n}\n\n/**\n * Based on the given block name and attribute name,\n * check if it is possible to bind the block attribute.\n *\n * @param {string} blockName - The block name.\n * @param {string} attributeName - The attribute name.\n * @return {boolean} Whether it is possible to bind the block attribute.\n */\nexport function canBindAttribute( blockName, attributeName ) {\n\treturn (\n\t\tcanBindBlock( blockName ) &&\n\t\tBLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ].includes( attributeName )\n\t);\n}\n\nexport const withBlockBindingSupport = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst registry = useRegistry();\n\t\tconst blockContext = useContext( BlockContext );\n\t\tconst sources = useSelect( ( select ) =>\n\t\t\tunlock( select( blocksStore ) ).getAllBlockBindingsSources()\n\t\t);\n\t\tconst { name, clientId } = props;\n\t\tconst hasParentPattern = !! props.context[ 'pattern/overrides' ];\n\t\tconst hasPatternOverridesDefaultBinding =\n\t\t\tprops.attributes.metadata?.bindings?.[ DEFAULT_ATTRIBUTE ]\n\t\t\t\t?.source === 'core/pattern-overrides';\n\t\tconst blockBindings = useMemo(\n\t\t\t() =>\n\t\t\t\treplacePatternOverrideDefaultBindings(\n\t\t\t\t\tname,\n\t\t\t\t\tprops.attributes.metadata?.bindings\n\t\t\t\t),\n\t\t\t[ props.attributes.metadata?.bindings, name ]\n\t\t);\n\n\t\t// While this hook doesn't directly call any selectors, `useSelect` is\n\t\t// used purposely here to ensure `boundAttributes` is updated whenever\n\t\t// there are attribute updates.\n\t\t// `source.getValues` may also call a selector via `registry.select`.\n\t\tconst boundAttributes = useSelect( () => {\n\t\t\tif ( ! blockBindings ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst attributes = {};\n\n\t\t\tconst blockBindingsBySource = new Map();\n\n\t\t\tfor ( const [ attributeName, binding ] of Object.entries(\n\t\t\t\tblockBindings\n\t\t\t) ) {\n\t\t\t\tconst { source: sourceName, args: sourceArgs } = binding;\n\t\t\t\tconst source = sources[ sourceName ];\n\t\t\t\tif (\n\t\t\t\t\t! source?.getValues ||\n\t\t\t\t\t! canBindAttribute( name, attributeName )\n\t\t\t\t) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tblockBindingsBySource.set( source, {\n\t\t\t\t\t...blockBindingsBySource.get( source ),\n\t\t\t\t\t[ attributeName ]: {\n\t\t\t\t\t\targs: sourceArgs,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( blockBindingsBySource.size ) {\n\t\t\t\tfor ( const [ source, bindings ] of blockBindingsBySource ) {\n\t\t\t\t\t// Populate context.\n\t\t\t\t\tconst context = {};\n\n\t\t\t\t\tif ( source.usesContext?.length ) {\n\t\t\t\t\t\tfor ( const key of source.usesContext ) {\n\t\t\t\t\t\t\tcontext[ key ] = blockContext[ key ];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Get values in batch if the source supports it.\n\t\t\t\t\tconst values = source.getValues( {\n\t\t\t\t\t\tregistry,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\tbindings,\n\t\t\t\t\t} );\n\t\t\t\t\tfor ( const [ attributeName, value ] of Object.entries(\n\t\t\t\t\t\tvalues\n\t\t\t\t\t) ) {\n\t\t\t\t\t\t// Use placeholder when value is undefined.\n\t\t\t\t\t\tif ( value === undefined ) {\n\t\t\t\t\t\t\tif ( attributeName === 'url' ) {\n\t\t\t\t\t\t\t\tattributes[ attributeName ] = null;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tattributes[ attributeName ] =\n\t\t\t\t\t\t\t\t\tsource.getPlaceholder?.( {\n\t\t\t\t\t\t\t\t\t\tregistry,\n\t\t\t\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\t\t\tattributeName,\n\t\t\t\t\t\t\t\t\t\targs: bindings[ attributeName ].args,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tattributes[ attributeName ] = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn attributes;\n\t\t}, [ blockBindings, name, clientId, blockContext, registry, sources ] );\n\n\t\tconst { setAttributes } = props;\n\n\t\tconst _setAttributes = useCallback(\n\t\t\t( nextAttributes ) => {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tif ( ! blockBindings ) {\n\t\t\t\t\t\tsetAttributes( nextAttributes );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst keptAttributes = { ...nextAttributes };\n\t\t\t\t\tconst blockBindingsBySource = new Map();\n\n\t\t\t\t\t// Loop only over the updated attributes to avoid modifying the bound ones that haven't changed.\n\t\t\t\t\tfor ( const [ attributeName, newValue ] of Object.entries(\n\t\t\t\t\t\tkeptAttributes\n\t\t\t\t\t) ) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t! blockBindings[ attributeName ] ||\n\t\t\t\t\t\t\t! canBindAttribute( name, attributeName )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst binding = blockBindings[ attributeName ];\n\t\t\t\t\t\tconst source = sources[ binding?.source ];\n\t\t\t\t\t\tif ( ! source?.setValues ) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tblockBindingsBySource.set( source, {\n\t\t\t\t\t\t\t...blockBindingsBySource.get( source ),\n\t\t\t\t\t\t\t[ attributeName ]: {\n\t\t\t\t\t\t\t\targs: binding.args,\n\t\t\t\t\t\t\t\tnewValue,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tdelete keptAttributes[ attributeName ];\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( blockBindingsBySource.size ) {\n\t\t\t\t\t\tfor ( const [\n\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t\tbindings,\n\t\t\t\t\t\t] of blockBindingsBySource ) {\n\t\t\t\t\t\t\t// Populate context.\n\t\t\t\t\t\t\tconst context = {};\n\n\t\t\t\t\t\t\tif ( source.usesContext?.length ) {\n\t\t\t\t\t\t\t\tfor ( const key of source.usesContext ) {\n\t\t\t\t\t\t\t\t\tcontext[ key ] = blockContext[ key ];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tsource.setValues( {\n\t\t\t\t\t\t\t\tregistry,\n\t\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\tbindings,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t// Don't update non-connected attributes if the block is using pattern overrides\n\t\t\t\t\t\t// and the editing is happening while overriding the pattern (not editing the original).\n\t\t\t\t\t\t! (\n\t\t\t\t\t\t\thasPatternOverridesDefaultBinding &&\n\t\t\t\t\t\t\thasParentPattern\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\tObject.keys( keptAttributes ).length\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Don't update caption and href until they are supported.\n\t\t\t\t\t\tif ( hasPatternOverridesDefaultBinding ) {\n\t\t\t\t\t\t\tdelete keptAttributes?.caption;\n\t\t\t\t\t\t\tdelete keptAttributes?.href;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetAttributes( keptAttributes );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[\n\t\t\t\tregistry,\n\t\t\t\tblockBindings,\n\t\t\t\tname,\n\t\t\t\tclientId,\n\t\t\t\tblockContext,\n\t\t\t\tsetAttributes,\n\t\t\t\tsources,\n\t\t\t\thasPatternOverridesDefaultBinding,\n\t\t\t\thasParentPattern,\n\t\t\t]\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tattributes={ { ...props.attributes, ...boundAttributes } }\n\t\t\t\t\tsetAttributes={ _setAttributes }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n\t'withBlockBindingSupport'\n);\n\n/**\n * Filters a registered block's settings to enhance a block's `edit` component\n * to upgrade bound attributes.\n *\n * @param {WPBlockSettings} settings - Registered block settings.\n * @param {string} name - Block name.\n * @return {WPBlockSettings} Filtered block settings.\n */\nfunction shimAttributeSource( settings, name ) {\n\tif ( ! canBindBlock( name ) ) {\n\t\treturn settings;\n\t}\n\n\treturn {\n\t\t...settings,\n\t\tedit: withBlockBindingSupport( settings.edit ),\n\t};\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/custom-sources-backwards-compatibility/shim-attribute-source',\n\tshimAttributeSource\n);\n"],"mappings":";;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAKA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAC,sBAAA,CAAAP,OAAA;AAAuD,IAAAQ,WAAA,GAAAR,OAAA;AAbvD;AACA;AACA;;AAOA;AACA;AACA;;AAIA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAEA,MAAMS,6BAA6B,GAAG;EACrC,gBAAgB,EAAE,CAAE,SAAS,CAAE;EAC/B,cAAc,EAAE,CAAE,SAAS,CAAE;EAC7B,YAAY,EAAE,CAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAE;EAC7C,aAAa,EAAE,CAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK;AACpD,CAAC;AAED,MAAMC,iBAAiB,GAAG,WAAW;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,qCAAqCA,CAAEC,SAAS,EAAEC,QAAQ,EAAG;EACrE;EACA,IACCA,QAAQ,GAAIH,iBAAiB,CAAE,EAAEI,MAAM,KAAK,wBAAwB,EACnE;IACD,MAAMC,mBAAmB,GAAGN,6BAA6B,CAAEG,SAAS,CAAE;IACtE,MAAMI,oBAAoB,GAA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ACnC;QACD;QACA,IAAKnB,iCAAiC,EAAG;UACxC,OAAO8B,cAAc,EAAEI,OAAO;UAC9B,OAAOJ,cAAc,EAAEK,IAAI;QAC5B;QACAV,aAAa,CAAEK,cAAe,CAAC;MAChC;IACD,CAAE,CAAC;EACJ,CAAC,EACD,CACC7C,QAAQ,EACRkB,aAAa,EACbP,IAAI,EACJC,QAAQ,EACRV,YAAY,EACZsC,aAAa,EACbnC,OAAO,EACPU,iCAAiC,EACjCF,gBAAgB,CAElB,CAAC;EAED,oBACC,IAAAhC,WAAA,CAAAsE,GAAA,EAAAtE,WAAA,CAAAuE,QAAA;IAAAC,QAAA,eACC,IAAAxE,WAAA,CAAAsE,GAAA,EAACrD,SAAS;MAAA,GACJC,KAAK;MACViB,UAAU,EAAG;QAAE,GAAGjB,KAAK,CAACiB,UAAU;QAAE,GAAGI;MAAgB,CAAG;MAC1DoB,aAAa,EAAGC;IAAgB,CAChC;EAAC,CACD,CAAC;AAEL,CAAC,EACD,yBACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASa,mBAAmBA,CAAEC,QAAQ,EAAE5C,IAAI,EAAG;EAC9C,IAAK,CAAEnB,YAAY,CAAEmB,IAAK,CAAC,EAAG;IAC7B,OAAO4C,QAAQ;EAChB;EAEA,OAAO;IACN,GAAGA,QAAQ;IACXC,IAAI,EAAE7D,uBAAuB,CAAE4D,QAAQ,CAACC,IAAK;EAC9C,CAAC;AACF;AAEA,IAAAC,gBAAS,EACR,0BAA0B,EAC1B,0EAA0E,EAC1EH,mBACD,CAAC","ignoreList":[]}
@@ -117,6 +117,7 @@ function useStyleOverride({
117
117
  css,
118
118
  assets,
119
119
  __unstableType,
120
+ variation,
120
121
  clientId
121
122
  } = {}) {
122
123
  const {
@@ -136,6 +137,7 @@ function useStyleOverride({
136
137
  css,
137
138
  assets,
138
139
  __unstableType,
140
+ variation,
139
141
  clientId
140
142
  };
141
143
  // Batch updates to style overrides to avoid triggering cascading renders