@wordpress/block-editor 12.20.0 → 12.21.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 (471) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-actions/index.js +45 -32
  3. package/build/components/block-actions/index.js.map +1 -1
  4. package/build/components/block-bindings-toolbar-indicator/index.js +25 -0
  5. package/build/components/block-bindings-toolbar-indicator/index.js.map +1 -0
  6. package/build/components/block-edit/context.js +2 -1
  7. package/build/components/block-edit/context.js.map +1 -1
  8. package/build/components/block-edit/index.js +8 -3
  9. package/build/components/block-edit/index.js.map +1 -1
  10. package/build/components/block-inspector/index.js +5 -4
  11. package/build/components/block-inspector/index.js.map +1 -1
  12. package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
  13. package/build/components/block-list/block-list-item.native.js +1 -1
  14. package/build/components/block-list/block-list-item.native.js.map +1 -1
  15. package/build/components/block-list/block-outline.native.js +23 -7
  16. package/build/components/block-list/block-outline.native.js.map +1 -1
  17. package/build/components/block-list/block-selection-button.native.js.map +1 -1
  18. package/build/components/block-list/block.native.js +0 -3
  19. package/build/components/block-list/block.native.js.map +1 -1
  20. package/build/components/block-list/use-block-props/index.js +8 -1
  21. package/build/components/block-list/use-block-props/index.js.map +1 -1
  22. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +3 -3
  23. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
  24. package/build/components/block-mover/index.native.js.map +1 -1
  25. package/build/components/block-popover/cover.js +68 -0
  26. package/build/components/block-popover/cover.js.map +1 -0
  27. package/build/components/block-popover/drop-zone.js +2 -3
  28. package/build/components/block-popover/drop-zone.js.map +1 -1
  29. package/build/components/block-popover/index.js +1 -19
  30. package/build/components/block-popover/index.js.map +1 -1
  31. package/build/components/block-preview/index.js +2 -1
  32. package/build/components/block-preview/index.js.map +1 -1
  33. package/build/components/block-removal-warning-modal/index.js +2 -4
  34. package/build/components/block-removal-warning-modal/index.js.map +1 -1
  35. package/build/components/block-rename/modal.js.map +1 -1
  36. package/build/components/block-settings-menu/block-settings-dropdown.js +12 -10
  37. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  38. package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
  39. package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
  40. package/build/components/block-toolbar/index.js +21 -10
  41. package/build/components/block-toolbar/index.js.map +1 -1
  42. package/build/components/block-toolbar/shuffle.js +89 -0
  43. package/build/components/block-toolbar/shuffle.js.map +1 -0
  44. package/build/components/block-toolbar/use-has-block-toolbar.js +43 -0
  45. package/build/components/block-toolbar/use-has-block-toolbar.js.map +1 -0
  46. package/build/components/block-tools/block-selection-button.js +5 -1
  47. package/build/components/block-tools/block-selection-button.js.map +1 -1
  48. package/build/components/block-tools/empty-block-inserter.js +2 -5
  49. package/build/components/block-tools/empty-block-inserter.js.map +1 -1
  50. package/build/components/block-tools/index.js +9 -26
  51. package/build/components/block-tools/index.js.map +1 -1
  52. package/build/components/block-tools/use-show-block-tools.js +60 -0
  53. package/build/components/block-tools/use-show-block-tools.js.map +1 -0
  54. package/build/components/caption/index.native.js.map +1 -1
  55. package/build/components/child-layout-control/index.js.map +1 -1
  56. package/build/components/color-palette/control.js.map +1 -1
  57. package/build/components/colors-gradients/control.js +1 -1
  58. package/build/components/colors-gradients/control.js.map +1 -1
  59. package/build/components/global-styles/border-panel.js +21 -8
  60. package/build/components/global-styles/border-panel.js.map +1 -1
  61. package/build/components/global-styles/color-panel.js +1 -1
  62. package/build/components/global-styles/color-panel.js.map +1 -1
  63. package/build/components/global-styles/image-settings-panel.js.map +1 -1
  64. package/build/components/global-styles/index.js +6 -0
  65. package/build/components/global-styles/index.js.map +1 -1
  66. package/build/components/global-styles/shadow-panel-components.js +80 -23
  67. package/build/components/global-styles/shadow-panel-components.js.map +1 -1
  68. package/build/components/global-styles/typography-utils.js +7 -5
  69. package/build/components/global-styles/typography-utils.js.map +1 -1
  70. package/build/components/global-styles/use-global-styles-output.js +15 -15
  71. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  72. package/build/components/global-styles/utils.js +1 -1
  73. package/build/components/global-styles/utils.js.map +1 -1
  74. package/build/components/grid-visualizer/grid-item-resizer.js +77 -0
  75. package/build/components/grid-visualizer/grid-item-resizer.js.map +1 -0
  76. package/build/components/grid-visualizer/grid-visualizer.js +81 -0
  77. package/build/components/grid-visualizer/grid-visualizer.js.map +1 -0
  78. package/build/components/grid-visualizer/index.js +20 -0
  79. package/build/components/grid-visualizer/index.js.map +1 -0
  80. package/build/components/grid-visualizer/utils.js +10 -0
  81. package/build/components/grid-visualizer/utils.js.map +1 -0
  82. package/build/components/iframe/index.js +61 -16
  83. package/build/components/iframe/index.js.map +1 -1
  84. package/build/components/index.native.js +7 -0
  85. package/build/components/index.native.js.map +1 -1
  86. package/build/components/inner-blocks/use-nested-settings-update.js +8 -2
  87. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  88. package/build/components/inserter/media-tab/media-preview.js.map +1 -1
  89. package/build/components/inserter/menu.js +9 -3
  90. package/build/components/inserter/menu.js.map +1 -1
  91. package/build/components/inserter/menu.native.js.map +1 -1
  92. package/build/components/inserter/mobile-tab-navigation.js +1 -1
  93. package/build/components/inserter/mobile-tab-navigation.js.map +1 -1
  94. package/build/components/inserter/search-results.js +3 -2
  95. package/build/components/inserter/search-results.js.map +1 -1
  96. package/build/components/inserter/tabs.js +2 -1
  97. package/build/components/inserter/tabs.js.map +1 -1
  98. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  99. package/build/components/inspector-controls-tabs/index.js +1 -1
  100. package/build/components/inspector-controls-tabs/index.js.map +1 -1
  101. package/build/components/inspector-controls-tabs/styles-tab.js +1 -1
  102. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  103. package/build/components/link-control/link-preview.js +4 -1
  104. package/build/components/link-control/link-preview.js.map +1 -1
  105. package/build/components/link-control/search-input.js.map +1 -1
  106. package/build/components/list-view/block-select-button.js +10 -2
  107. package/build/components/list-view/block-select-button.js.map +1 -1
  108. package/build/components/list-view/branch.js.map +1 -1
  109. package/build/components/list-view/drop-indicator.js.map +1 -1
  110. package/build/components/list-view/index.js.map +1 -1
  111. package/build/components/list-view/use-clipboard-handler.js +2 -1
  112. package/build/components/list-view/use-clipboard-handler.js.map +1 -1
  113. package/build/components/panel-color-settings/index.js.map +1 -1
  114. package/build/components/provider/index.js.map +1 -1
  115. package/build/components/resizable-box-popover/index.js +3 -5
  116. package/build/components/resizable-box-popover/index.js.map +1 -1
  117. package/build/components/responsive-block-control/index.js +1 -1
  118. package/build/components/responsive-block-control/index.js.map +1 -1
  119. package/build/components/rich-text/index.js +46 -26
  120. package/build/components/rich-text/index.js.map +1 -1
  121. package/build/components/rich-text/use-enter.js +3 -0
  122. package/build/components/rich-text/use-enter.js.map +1 -1
  123. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  124. package/build/components/url-popover/index.js +3 -3
  125. package/build/components/url-popover/index.js.map +1 -1
  126. package/build/components/writing-flow/use-clipboard-handler.js +2 -1
  127. package/build/components/writing-flow/use-clipboard-handler.js.map +1 -1
  128. package/build/components/writing-flow/utils.js +23 -6
  129. package/build/components/writing-flow/utils.js.map +1 -1
  130. package/build/hooks/background.js.map +1 -1
  131. package/build/hooks/block-hooks.js +34 -8
  132. package/build/hooks/block-hooks.js.map +1 -1
  133. package/build/hooks/border.js +6 -4
  134. package/build/hooks/border.js.map +1 -1
  135. package/build/hooks/dimensions.js +3 -4
  136. package/build/hooks/dimensions.js.map +1 -1
  137. package/build/hooks/font-size.js +6 -7
  138. package/build/hooks/font-size.js.map +1 -1
  139. package/build/hooks/index.js +1 -1
  140. package/build/hooks/index.js.map +1 -1
  141. package/build/hooks/layout-child.js +39 -0
  142. package/build/hooks/layout-child.js.map +1 -1
  143. package/build/hooks/layout.js +11 -4
  144. package/build/hooks/layout.js.map +1 -1
  145. package/build/hooks/line-height.js.map +1 -1
  146. package/build/hooks/spacing-visualizer.js +115 -0
  147. package/build/hooks/spacing-visualizer.js.map +1 -0
  148. package/build/hooks/use-bindings-attributes.js +171 -48
  149. package/build/hooks/use-bindings-attributes.js.map +1 -1
  150. package/build/hooks/use-typography-props.js +1 -2
  151. package/build/hooks/use-typography-props.js.map +1 -1
  152. package/build/layouts/grid.js +6 -2
  153. package/build/layouts/grid.js.map +1 -1
  154. package/build/private-apis.js +7 -3
  155. package/build/private-apis.js.map +1 -1
  156. package/build/store/actions.js +42 -12
  157. package/build/store/actions.js.map +1 -1
  158. package/build/store/private-actions.js +29 -55
  159. package/build/store/private-actions.js.map +1 -1
  160. package/build/store/private-selectors.js +0 -8
  161. package/build/store/private-selectors.js.map +1 -1
  162. package/build/store/reducer.js +3 -20
  163. package/build/store/reducer.js.map +1 -1
  164. package/build/store/selectors.js +27 -15
  165. package/build/store/selectors.js.map +1 -1
  166. package/build/utils/calculate-scale.js +17 -0
  167. package/build/utils/calculate-scale.js.map +1 -0
  168. package/build-module/components/block-actions/index.js +45 -32
  169. package/build-module/components/block-actions/index.js.map +1 -1
  170. package/build-module/components/block-bindings-toolbar-indicator/index.js +18 -0
  171. package/build-module/components/block-bindings-toolbar-indicator/index.js.map +1 -0
  172. package/build-module/components/block-edit/context.js +1 -0
  173. package/build-module/components/block-edit/context.js.map +1 -1
  174. package/build-module/components/block-edit/index.js +9 -4
  175. package/build-module/components/block-edit/index.js.map +1 -1
  176. package/build-module/components/block-inspector/index.js +6 -5
  177. package/build-module/components/block-inspector/index.js.map +1 -1
  178. package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
  179. package/build-module/components/block-list/block-list-item.native.js +1 -1
  180. package/build-module/components/block-list/block-list-item.native.js.map +1 -1
  181. package/build-module/components/block-list/block-outline.native.js +23 -7
  182. package/build-module/components/block-list/block-outline.native.js.map +1 -1
  183. package/build-module/components/block-list/block-selection-button.native.js.map +1 -1
  184. package/build-module/components/block-list/block.native.js +0 -3
  185. package/build-module/components/block-list/block.native.js.map +1 -1
  186. package/build-module/components/block-list/use-block-props/index.js +9 -2
  187. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  188. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +3 -3
  189. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
  190. package/build-module/components/block-mover/index.native.js.map +1 -1
  191. package/build-module/components/block-popover/cover.js +60 -0
  192. package/build-module/components/block-popover/cover.js.map +1 -0
  193. package/build-module/components/block-popover/drop-zone.js +2 -3
  194. package/build-module/components/block-popover/drop-zone.js.map +1 -1
  195. package/build-module/components/block-popover/index.js +1 -19
  196. package/build-module/components/block-popover/index.js.map +1 -1
  197. package/build-module/components/block-preview/index.js +2 -1
  198. package/build-module/components/block-preview/index.js.map +1 -1
  199. package/build-module/components/block-removal-warning-modal/index.js +3 -5
  200. package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
  201. package/build-module/components/block-rename/modal.js.map +1 -1
  202. package/build-module/components/block-settings-menu/block-settings-dropdown.js +12 -10
  203. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  204. package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
  205. package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
  206. package/build-module/components/block-toolbar/index.js +21 -11
  207. package/build-module/components/block-toolbar/index.js.map +1 -1
  208. package/build-module/components/block-toolbar/shuffle.js +82 -0
  209. package/build-module/components/block-toolbar/shuffle.js.map +1 -0
  210. package/build-module/components/block-toolbar/use-has-block-toolbar.js +36 -0
  211. package/build-module/components/block-toolbar/use-has-block-toolbar.js.map +1 -0
  212. package/build-module/components/block-tools/block-selection-button.js +5 -1
  213. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  214. package/build-module/components/block-tools/empty-block-inserter.js +2 -5
  215. package/build-module/components/block-tools/empty-block-inserter.js.map +1 -1
  216. package/build-module/components/block-tools/index.js +9 -26
  217. package/build-module/components/block-tools/index.js.map +1 -1
  218. package/build-module/components/block-tools/use-show-block-tools.js +54 -0
  219. package/build-module/components/block-tools/use-show-block-tools.js.map +1 -0
  220. package/build-module/components/caption/index.native.js.map +1 -1
  221. package/build-module/components/child-layout-control/index.js.map +1 -1
  222. package/build-module/components/color-palette/control.js.map +1 -1
  223. package/build-module/components/colors-gradients/control.js +1 -1
  224. package/build-module/components/colors-gradients/control.js.map +1 -1
  225. package/build-module/components/global-styles/border-panel.js +22 -10
  226. package/build-module/components/global-styles/border-panel.js.map +1 -1
  227. package/build-module/components/global-styles/color-panel.js +1 -1
  228. package/build-module/components/global-styles/color-panel.js.map +1 -1
  229. package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
  230. package/build-module/components/global-styles/index.js +1 -1
  231. package/build-module/components/global-styles/index.js.map +1 -1
  232. package/build-module/components/global-styles/shadow-panel-components.js +82 -24
  233. package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
  234. package/build-module/components/global-styles/typography-utils.js +7 -5
  235. package/build-module/components/global-styles/typography-utils.js.map +1 -1
  236. package/build-module/components/global-styles/use-global-styles-output.js +16 -16
  237. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  238. package/build-module/components/global-styles/utils.js +2 -2
  239. package/build-module/components/global-styles/utils.js.map +1 -1
  240. package/build-module/components/grid-visualizer/grid-item-resizer.js +69 -0
  241. package/build-module/components/grid-visualizer/grid-item-resizer.js.map +1 -0
  242. package/build-module/components/grid-visualizer/grid-visualizer.js +73 -0
  243. package/build-module/components/grid-visualizer/grid-visualizer.js.map +1 -0
  244. package/build-module/components/grid-visualizer/index.js +3 -0
  245. package/build-module/components/grid-visualizer/index.js.map +1 -0
  246. package/build-module/components/grid-visualizer/utils.js +4 -0
  247. package/build-module/components/grid-visualizer/utils.js.map +1 -0
  248. package/build-module/components/iframe/index.js +61 -16
  249. package/build-module/components/iframe/index.js.map +1 -1
  250. package/build-module/components/index.native.js +1 -1
  251. package/build-module/components/index.native.js.map +1 -1
  252. package/build-module/components/inner-blocks/use-nested-settings-update.js +8 -2
  253. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  254. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
  255. package/build-module/components/inserter/menu.js +9 -3
  256. package/build-module/components/inserter/menu.js.map +1 -1
  257. package/build-module/components/inserter/menu.native.js.map +1 -1
  258. package/build-module/components/inserter/mobile-tab-navigation.js +1 -1
  259. package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -1
  260. package/build-module/components/inserter/search-results.js +3 -2
  261. package/build-module/components/inserter/search-results.js.map +1 -1
  262. package/build-module/components/inserter/tabs.js +2 -1
  263. package/build-module/components/inserter/tabs.js.map +1 -1
  264. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  265. package/build-module/components/inspector-controls-tabs/index.js +1 -1
  266. package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
  267. package/build-module/components/inspector-controls-tabs/styles-tab.js +2 -2
  268. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  269. package/build-module/components/link-control/link-preview.js +5 -2
  270. package/build-module/components/link-control/link-preview.js.map +1 -1
  271. package/build-module/components/link-control/search-input.js.map +1 -1
  272. package/build-module/components/list-view/block-select-button.js +11 -3
  273. package/build-module/components/list-view/block-select-button.js.map +1 -1
  274. package/build-module/components/list-view/branch.js.map +1 -1
  275. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  276. package/build-module/components/list-view/index.js.map +1 -1
  277. package/build-module/components/list-view/use-clipboard-handler.js +3 -2
  278. package/build-module/components/list-view/use-clipboard-handler.js.map +1 -1
  279. package/build-module/components/panel-color-settings/index.js.map +1 -1
  280. package/build-module/components/provider/index.js.map +1 -1
  281. package/build-module/components/resizable-box-popover/index.js +3 -5
  282. package/build-module/components/resizable-box-popover/index.js.map +1 -1
  283. package/build-module/components/responsive-block-control/index.js +1 -1
  284. package/build-module/components/responsive-block-control/index.js.map +1 -1
  285. package/build-module/components/rich-text/index.js +47 -28
  286. package/build-module/components/rich-text/index.js.map +1 -1
  287. package/build-module/components/rich-text/use-enter.js +3 -0
  288. package/build-module/components/rich-text/use-enter.js.map +1 -1
  289. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  290. package/build-module/components/url-popover/index.js +3 -3
  291. package/build-module/components/url-popover/index.js.map +1 -1
  292. package/build-module/components/writing-flow/use-clipboard-handler.js +3 -2
  293. package/build-module/components/writing-flow/use-clipboard-handler.js.map +1 -1
  294. package/build-module/components/writing-flow/utils.js +22 -7
  295. package/build-module/components/writing-flow/utils.js.map +1 -1
  296. package/build-module/hooks/background.js.map +1 -1
  297. package/build-module/hooks/block-hooks.js +34 -8
  298. package/build-module/hooks/block-hooks.js.map +1 -1
  299. package/build-module/hooks/border.js +7 -5
  300. package/build-module/hooks/border.js.map +1 -1
  301. package/build-module/hooks/dimensions.js +1 -2
  302. package/build-module/hooks/dimensions.js.map +1 -1
  303. package/build-module/hooks/font-size.js +7 -8
  304. package/build-module/hooks/font-size.js.map +1 -1
  305. package/build-module/hooks/index.js +1 -1
  306. package/build-module/hooks/index.js.map +1 -1
  307. package/build-module/hooks/layout-child.js +39 -0
  308. package/build-module/hooks/layout-child.js.map +1 -1
  309. package/build-module/hooks/layout.js +11 -4
  310. package/build-module/hooks/layout.js.map +1 -1
  311. package/build-module/hooks/line-height.js.map +1 -1
  312. package/build-module/hooks/spacing-visualizer.js +106 -0
  313. package/build-module/hooks/spacing-visualizer.js.map +1 -0
  314. package/build-module/hooks/use-bindings-attributes.js +172 -49
  315. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  316. package/build-module/hooks/use-typography-props.js +2 -3
  317. package/build-module/hooks/use-typography-props.js.map +1 -1
  318. package/build-module/layouts/grid.js +6 -2
  319. package/build-module/layouts/grid.js.map +1 -1
  320. package/build-module/private-apis.js +7 -3
  321. package/build-module/private-apis.js.map +1 -1
  322. package/build-module/store/actions.js +42 -12
  323. package/build-module/store/actions.js.map +1 -1
  324. package/build-module/store/private-actions.js +29 -54
  325. package/build-module/store/private-actions.js.map +1 -1
  326. package/build-module/store/private-selectors.js +0 -6
  327. package/build-module/store/private-selectors.js.map +1 -1
  328. package/build-module/store/reducer.js +3 -20
  329. package/build-module/store/reducer.js.map +1 -1
  330. package/build-module/store/selectors.js +23 -13
  331. package/build-module/store/selectors.js.map +1 -1
  332. package/build-module/utils/calculate-scale.js +11 -0
  333. package/build-module/utils/calculate-scale.js.map +1 -0
  334. package/build-style/content-rtl.css +8 -2
  335. package/build-style/content.css +8 -2
  336. package/build-style/default-editor-styles-rtl.css +1 -0
  337. package/build-style/default-editor-styles.css +1 -0
  338. package/build-style/style-rtl.css +113 -22
  339. package/build-style/style.css +113 -22
  340. package/package.json +31 -31
  341. package/src/components/block-actions/index.js +57 -47
  342. package/src/components/block-bindings-toolbar-indicator/index.js +20 -0
  343. package/src/components/block-bindings-toolbar-indicator/style.scss +14 -0
  344. package/src/components/block-draggable/test/index.native.js +2 -2
  345. package/src/components/block-edit/context.js +1 -0
  346. package/src/components/block-edit/index.js +5 -1
  347. package/src/components/block-inspector/index.js +7 -5
  348. package/src/components/block-list/block-invalid-warning.native.js +1 -1
  349. package/src/components/block-list/block-list-item.native.js +1 -1
  350. package/src/components/block-list/block-outline.native.js +36 -21
  351. package/src/components/block-list/block-selection-button.native.js +1 -3
  352. package/src/components/block-list/block.native.js +0 -3
  353. package/src/components/block-list/content.scss +5 -1
  354. package/src/components/block-list/test/block-outline.native.js +255 -0
  355. package/src/components/block-list/use-block-props/index.js +12 -2
  356. package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +3 -7
  357. package/src/components/block-mover/index.native.js +1 -1
  358. package/src/components/block-popover/cover.js +63 -0
  359. package/src/components/block-popover/drop-zone.js +3 -4
  360. package/src/components/block-popover/index.js +1 -28
  361. package/src/components/block-preview/index.js +3 -1
  362. package/src/components/block-removal-warning-modal/index.js +5 -19
  363. package/src/components/block-rename/modal.js +1 -1
  364. package/src/components/block-settings-menu/block-settings-dropdown.js +12 -9
  365. package/src/components/block-switcher/block-transformations-menu.native.js +1 -1
  366. package/src/components/block-toolbar/block-toolbar-menu.native.js +2 -2
  367. package/src/components/block-toolbar/index.js +19 -15
  368. package/src/components/block-toolbar/shuffle.js +93 -0
  369. package/src/components/block-toolbar/use-has-block-toolbar.js +49 -0
  370. package/src/components/block-tools/block-selection-button.js +4 -0
  371. package/src/components/block-tools/empty-block-inserter.js +3 -6
  372. package/src/components/block-tools/index.js +13 -36
  373. package/src/components/block-tools/use-show-block-tools.js +73 -0
  374. package/src/components/caption/index.native.js +1 -1
  375. package/src/components/child-layout-control/index.js +1 -1
  376. package/src/components/color-palette/control.js +1 -1
  377. package/src/components/colors-gradients/control.js +1 -1
  378. package/src/components/colors-gradients/test/control.js +2 -2
  379. package/src/components/contrast-checker/test/index.js +10 -10
  380. package/src/components/default-block-appender/content.scss +5 -2
  381. package/src/components/global-styles/border-panel.js +35 -24
  382. package/src/components/global-styles/color-panel.js +1 -1
  383. package/src/components/global-styles/image-settings-panel.js +1 -1
  384. package/src/components/global-styles/index.js +5 -1
  385. package/src/components/global-styles/shadow-panel-components.js +92 -23
  386. package/src/components/global-styles/style.scss +33 -10
  387. package/src/components/global-styles/test/typography-utils.js +231 -81
  388. package/src/components/global-styles/typography-utils.js +10 -7
  389. package/src/components/global-styles/use-global-styles-output.js +14 -16
  390. package/src/components/global-styles/utils.js +2 -8
  391. package/src/components/grid-visualizer/grid-item-resizer.js +100 -0
  392. package/src/components/grid-visualizer/grid-visualizer.js +81 -0
  393. package/src/components/grid-visualizer/index.js +2 -0
  394. package/src/components/grid-visualizer/style.scss +33 -0
  395. package/src/components/grid-visualizer/utils.js +5 -0
  396. package/src/components/iframe/index.js +78 -31
  397. package/src/components/index.native.js +1 -0
  398. package/src/components/inner-blocks/use-nested-settings-update.js +12 -2
  399. package/src/components/inserter/media-tab/media-preview.js +1 -1
  400. package/src/components/inserter/menu.js +10 -4
  401. package/src/components/inserter/menu.native.js +3 -3
  402. package/src/components/inserter/mobile-tab-navigation.js +1 -1
  403. package/src/components/inserter/search-results.js +2 -1
  404. package/src/components/inserter/style.scss +10 -0
  405. package/src/components/inserter/tabs.js +2 -1
  406. package/src/components/inspector-controls/block-support-tools-panel.js +2 -2
  407. package/src/components/inspector-controls-tabs/index.js +1 -1
  408. package/src/components/inspector-controls-tabs/styles-tab.js +2 -2
  409. package/src/components/line-height-control/test/index.js +1 -1
  410. package/src/components/link-control/link-preview.js +9 -2
  411. package/src/components/link-control/search-input.js +1 -1
  412. package/src/components/link-control/style.scss +9 -0
  413. package/src/components/list-view/block-select-button.js +16 -2
  414. package/src/components/list-view/branch.js +1 -1
  415. package/src/components/list-view/drop-indicator.js +1 -1
  416. package/src/components/list-view/index.js +1 -1
  417. package/src/components/list-view/style.scss +8 -0
  418. package/src/components/list-view/use-clipboard-handler.js +3 -2
  419. package/src/components/panel-color-settings/index.js +1 -1
  420. package/src/components/panel-color-settings/test/index.js +3 -3
  421. package/src/components/provider/index.js +1 -4
  422. package/src/components/resizable-box-popover/index.js +4 -6
  423. package/src/components/responsive-block-control/README.md +4 -4
  424. package/src/components/responsive-block-control/index.js +1 -1
  425. package/src/components/responsive-block-control/test/index.js +5 -5
  426. package/src/components/rich-text/index.js +76 -53
  427. package/src/components/rich-text/use-enter.js +4 -0
  428. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +4 -4
  429. package/src/components/url-popover/index.js +5 -5
  430. package/src/components/url-popover/style.scss +1 -0
  431. package/src/components/writing-flow/use-clipboard-handler.js +3 -2
  432. package/src/components/writing-flow/utils.js +31 -16
  433. package/src/hooks/background.js +1 -1
  434. package/src/hooks/block-hooks.js +47 -9
  435. package/src/hooks/block-hooks.scss +6 -0
  436. package/src/hooks/border.js +16 -4
  437. package/src/hooks/dimensions.js +1 -2
  438. package/src/hooks/font-size.js +7 -12
  439. package/src/hooks/index.js +1 -0
  440. package/src/hooks/layout-child.js +38 -0
  441. package/src/hooks/layout.js +12 -1
  442. package/src/hooks/line-height.js +1 -1
  443. package/src/hooks/spacing-visualizer.js +126 -0
  444. package/src/hooks/{padding.scss → spacing.scss} +1 -1
  445. package/src/hooks/use-bindings-attributes.js +215 -65
  446. package/src/hooks/use-typography-props.js +2 -8
  447. package/src/layouts/grid.js +8 -3
  448. package/src/private-apis.js +6 -2
  449. package/src/store/actions.js +56 -18
  450. package/src/store/private-actions.js +34 -79
  451. package/src/store/private-selectors.js +0 -8
  452. package/src/store/reducer.js +2 -23
  453. package/src/store/selectors.js +41 -46
  454. package/src/store/test/actions.js +0 -4
  455. package/src/style.scss +3 -1
  456. package/src/utils/calculate-scale.js +20 -0
  457. package/build/hooks/margin.js +0 -86
  458. package/build/hooks/margin.js.map +0 -1
  459. package/build/hooks/padding.js +0 -78
  460. package/build/hooks/padding.js.map +0 -1
  461. package/build/utils/use-can-block-toolbar-be-focused.js +0 -46
  462. package/build/utils/use-can-block-toolbar-be-focused.js.map +0 -1
  463. package/build-module/hooks/margin.js +0 -78
  464. package/build-module/hooks/margin.js.map +0 -1
  465. package/build-module/hooks/padding.js +0 -70
  466. package/build-module/hooks/padding.js.map +0 -1
  467. package/build-module/utils/use-can-block-toolbar-be-focused.js +0 -40
  468. package/build-module/utils/use-can-block-toolbar-be-focused.js.map +0 -1
  469. package/src/hooks/margin.js +0 -91
  470. package/src/hooks/padding.js +0 -82
  471. package/src/utils/use-can-block-toolbar-be-focused.js +0 -48
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","createHigherOrderComponent","useInstanceId","addFilter","getBlockSupport","hasBlockSupport","useSelect","Button","ButtonGroup","ToggleControl","PanelBody","privateApis","componentsPrivateApis","__","store","blockEditorStore","InspectorControls","useSettings","getLayoutType","getLayoutTypes","useBlockEditingMode","LAYOUT_DEFINITIONS","useBlockSettings","useStyleOverride","unlock","layoutBlockSupportKey","hasLayoutBlockSupport","blockName","useLayoutClasses","blockAttributes","kebabCase","rootPaddingAlignment","select","getSettings","__experimentalFeatures","useRootPaddingAwareAlignments","layout","default","defaultBlockLayout","usedLayout","inherit","contentSize","wideSize","type","layoutClassnames","className","baseClassName","splitBlockName","split","fullBlockName","pop","join","compoundClassName","push","orientation","justifyContent","flexWrap","useLayoutStyles","selector","style","fullLayoutType","blockGapSupport","hasBlockGapSupport","css","getLayoutStyle","LayoutPanelPure","setAttributes","name","settings","layoutSettings","defaultThemeLayout","themeSupportsLayout","supportsLayout","blockEditingMode","layoutBlockSupport","blockSupportAndThemeSettings","allowSwitching","allowEditing","allowInheriting","showInheritToggle","layoutType","constrainedType","displayControlsForLegacyLayouts","hasContentSizeOrLegacySettings","onChangeType","newType","onChangeLayout","newLayout","createElement","Fragment","title","__nextHasNoMarginBottom","label","checked","onChange","help","LayoutTypeSwitcher","inspectorControls","toolBarControls","shareWithChildBlocks","edit","attributeKeys","hasSupport","map","key","isPressed","onClick","addAttribute","_settings$attributes$","attributes","BlockWithLayoutStyles","block","BlockListBlock","props","id","layoutClasses","selectorPrefix","layoutClassNames","__unstableLayoutClassNames","withLayoutStyles","blockSupportsLayout","shouldRenderLayoutStyles","disableLayoutStyles"],"sources":["@wordpress/block-editor/src/hooks/layout.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tButton,\n\tButtonGroup,\n\tToggleControl,\n\tPanelBody,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport { useSettings } from '../components/use-settings';\nimport { getLayoutType, getLayoutTypes } from '../layouts';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\nimport { LAYOUT_DEFINITIONS } from '../layouts/definitions';\nimport { useBlockSettings, useStyleOverride } from './utils';\nimport { unlock } from '../lock-unlock';\n\nconst layoutBlockSupportKey = 'layout';\n\nfunction hasLayoutBlockSupport( blockName ) {\n\treturn (\n\t\thasBlockSupport( blockName, 'layout' ) ||\n\t\thasBlockSupport( blockName, '__experimentalLayout' )\n\t);\n}\n\n/**\n * Generates the utility classnames for the given block's layout attributes.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n *\n * @return { Array } Array of CSS classname strings.\n */\nexport function useLayoutClasses( blockAttributes = {}, blockName = '' ) {\n\tconst { kebabCase } = unlock( componentsPrivateApis );\n\tconst rootPaddingAlignment = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalFeatures\n\t\t\t?.useRootPaddingAwareAlignments;\n\t}, [] );\n\tconst { layout } = blockAttributes;\n\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( blockName, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst layoutClassnames = [];\n\n\tif ( LAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className ) {\n\t\tconst baseClassName =\n\t\t\tLAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className;\n\t\tconst splitBlockName = blockName.split( '/' );\n\t\tconst fullBlockName =\n\t\t\tsplitBlockName[ 0 ] === 'core'\n\t\t\t\t? splitBlockName.pop()\n\t\t\t\t: splitBlockName.join( '-' );\n\t\tconst compoundClassName = `wp-block-${ fullBlockName }-${ baseClassName }`;\n\t\tlayoutClassnames.push( baseClassName, compoundClassName );\n\t}\n\n\tif (\n\t\t( usedLayout?.inherit ||\n\t\t\tusedLayout?.contentSize ||\n\t\t\tusedLayout?.type === 'constrained' ) &&\n\t\trootPaddingAlignment\n\t) {\n\t\tlayoutClassnames.push( 'has-global-padding' );\n\t}\n\n\tif ( usedLayout?.orientation ) {\n\t\tlayoutClassnames.push( `is-${ kebabCase( usedLayout.orientation ) }` );\n\t}\n\n\tif ( usedLayout?.justifyContent ) {\n\t\tlayoutClassnames.push(\n\t\t\t`is-content-justification-${ kebabCase(\n\t\t\t\tusedLayout.justifyContent\n\t\t\t) }`\n\t\t);\n\t}\n\n\tif ( usedLayout?.flexWrap && usedLayout.flexWrap === 'nowrap' ) {\n\t\tlayoutClassnames.push( 'is-nowrap' );\n\t}\n\n\treturn layoutClassnames;\n}\n\n/**\n * Generates a CSS rule with the given block's layout styles.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n * @param { string } selector A selector to use in generating the CSS rule.\n *\n * @return { string } CSS rule.\n */\nexport function useLayoutStyles( blockAttributes = {}, blockName, selector ) {\n\tconst { layout = {}, style = {} } = blockAttributes;\n\t// Update type for blocks using legacy layouts.\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || {};\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst [ blockGapSupport ] = useSettings( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\tconst css = fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName,\n\t\tselector,\n\t\tlayout,\n\t\tstyle,\n\t\thasBlockGapSupport,\n\t} );\n\treturn css;\n}\n\nfunction LayoutPanelPure( { layout, setAttributes, name: blockName } ) {\n\tconst settings = useBlockSettings( blockName );\n\t// Block settings come from theme.json under settings.[blockName].\n\tconst { layout: layoutSettings } = settings;\n\t// Layout comes from block attributes.\n\tconst [ defaultThemeLayout ] = useSettings( 'layout' );\n\tconst { themeSupportsLayout } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\tthemeSupportsLayout: getSettings().supportsLayout,\n\t\t};\n\t}, [] );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\t// Layout block support comes from the block's block.json.\n\tconst layoutBlockSupport = getBlockSupport(\n\t\tblockName,\n\t\tlayoutBlockSupportKey,\n\t\t{}\n\t);\n\tconst blockSupportAndThemeSettings = {\n\t\t...layoutSettings,\n\t\t...layoutBlockSupport,\n\t};\n\tconst {\n\t\tallowSwitching,\n\t\tallowEditing = true,\n\t\tallowInheriting = true,\n\t\tdefault: defaultBlockLayout,\n\t} = blockSupportAndThemeSettings;\n\n\tif ( ! allowEditing ) {\n\t\treturn null;\n\t}\n\n\t// Only show the inherit toggle if it's supported,\n\t// a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values),\n\t// and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other.\n\tconst showInheritToggle = !! (\n\t\tallowInheriting &&\n\t\t!! defaultThemeLayout &&\n\t\t( ! layout?.type ||\n\t\t\tlayout?.type === 'default' ||\n\t\t\tlayout?.type === 'constrained' ||\n\t\t\tlayout?.inherit )\n\t);\n\n\tconst usedLayout = layout || defaultBlockLayout || {};\n\tconst {\n\t\tinherit = false,\n\t\ttype = 'default',\n\t\tcontentSize = null,\n\t} = usedLayout;\n\t/**\n\t * `themeSupportsLayout` is only relevant to the `default/flow` or\n\t * `constrained` layouts and it should not be taken into account when other\n\t * `layout` types are used.\n\t */\n\tif (\n\t\t( type === 'default' || type === 'constrained' ) &&\n\t\t! themeSupportsLayout\n\t) {\n\t\treturn null;\n\t}\n\tconst layoutType = getLayoutType( type );\n\tconst constrainedType = getLayoutType( 'constrained' );\n\tconst displayControlsForLegacyLayouts =\n\t\t! usedLayout.type && ( contentSize || inherit );\n\tconst hasContentSizeOrLegacySettings = !! inherit || !! contentSize;\n\n\tconst onChangeType = ( newType ) =>\n\t\tsetAttributes( { layout: { type: newType } } );\n\tconst onChangeLayout = ( newLayout ) =>\n\t\tsetAttributes( { layout: newLayout } );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Layout' ) }>\n\t\t\t\t\t{ showInheritToggle && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tclassName=\"block-editor-hooks__toggle-control\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Inner blocks use content width' ) }\n\t\t\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t\t\ttype:\n\t\t\t\t\t\t\t\t\t\t\t\tlayoutType?.name ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t'constrained' ||\n\t\t\t\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'default'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: 'constrained',\n\t\t\t\t\t\t\t\t\t\t},\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\thelp={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks use content width with options for full and wide widths.'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks will fill the width of this container. Toggle to constrain.'\n\t\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{ ! inherit && allowSwitching && (\n\t\t\t\t\t\t<LayoutTypeSwitcher\n\t\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\t\tonChange={ onChangeType }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ layoutType && layoutType.name !== 'default' && (\n\t\t\t\t\t\t<layoutType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ blockSupportAndThemeSettings }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ constrainedType && displayControlsForLegacyLayouts && (\n\t\t\t\t\t\t<constrainedType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ blockSupportAndThemeSettings }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ ! inherit && layoutType && (\n\t\t\t\t<layoutType.toolBarControls\n\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default {\n\tshareWithChildBlocks: true,\n\tedit: LayoutPanelPure,\n\tattributeKeys: [ 'layout' ],\n\thasSupport( name ) {\n\t\treturn hasLayoutBlockSupport( name );\n\t},\n};\n\nfunction LayoutTypeSwitcher( { type, onChange } ) {\n\treturn (\n\t\t<ButtonGroup>\n\t\t\t{ getLayoutTypes().map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tisPressed={ type === name }\n\t\t\t\t\t\tonClick={ () => onChange( name ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</Button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ButtonGroup>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( 'type' in ( settings.attributes?.layout ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasLayoutBlockSupport( settings ) ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockWithLayoutStyles( { block: BlockListBlock, props } ) {\n\tconst { name, attributes } = props;\n\tconst id = useInstanceId( BlockListBlock );\n\tconst { layout } = attributes;\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( name, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\tconst layoutClasses = useLayoutClasses( attributes, name );\n\n\tconst { kebabCase } = unlock( componentsPrivateApis );\n\tconst selectorPrefix = `wp-container-${ kebabCase( name ) }-is-layout-`;\n\t// Higher specificity to override defaults from theme.json.\n\tconst selector = `.${ selectorPrefix }${ id }.${ selectorPrefix }${ id }`;\n\tconst [ blockGapSupport ] = useSettings( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\n\t// Get CSS string for the current layout type.\n\t// The CSS and `style` element is only output if it is not empty.\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst css = fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName: name,\n\t\tselector,\n\t\tlayout: usedLayout,\n\t\tstyle: attributes?.style,\n\t\thasBlockGapSupport,\n\t} );\n\n\t// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.\n\tconst layoutClassNames = classnames(\n\t\t{\n\t\t\t[ `${ selectorPrefix }${ id }` ]: !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t},\n\t\tlayoutClasses\n\t);\n\n\tuseStyleOverride( { css } );\n\n\treturn (\n\t\t<BlockListBlock\n\t\t\t{ ...props }\n\t\t\t__unstableLayoutClassNames={ layoutClassNames }\n\t\t/>\n\t);\n}\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst blockSupportsLayout = hasLayoutBlockSupport( props.name );\n\t\tconst shouldRenderLayoutStyles = useSelect(\n\t\t\t( select ) => {\n\t\t\t\t// The callback returns early to avoid block editor subscription.\n\t\t\t\tif ( ! blockSupportsLayout ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn ! select( blockEditorStore ).getSettings()\n\t\t\t\t\t.disableLayoutStyles;\n\t\t\t},\n\t\t\t[ blockSupportsLayout ]\n\t\t);\n\n\t\tif ( ! shouldRenderLayoutStyles ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\treturn (\n\t\t\t<BlockWithLayoutStyles block={ BlockListBlock } props={ props } />\n\t\t);\n\t},\n\t'withLayoutStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/layout/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-layout-styles',\n\twithLayoutStyles\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,0BAA0B,EAAEC,aAAa,QAAQ,oBAAoB;AAC9E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,eAAe,EAAEC,eAAe,QAAQ,mBAAmB;AACpE,SAASC,SAAS,QAAQ,iBAAiB;AA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,mBAAmB,CACtB,CAAC;EAED,IAAK,CAAEC,wBAAwB,EAAG;IACjC,OAAOjC,aAAA,CAACwB,cAAc;MAAA,GAAMC;IAAK,CAAI,CAAC;EACvC;EAEA,OACCzB,aAAA,CAACsB,qBAAqB;IAACC,KAAK,EAAGC,cAAgB;IAACC,KAAK,EAAGA;EAAO,CAAE,CAAC;AAEpE,CAAC,EACD,kBACD,CAAC;AAED9G,SAAS,CACR,0BAA0B,EAC1B,0BAA0B,EAC1BwG,YACD,CAAC;AACDxG,SAAS,CACR,uBAAuB,EACvB,uCAAuC,EACvCoH,gBACD,CAAC"}
1
+ {"version":3,"names":["classnames","createHigherOrderComponent","useInstanceId","addFilter","getBlockSupport","hasBlockSupport","useSelect","Button","ButtonGroup","ToggleControl","PanelBody","privateApis","componentsPrivateApis","__","store","blockEditorStore","InspectorControls","useSettings","getLayoutType","getLayoutTypes","useBlockEditingMode","LAYOUT_DEFINITIONS","useBlockSettings","useStyleOverride","unlock","layoutBlockSupportKey","hasLayoutBlockSupport","blockName","useLayoutClasses","blockAttributes","kebabCase","rootPaddingAlignment","select","getSettings","__experimentalFeatures","useRootPaddingAwareAlignments","layout","default","defaultBlockLayout","usedLayout","inherit","contentSize","wideSize","type","layoutClassnames","className","baseClassName","splitBlockName","split","fullBlockName","pop","join","compoundClassName","push","orientation","justifyContent","flexWrap","useLayoutStyles","selector","style","fullLayoutType","blockGapSupport","hasBlockGapSupport","css","getLayoutStyle","LayoutPanelPure","setAttributes","name","clientId","settings","layoutSettings","defaultThemeLayout","themeSupportsLayout","supportsLayout","blockEditingMode","layoutBlockSupport","blockSupportAndThemeSettings","allowSwitching","allowEditing","allowInheriting","showInheritToggle","layoutType","constrainedType","displayControlsForLegacyLayouts","hasContentSizeOrLegacySettings","onChangeType","newType","onChangeLayout","newLayout","createElement","Fragment","title","__nextHasNoMarginBottom","label","checked","onChange","help","LayoutTypeSwitcher","inspectorControls","toolBarControls","shareWithChildBlocks","edit","attributeKeys","hasSupport","map","key","isPressed","onClick","addAttribute","_settings$attributes$","attributes","BlockWithLayoutStyles","block","BlockListBlock","props","id","layoutClasses","selectorPrefix","layoutClassNames","__unstableLayoutClassNames","withLayoutStyles","blockSupportsLayout","shouldRenderLayoutStyles","disableLayoutStyles"],"sources":["@wordpress/block-editor/src/hooks/layout.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tButton,\n\tButtonGroup,\n\tToggleControl,\n\tPanelBody,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport { useSettings } from '../components/use-settings';\nimport { getLayoutType, getLayoutTypes } from '../layouts';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\nimport { LAYOUT_DEFINITIONS } from '../layouts/definitions';\nimport { useBlockSettings, useStyleOverride } from './utils';\nimport { unlock } from '../lock-unlock';\n\nconst layoutBlockSupportKey = 'layout';\n\nfunction hasLayoutBlockSupport( blockName ) {\n\treturn (\n\t\thasBlockSupport( blockName, 'layout' ) ||\n\t\thasBlockSupport( blockName, '__experimentalLayout' )\n\t);\n}\n\n/**\n * Generates the utility classnames for the given block's layout attributes.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n *\n * @return { Array } Array of CSS classname strings.\n */\nexport function useLayoutClasses( blockAttributes = {}, blockName = '' ) {\n\tconst { kebabCase } = unlock( componentsPrivateApis );\n\tconst rootPaddingAlignment = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalFeatures\n\t\t\t?.useRootPaddingAwareAlignments;\n\t}, [] );\n\tconst { layout } = blockAttributes;\n\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( blockName, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst layoutClassnames = [];\n\n\tif ( LAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className ) {\n\t\tconst baseClassName =\n\t\t\tLAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className;\n\t\tconst splitBlockName = blockName.split( '/' );\n\t\tconst fullBlockName =\n\t\t\tsplitBlockName[ 0 ] === 'core'\n\t\t\t\t? splitBlockName.pop()\n\t\t\t\t: splitBlockName.join( '-' );\n\t\tconst compoundClassName = `wp-block-${ fullBlockName }-${ baseClassName }`;\n\t\tlayoutClassnames.push( baseClassName, compoundClassName );\n\t}\n\n\tif (\n\t\t( usedLayout?.inherit ||\n\t\t\tusedLayout?.contentSize ||\n\t\t\tusedLayout?.type === 'constrained' ) &&\n\t\trootPaddingAlignment\n\t) {\n\t\tlayoutClassnames.push( 'has-global-padding' );\n\t}\n\n\tif ( usedLayout?.orientation ) {\n\t\tlayoutClassnames.push( `is-${ kebabCase( usedLayout.orientation ) }` );\n\t}\n\n\tif ( usedLayout?.justifyContent ) {\n\t\tlayoutClassnames.push(\n\t\t\t`is-content-justification-${ kebabCase(\n\t\t\t\tusedLayout.justifyContent\n\t\t\t) }`\n\t\t);\n\t}\n\n\tif ( usedLayout?.flexWrap && usedLayout.flexWrap === 'nowrap' ) {\n\t\tlayoutClassnames.push( 'is-nowrap' );\n\t}\n\n\treturn layoutClassnames;\n}\n\n/**\n * Generates a CSS rule with the given block's layout styles.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n * @param { string } selector A selector to use in generating the CSS rule.\n *\n * @return { string } CSS rule.\n */\nexport function useLayoutStyles( blockAttributes = {}, blockName, selector ) {\n\tconst { layout = {}, style = {} } = blockAttributes;\n\t// Update type for blocks using legacy layouts.\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || {};\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst [ blockGapSupport ] = useSettings( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\tconst css = fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName,\n\t\tselector,\n\t\tlayout,\n\t\tstyle,\n\t\thasBlockGapSupport,\n\t} );\n\treturn css;\n}\n\nfunction LayoutPanelPure( {\n\tlayout,\n\tsetAttributes,\n\tname: blockName,\n\tclientId,\n} ) {\n\tconst settings = useBlockSettings( blockName );\n\t// Block settings come from theme.json under settings.[blockName].\n\tconst { layout: layoutSettings } = settings;\n\t// Layout comes from block attributes.\n\tconst [ defaultThemeLayout ] = useSettings( 'layout' );\n\tconst { themeSupportsLayout } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\tthemeSupportsLayout: getSettings().supportsLayout,\n\t\t};\n\t}, [] );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\t// Layout block support comes from the block's block.json.\n\tconst layoutBlockSupport = getBlockSupport(\n\t\tblockName,\n\t\tlayoutBlockSupportKey,\n\t\t{}\n\t);\n\tconst blockSupportAndThemeSettings = {\n\t\t...layoutSettings,\n\t\t...layoutBlockSupport,\n\t};\n\tconst {\n\t\tallowSwitching,\n\t\tallowEditing = true,\n\t\tallowInheriting = true,\n\t\tdefault: defaultBlockLayout,\n\t} = blockSupportAndThemeSettings;\n\n\tif ( ! allowEditing ) {\n\t\treturn null;\n\t}\n\n\t// Only show the inherit toggle if it's supported,\n\t// a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values),\n\t// and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other.\n\tconst showInheritToggle = !! (\n\t\tallowInheriting &&\n\t\t!! defaultThemeLayout &&\n\t\t( ! layout?.type ||\n\t\t\tlayout?.type === 'default' ||\n\t\t\tlayout?.type === 'constrained' ||\n\t\t\tlayout?.inherit )\n\t);\n\n\tconst usedLayout = layout || defaultBlockLayout || {};\n\tconst {\n\t\tinherit = false,\n\t\ttype = 'default',\n\t\tcontentSize = null,\n\t} = usedLayout;\n\t/**\n\t * `themeSupportsLayout` is only relevant to the `default/flow` or\n\t * `constrained` layouts and it should not be taken into account when other\n\t * `layout` types are used.\n\t */\n\tif (\n\t\t( type === 'default' || type === 'constrained' ) &&\n\t\t! themeSupportsLayout\n\t) {\n\t\treturn null;\n\t}\n\tconst layoutType = getLayoutType( type );\n\tconst constrainedType = getLayoutType( 'constrained' );\n\tconst displayControlsForLegacyLayouts =\n\t\t! usedLayout.type && ( contentSize || inherit );\n\tconst hasContentSizeOrLegacySettings = !! inherit || !! contentSize;\n\n\tconst onChangeType = ( newType ) =>\n\t\tsetAttributes( { layout: { type: newType } } );\n\tconst onChangeLayout = ( newLayout ) =>\n\t\tsetAttributes( { layout: newLayout } );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Layout' ) }>\n\t\t\t\t\t{ showInheritToggle && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tclassName=\"block-editor-hooks__toggle-control\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Inner blocks use content width' ) }\n\t\t\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t\t\ttype:\n\t\t\t\t\t\t\t\t\t\t\t\tlayoutType?.name ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t'constrained' ||\n\t\t\t\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'default'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: 'constrained',\n\t\t\t\t\t\t\t\t\t\t},\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\thelp={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks use content width with options for full and wide widths.'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks will fill the width of this container. Toggle to constrain.'\n\t\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{ ! inherit && allowSwitching && (\n\t\t\t\t\t\t<LayoutTypeSwitcher\n\t\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\t\tonChange={ onChangeType }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ layoutType && layoutType.name !== 'default' && (\n\t\t\t\t\t\t<layoutType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ blockSupportAndThemeSettings }\n\t\t\t\t\t\t\tname={ blockName }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ constrainedType && displayControlsForLegacyLayouts && (\n\t\t\t\t\t\t<constrainedType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ blockSupportAndThemeSettings }\n\t\t\t\t\t\t\tname={ blockName }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ ! inherit && layoutType && (\n\t\t\t\t<layoutType.toolBarControls\n\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\tname={ blockName }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default {\n\tshareWithChildBlocks: true,\n\tedit: LayoutPanelPure,\n\tattributeKeys: [ 'layout' ],\n\thasSupport( name ) {\n\t\treturn hasLayoutBlockSupport( name );\n\t},\n};\n\nfunction LayoutTypeSwitcher( { type, onChange } ) {\n\treturn (\n\t\t<ButtonGroup>\n\t\t\t{ getLayoutTypes().map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tisPressed={ type === name }\n\t\t\t\t\t\tonClick={ () => onChange( name ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</Button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ButtonGroup>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( 'type' in ( settings.attributes?.layout ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasLayoutBlockSupport( settings ) ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockWithLayoutStyles( { block: BlockListBlock, props } ) {\n\tconst { name, attributes } = props;\n\tconst id = useInstanceId( BlockListBlock );\n\tconst { layout } = attributes;\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( name, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\tconst layoutClasses = useLayoutClasses( attributes, name );\n\n\tconst { kebabCase } = unlock( componentsPrivateApis );\n\tconst selectorPrefix = `wp-container-${ kebabCase( name ) }-is-layout-`;\n\t// Higher specificity to override defaults from theme.json.\n\tconst selector = `.${ selectorPrefix }${ id }.${ selectorPrefix }${ id }`;\n\tconst [ blockGapSupport ] = useSettings( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\n\t// Get CSS string for the current layout type.\n\t// The CSS and `style` element is only output if it is not empty.\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst css = fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName: name,\n\t\tselector,\n\t\tlayout: usedLayout,\n\t\tstyle: attributes?.style,\n\t\thasBlockGapSupport,\n\t} );\n\n\t// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.\n\tconst layoutClassNames = classnames(\n\t\t{\n\t\t\t[ `${ selectorPrefix }${ id }` ]: !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t},\n\t\tlayoutClasses\n\t);\n\n\tuseStyleOverride( { css } );\n\n\treturn (\n\t\t<BlockListBlock\n\t\t\t{ ...props }\n\t\t\t__unstableLayoutClassNames={ layoutClassNames }\n\t\t/>\n\t);\n}\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst blockSupportsLayout = hasLayoutBlockSupport( props.name );\n\t\tconst shouldRenderLayoutStyles = useSelect(\n\t\t\t( select ) => {\n\t\t\t\t// The callback returns early to avoid block editor subscription.\n\t\t\t\tif ( ! blockSupportsLayout ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn ! select( blockEditorStore ).getSettings()\n\t\t\t\t\t.disableLayoutStyles;\n\t\t\t},\n\t\t\t[ blockSupportsLayout ]\n\t\t);\n\n\t\tif ( ! shouldRenderLayoutStyles ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\treturn (\n\t\t\t<BlockWithLayoutStyles block={ BlockListBlock } props={ props } />\n\t\t);\n\t},\n\t'withLayoutStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/layout/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-layout-styles',\n\twithLayoutStyles\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,0BAA0B,EAAEC,aAAa,QAAQ,oBAAoB;AAC9E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,eAAe,EAAEC,eAAe,QAAQ,mBAAmB;AACpE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,MAAM,EACNC,WAAW,EACXC,aAAa,EACbC,SAAS,EACTC,WAAW,IAAIC,qBAAqB,QAC9B,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,UAAU;AACpD,SAASC,iBAAiB,QAAQ,eAAe;AACjD,SAASC,WAAW,QAAQ,4BAA4B;AACxD,SAASC,aAAa,EAAEC,cAAc,QAAQ,YAAY;A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A,OACCzB,aAAA,CAACsB,qBAAqB;IAACC,KAAK,EAAGC,cAAgB;IAACC,KAAK,EAAGA;EAAO,CAAE,CAAC;AAEpE,CAAC,EACD,kBACD,CAAC;AAED/G,SAAS,CACR,0BAA0B,EAC1B,0BAA0B,EAC1ByG,YACD,CAAC;AACDzG,SAAS,CACR,uBAAuB,EACvB,uCAAuC,EACvCqH,gBACD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"names":["hasBlockSupport","LineHeightControl","cleanEmptyObject","useSettings","LINE_HEIGHT_SUPPORT_KEY","LineHeightEdit","props","attributes","style","setAttributes","onChange","newLineHeightValue","newStyle","typography","lineHeight","createElement","__unstableInputWidth","__nextHasNoMarginBottom","value","size","useIsLineHeightDisabled","name","blockName","isEnabled"],"sources":["@wordpress/block-editor/src/hooks/line-height.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport LineHeightControl from '../components/line-height-control';\nimport { cleanEmptyObject } from './utils';\nimport { useSettings } from '../components/use-settings';\n\nexport const LINE_HEIGHT_SUPPORT_KEY = 'typography.lineHeight';\n\n/**\n * Inspector control panel containing the line height related configuration\n *\n * @param {Object} props\n *\n * @return {Element} Line height edit element.\n */\nexport function LineHeightEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tconst onChange = ( newLineHeightValue ) => {\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\ttypography: {\n\t\t\t\t...style?.typography,\n\t\t\t\tlineHeight: newLineHeightValue,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( { style: cleanEmptyObject( newStyle ) } );\n\t};\n\treturn (\n\t\t<LineHeightControl\n\t\t\t__unstableInputWidth=\"100%\"\n\t\t\t__nextHasNoMarginBottom={ true }\n\t\t\tvalue={ style?.typography?.lineHeight }\n\t\t\tonChange={ onChange }\n\t\t\tsize=\"__unstable-large\"\n\t\t/>\n\t);\n}\n\n/**\n * Custom hook that checks if line-height settings have been disabled.\n *\n * @param {string} name The name of the block.\n * @return {boolean} Whether setting is disabled.\n */\nexport function useIsLineHeightDisabled( { name: blockName } = {} ) {\n\tconst [ isEnabled ] = useSettings( 'typography.lineHeight' );\n\n\treturn (\n\t\t! isEnabled || ! hasBlockSupport( blockName, LINE_HEIGHT_SUPPORT_KEY )\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,eAAe,QAAQ,mBAAmB;;AAEnD;AACA;AACA;AACA,OAAOC,iBAAiB,MAAM,mCAAmC;AACjE,SAASC,gBAAgB,QAAQ,SAAS;AAC1C,SAASC,WAAW,QAAQ,4BAA4B;AAExD,OAAO,MAAMC,uBAAuB,GAAG,uBAAuB;;AAE9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAAEC,KAAK,EAAG;EACvC,MAAM;IACLC,UAAU,EAAE;MAAEC;IAAM,CAAC;IACrBC;EACD,CAAC,GAAGH,KAAK;EAET,MAAMI,QAAQ,GAAKC,kBAAkB,IAAM;IAC1C,MAAMC,QAAQ,GAAG;MAChB,GAAGJ,KAAK;MACRK,UAAU,EAAE;QACX,GAAGL,KAAK,EAAEK,UAAU;QACpBC,UAAU,EAAEH;MACb;IACD,CAAC;IAEDF,aAAa,CAAE;MAAED,KAAK,EAAEN,gBAAgB,CAAEU,QAAS;IAAE,CAAE,CAAC;EACzD,CAAC;EACD,OACCG,aAAA,CAACd,iBAAiB;IACjBe,oBAAoB,EAAC,MAAM;IAC3BC,uBAAuB,EAAG,IAAM;IAChCC,KAAK,EAAGV,KAAK,EAAEK,UAAU,EAAEC,UAAY;IACvCJ,QAAQ,EAAGA,QAAU;IACrBS,IAAI,EAAC;EAAkB,CACvB,CAAC;AAEJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CAAE;EAAEC,IAAI,EAAEC;AAAU,CAAC,GAAG,CAAC,CAAC,EAAG;EACnE,MAAM,CAAEC,SAAS,CAAE,GAAGpB,WAAW,CAAE,uBAAwB,CAAC;EAE5D,OACC,CAAEoB,SAAS,IAAI,CAAEvB,eAAe,CAAEsB,SAAS,EAAElB,uBAAwB,CAAC;AAExE"}
1
+ {"version":3,"names":["hasBlockSupport","LineHeightControl","cleanEmptyObject","useSettings","LINE_HEIGHT_SUPPORT_KEY","LineHeightEdit","props","attributes","style","setAttributes","onChange","newLineHeightValue","newStyle","typography","lineHeight","createElement","__unstableInputWidth","__nextHasNoMarginBottom","value","size","useIsLineHeightDisabled","name","blockName","isEnabled"],"sources":["@wordpress/block-editor/src/hooks/line-height.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport LineHeightControl from '../components/line-height-control';\nimport { cleanEmptyObject } from './utils';\nimport { useSettings } from '../components/use-settings';\n\nexport const LINE_HEIGHT_SUPPORT_KEY = 'typography.lineHeight';\n\n/**\n * Inspector control panel containing the line height related configuration\n *\n * @param {Object} props\n *\n * @return {Element} Line height edit element.\n */\nexport function LineHeightEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tconst onChange = ( newLineHeightValue ) => {\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\ttypography: {\n\t\t\t\t...style?.typography,\n\t\t\t\tlineHeight: newLineHeightValue,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( { style: cleanEmptyObject( newStyle ) } );\n\t};\n\treturn (\n\t\t<LineHeightControl\n\t\t\t__unstableInputWidth=\"100%\"\n\t\t\t__nextHasNoMarginBottom\n\t\t\tvalue={ style?.typography?.lineHeight }\n\t\t\tonChange={ onChange }\n\t\t\tsize=\"__unstable-large\"\n\t\t/>\n\t);\n}\n\n/**\n * Custom hook that checks if line-height settings have been disabled.\n *\n * @param {string} name The name of the block.\n * @return {boolean} Whether setting is disabled.\n */\nexport function useIsLineHeightDisabled( { name: blockName } = {} ) {\n\tconst [ isEnabled ] = useSettings( 'typography.lineHeight' );\n\n\treturn (\n\t\t! isEnabled || ! hasBlockSupport( blockName, LINE_HEIGHT_SUPPORT_KEY )\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,eAAe,QAAQ,mBAAmB;;AAEnD;AACA;AACA;AACA,OAAOC,iBAAiB,MAAM,mCAAmC;AACjE,SAASC,gBAAgB,QAAQ,SAAS;AAC1C,SAASC,WAAW,QAAQ,4BAA4B;AAExD,OAAO,MAAMC,uBAAuB,GAAG,uBAAuB;;AAE9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAAEC,KAAK,EAAG;EACvC,MAAM;IACLC,UAAU,EAAE;MAAEC;IAAM,CAAC;IACrBC;EACD,CAAC,GAAGH,KAAK;EAET,MAAMI,QAAQ,GAAKC,kBAAkB,IAAM;IAC1C,MAAMC,QAAQ,GAAG;MAChB,GAAGJ,KAAK;MACRK,UAAU,EAAE;QACX,GAAGL,KAAK,EAAEK,UAAU;QACpBC,UAAU,EAAEH;MACb;IACD,CAAC;IAEDF,aAAa,CAAE;MAAED,KAAK,EAAEN,gBAAgB,CAAEU,QAAS;IAAE,CAAE,CAAC;EACzD,CAAC;EACD,OACCG,aAAA,CAACd,iBAAiB;IACjBe,oBAAoB,EAAC,MAAM;IAC3BC,uBAAuB;IACvBC,KAAK,EAAGV,KAAK,EAAEK,UAAU,EAAEC,UAAY;IACvCJ,QAAQ,EAAGA,QAAU;IACrBS,IAAI,EAAC;EAAkB,CACvB,CAAC;AAEJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CAAE;EAAEC,IAAI,EAAEC;AAAU,CAAC,GAAG,CAAC,CAAC,EAAG;EACnE,MAAM,CAAEC,SAAS,CAAE,GAAGpB,WAAW,CAAE,uBAAwB,CAAC;EAE5D,OACC,CAAEoB,SAAS,IAAI,CAAEvB,eAAe,CAAEsB,SAAS,EAAElB,uBAAwB,CAAC;AAExE"}
@@ -0,0 +1,106 @@
1
+ import { createElement } from "react";
2
+ /**
3
+ * WordPress dependencies
4
+ */
5
+ import { useState, useRef, useLayoutEffect, useEffect, useReducer } from '@wordpress/element';
6
+ import isShallowEqual from '@wordpress/is-shallow-equal';
7
+
8
+ /**
9
+ * Internal dependencies
10
+ */
11
+ import BlockPopoverCover from '../components/block-popover/cover';
12
+ import { __unstableUseBlockElement as useBlockElement } from '../components/block-list/use-block-props/use-block-refs';
13
+ function SpacingVisualizer({
14
+ clientId,
15
+ value,
16
+ computeStyle,
17
+ forceShow
18
+ }) {
19
+ const blockElement = useBlockElement(clientId);
20
+ const [style, updateStyle] = useReducer(() => computeStyle(blockElement));
21
+ useLayoutEffect(() => {
22
+ if (!blockElement) {
23
+ return;
24
+ }
25
+ // It's not sufficient to read the computed spacing value when value.spacing changes as
26
+ // useEffect may run before the browser recomputes CSS. We therefore combine
27
+ // useLayoutEffect and two rAF calls to ensure that we read the spacing after the current
28
+ // paint but before the next paint.
29
+ // See https://github.com/WordPress/gutenberg/pull/59227.
30
+ window.requestAnimationFrame(() => window.requestAnimationFrame(updateStyle));
31
+ }, [blockElement, value]);
32
+ const previousValue = useRef(value);
33
+ const [isActive, setIsActive] = useState(false);
34
+ useEffect(() => {
35
+ if (isShallowEqual(value, previousValue.current) || forceShow) {
36
+ return;
37
+ }
38
+ setIsActive(true);
39
+ previousValue.current = value;
40
+ const timeout = setTimeout(() => {
41
+ setIsActive(false);
42
+ }, 400);
43
+ return () => {
44
+ setIsActive(false);
45
+ clearTimeout(timeout);
46
+ };
47
+ }, [value, forceShow]);
48
+ if (!isActive && !forceShow) {
49
+ return null;
50
+ }
51
+ return createElement(BlockPopoverCover, {
52
+ clientId: clientId,
53
+ __unstablePopoverSlot: "block-toolbar"
54
+ }, createElement("div", {
55
+ className: "block-editor__spacing-visualizer",
56
+ style: style
57
+ }));
58
+ }
59
+ function getComputedCSS(element, property) {
60
+ return element.ownerDocument.defaultView.getComputedStyle(element).getPropertyValue(property);
61
+ }
62
+ export function MarginVisualizer({
63
+ clientId,
64
+ value,
65
+ forceShow
66
+ }) {
67
+ return createElement(SpacingVisualizer, {
68
+ clientId: clientId,
69
+ value: value?.spacing?.margin,
70
+ computeStyle: blockElement => {
71
+ const top = getComputedCSS(blockElement, 'margin-top');
72
+ const right = getComputedCSS(blockElement, 'margin-right');
73
+ const bottom = getComputedCSS(blockElement, 'margin-bottom');
74
+ const left = getComputedCSS(blockElement, 'margin-left');
75
+ return {
76
+ borderTopWidth: top,
77
+ borderRightWidth: right,
78
+ borderBottomWidth: bottom,
79
+ borderLeftWidth: left,
80
+ top: top ? `-${top}` : 0,
81
+ right: right ? `-${right}` : 0,
82
+ bottom: bottom ? `-${bottom}` : 0,
83
+ left: left ? `-${left}` : 0
84
+ };
85
+ },
86
+ forceShow: forceShow
87
+ });
88
+ }
89
+ export function PaddingVisualizer({
90
+ clientId,
91
+ value,
92
+ forceShow
93
+ }) {
94
+ return createElement(SpacingVisualizer, {
95
+ clientId: clientId,
96
+ value: value?.spacing?.padding,
97
+ computeStyle: blockElement => ({
98
+ borderTopWidth: getComputedCSS(blockElement, 'padding-top'),
99
+ borderRightWidth: getComputedCSS(blockElement, 'padding-right'),
100
+ borderBottomWidth: getComputedCSS(blockElement, 'padding-bottom'),
101
+ borderLeftWidth: getComputedCSS(blockElement, 'padding-left')
102
+ }),
103
+ forceShow: forceShow
104
+ });
105
+ }
106
+ //# sourceMappingURL=spacing-visualizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useState","useRef","useLayoutEffect","useEffect","useReducer","isShallowEqual","BlockPopoverCover","__unstableUseBlockElement","useBlockElement","SpacingVisualizer","clientId","value","computeStyle","forceShow","blockElement","style","updateStyle","window","requestAnimationFrame","previousValue","isActive","setIsActive","current","timeout","setTimeout","clearTimeout","createElement","__unstablePopoverSlot","className","getComputedCSS","element","property","ownerDocument","defaultView","getComputedStyle","getPropertyValue","MarginVisualizer","spacing","margin","top","right","bottom","left","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","PaddingVisualizer","padding"],"sources":["@wordpress/block-editor/src/hooks/spacing-visualizer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseRef,\n\tuseLayoutEffect,\n\tuseEffect,\n\tuseReducer,\n} from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport BlockPopoverCover from '../components/block-popover/cover';\nimport { __unstableUseBlockElement as useBlockElement } from '../components/block-list/use-block-props/use-block-refs';\n\nfunction SpacingVisualizer( { clientId, value, computeStyle, forceShow } ) {\n\tconst blockElement = useBlockElement( clientId );\n\tconst [ style, updateStyle ] = useReducer( () =>\n\t\tcomputeStyle( blockElement )\n\t);\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! blockElement ) {\n\t\t\treturn;\n\t\t}\n\t\t// It's not sufficient to read the computed spacing value when value.spacing changes as\n\t\t// useEffect may run before the browser recomputes CSS. We therefore combine\n\t\t// useLayoutEffect and two rAF calls to ensure that we read the spacing after the current\n\t\t// paint but before the next paint.\n\t\t// See https://github.com/WordPress/gutenberg/pull/59227.\n\t\twindow.requestAnimationFrame( () =>\n\t\t\twindow.requestAnimationFrame( updateStyle )\n\t\t);\n\t}, [ blockElement, value ] );\n\n\tconst previousValue = useRef( value );\n\tconst [ isActive, setIsActive ] = useState( false );\n\n\tuseEffect( () => {\n\t\tif ( isShallowEqual( value, previousValue.current ) || forceShow ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsActive( true );\n\t\tpreviousValue.current = value;\n\n\t\tconst timeout = setTimeout( () => {\n\t\t\tsetIsActive( false );\n\t\t}, 400 );\n\n\t\treturn () => {\n\t\t\tsetIsActive( false );\n\t\t\tclearTimeout( timeout );\n\t\t};\n\t}, [ value, forceShow ] );\n\n\tif ( ! isActive && ! forceShow ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockPopoverCover\n\t\t\tclientId={ clientId }\n\t\t\t__unstablePopoverSlot=\"block-toolbar\"\n\t\t>\n\t\t\t<div className=\"block-editor__spacing-visualizer\" style={ style } />\n\t\t</BlockPopoverCover>\n\t);\n}\n\nfunction getComputedCSS( element, property ) {\n\treturn element.ownerDocument.defaultView\n\t\t.getComputedStyle( element )\n\t\t.getPropertyValue( property );\n}\n\nexport function MarginVisualizer( { clientId, value, forceShow } ) {\n\treturn (\n\t\t<SpacingVisualizer\n\t\t\tclientId={ clientId }\n\t\t\tvalue={ value?.spacing?.margin }\n\t\t\tcomputeStyle={ ( blockElement ) => {\n\t\t\t\tconst top = getComputedCSS( blockElement, 'margin-top' );\n\t\t\t\tconst right = getComputedCSS( blockElement, 'margin-right' );\n\t\t\t\tconst bottom = getComputedCSS( blockElement, 'margin-bottom' );\n\t\t\t\tconst left = getComputedCSS( blockElement, 'margin-left' );\n\t\t\t\treturn {\n\t\t\t\t\tborderTopWidth: top,\n\t\t\t\t\tborderRightWidth: right,\n\t\t\t\t\tborderBottomWidth: bottom,\n\t\t\t\t\tborderLeftWidth: left,\n\t\t\t\t\ttop: top ? `-${ top }` : 0,\n\t\t\t\t\tright: right ? `-${ right }` : 0,\n\t\t\t\t\tbottom: bottom ? `-${ bottom }` : 0,\n\t\t\t\t\tleft: left ? `-${ left }` : 0,\n\t\t\t\t};\n\t\t\t} }\n\t\t\tforceShow={ forceShow }\n\t\t/>\n\t);\n}\n\nexport function PaddingVisualizer( { clientId, value, forceShow } ) {\n\treturn (\n\t\t<SpacingVisualizer\n\t\t\tclientId={ clientId }\n\t\t\tvalue={ value?.spacing?.padding }\n\t\t\tcomputeStyle={ ( blockElement ) => ( {\n\t\t\t\tborderTopWidth: getComputedCSS( blockElement, 'padding-top' ),\n\t\t\t\tborderRightWidth: getComputedCSS(\n\t\t\t\t\tblockElement,\n\t\t\t\t\t'padding-right'\n\t\t\t\t),\n\t\t\t\tborderBottomWidth: getComputedCSS(\n\t\t\t\t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gB,EAAEJ,KAAK;QACvBK,iBAAiB,EAAEJ,MAAM;QACzBK,eAAe,EAAEJ,IAAI;QACrBH,GAAG,EAAEA,GAAG,GAAI,IAAIA,GAAK,EAAC,GAAG,CAAC;QAC1BC,KAAK,EAAEA,KAAK,GAAI,IAAIA,KAAO,EAAC,GAAG,CAAC;QAChCC,MAAM,EAAEA,MAAM,GAAI,IAAIA,MAAQ,EAAC,GAAG,CAAC;QACnCC,IAAI,EAAEA,IAAI,GAAI,IAAIA,IAAM,EAAC,GAAG;MAC7B,CAAC;IACF,CAAG;IACH7B,SAAS,EAAGA;EAAW,CACvB,CAAC;AAEJ;AAEA,OAAO,SAASkC,iBAAiBA,CAAE;EAAErC,QAAQ;EAAEC,KAAK;EAAEE;AAAU,CAAC,EAAG;EACnE,OACCa,aAAA,CAACjB,iBAAiB;IACjBC,QAAQ,EAAGA,QAAU;IACrBC,KAAK,EAAGA,KAAK,EAAE0B,OAAO,EAAEW,OAAS;IACjCpC,YAAY,EAAKE,YAAY,KAAQ;MACpC6B,cAAc,EAAEd,cAAc,CAAEf,YAAY,EAAE,aAAc,CAAC;MAC7D8B,gBAAgB,EAAEf,cAAc,CAC/Bf,YAAY,EACZ,eACD,CAAC;MACD+B,iBAAiB,EAAEhB,cAAc,CAChCf,YAAY,EACZ,gBACD,CAAC;MACDgC,eAAe,EAAEjB,cAAc,CAAEf,YAAY,EAAE,cAAe;IAC/D,CAAC,CAAI;IACLD,SAAS,EAAGA;EAAW,CACvB,CAAC;AAEJ"}
@@ -1,16 +1,17 @@
1
- import { createElement } from "react";
1
+ import { createElement, Fragment } from "react";
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
5
- import { getBlockType } from '@wordpress/blocks';
5
+ import { getBlockType, store as blocksStore } from '@wordpress/blocks';
6
6
  import { createHigherOrderComponent } from '@wordpress/compose';
7
7
  import { useSelect } from '@wordpress/data';
8
+ import { useLayoutEffect, useCallback, useState } from '@wordpress/element';
8
9
  import { addFilter } from '@wordpress/hooks';
10
+ import { RichTextData } from '@wordpress/rich-text';
11
+
9
12
  /**
10
13
  * Internal dependencies
11
14
  */
12
- import { store as blockEditorStore } from '../store';
13
- import { useBlockEditContext } from '../components/block-edit/context';
14
15
  import { unlock } from '../lock-unlock';
15
16
 
16
17
  /** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */
@@ -23,70 +24,192 @@ import { unlock } from '../lock-unlock';
23
24
  * @return {WPHigherOrderComponent} Higher-order component.
24
25
  */
25
26
 
26
- export const BLOCK_BINDINGS_ALLOWED_BLOCKS = {
27
+ const BLOCK_BINDINGS_ALLOWED_BLOCKS = {
27
28
  'core/paragraph': ['content'],
28
29
  'core/heading': ['content'],
29
30
  'core/image': ['url', 'title', 'alt'],
30
31
  'core/button': ['url', 'text', 'linkTarget']
31
32
  };
32
- const createEditFunctionWithBindingsAttribute = () => createHigherOrderComponent(BlockEdit => props => {
33
- const {
34
- clientId,
35
- name: blockName
36
- } = useBlockEditContext();
33
+
34
+ /**
35
+ * Based on the given block name,
36
+ * check if it is possible to bind the block.
37
+ *
38
+ * @param {string} blockName - The block name.
39
+ * @return {boolean} Whether it is possible to bind the block to sources.
40
+ */
41
+ export function canBindBlock(blockName) {
42
+ return blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS;
43
+ }
44
+
45
+ /**
46
+ * Based on the given block name and attribute name,
47
+ * check if it is possible to bind the block attribute.
48
+ *
49
+ * @param {string} blockName - The block name.
50
+ * @param {string} attributeName - The attribute name.
51
+ * @return {boolean} Whether it is possible to bind the block attribute.
52
+ */
53
+ export function canBindAttribute(blockName, attributeName) {
54
+ return canBindBlock(blockName) && BLOCK_BINDINGS_ALLOWED_BLOCKS[blockName].includes(attributeName);
55
+ }
56
+
57
+ /**
58
+ * This component is responsible for detecting and
59
+ * propagating data changes from the source to the block.
60
+ *
61
+ * @param {Object} props - The component props.
62
+ * @param {string} props.attrName - The attribute name.
63
+ * @param {Object} props.blockProps - The block props with bound attribute.
64
+ * @param {Object} props.source - Source handler.
65
+ * @param {Object} props.args - The arguments to pass to the source.
66
+ * @param {Function} props.onPropValueChange - The function to call when the attribute value changes.
67
+ * @return {null} Data-handling component. Render nothing.
68
+ */
69
+ const BindingConnector = ({
70
+ args,
71
+ attrName,
72
+ blockProps,
73
+ source,
74
+ onPropValueChange
75
+ }) => {
37
76
  const {
38
- getBlockBindingsSource
39
- } = unlock(useSelect(blockEditorStore));
77
+ placeholder,
78
+ value: propValue
79
+ } = source.useSource(blockProps, args);
40
80
  const {
41
- getBlockAttributes
42
- } = useSelect(blockEditorStore);
43
- const updatedAttributes = getBlockAttributes(clientId);
44
- if (updatedAttributes?.metadata?.bindings) {
45
- Object.entries(updatedAttributes.metadata.bindings).forEach(([attributeName, settings]) => {
46
- const source = getBlockBindingsSource(settings.source);
47
- if (source && source.useSource) {
48
- // Second argument (`updateMetaValue`) will be used to update the value in the future.
49
- const {
50
- placeholder,
51
- useValue: [metaValue = null] = []
52
- } = source.useSource(props, settings.args);
53
- if (placeholder && !metaValue) {
54
- // If the attribute is `src` or `href`, a placeholder can't be used because it is not a valid url.
55
- // Adding this workaround until attributes and metadata fields types are improved and include `url`.
56
- const htmlAttribute = getBlockType(blockName).attributes[attributeName].attribute;
57
- if (htmlAttribute === 'src' || htmlAttribute === 'href') {
58
- updatedAttributes[attributeName] = null;
59
- } else {
60
- updatedAttributes[attributeName] = placeholder;
61
- }
62
- }
63
- if (metaValue) {
64
- updatedAttributes[attributeName] = metaValue;
65
- }
81
+ name: blockName
82
+ } = blockProps;
83
+ const attrValue = blockProps.attributes[attrName];
84
+ const updateBoundAttibute = useCallback((newAttrValue, prevAttrValue) => {
85
+ /*
86
+ * If the attribute is a RichTextData instance,
87
+ * (core/paragraph, core/heading, core/button, etc.)
88
+ * compare its HTML representation with the new value.
89
+ *
90
+ * To do: it looks like a workaround.
91
+ * Consider improving the attribute and metadata fields types.
92
+ */
93
+ if (prevAttrValue instanceof RichTextData) {
94
+ // Bail early if the Rich Text value is the same.
95
+ if (prevAttrValue.toHTMLString() === newAttrValue) {
96
+ return;
66
97
  }
98
+
99
+ /*
100
+ * To preserve the value type,
101
+ * convert the new value to a RichTextData instance.
102
+ */
103
+ newAttrValue = RichTextData.fromHTMLString(newAttrValue);
104
+ }
105
+ if (prevAttrValue === newAttrValue) {
106
+ return;
107
+ }
108
+ onPropValueChange({
109
+ [attrName]: newAttrValue
67
110
  });
68
- }
69
- return createElement(BlockEdit, {
70
- key: "edit",
111
+ }, [attrName, onPropValueChange]);
112
+ useLayoutEffect(() => {
113
+ if (typeof propValue !== 'undefined') {
114
+ updateBoundAttibute(propValue, attrValue);
115
+ } else if (placeholder) {
116
+ /*
117
+ * Placeholder fallback.
118
+ * If the attribute is `src` or `href`,
119
+ * a placeholder can't be used because it is not a valid url.
120
+ * Adding this workaround until
121
+ * attributes and metadata fields types are improved and include `url`.
122
+ */
123
+ const htmlAttribute = getBlockType(blockName).attributes[attrName].attribute;
124
+ if (htmlAttribute === 'src' || htmlAttribute === 'href') {
125
+ updateBoundAttibute(null);
126
+ return;
127
+ }
128
+ updateBoundAttibute(placeholder);
129
+ }
130
+ }, [updateBoundAttibute, propValue, attrValue, placeholder, blockName, attrName]);
131
+ return null;
132
+ };
133
+
134
+ /**
135
+ * BlockBindingBridge acts like a component wrapper
136
+ * that connects the bound attributes of a block
137
+ * to the source handlers.
138
+ * For this, it creates a BindingConnector for each bound attribute.
139
+ *
140
+ * @param {Object} props - The component props.
141
+ * @param {Object} props.blockProps - The BlockEdit props object.
142
+ * @param {Object} props.bindings - The block bindings settings.
143
+ * @param {Function} props.onPropValueChange - The function to call when the attribute value changes.
144
+ * @return {null} Data-handling component. Render nothing.
145
+ */
146
+ function BlockBindingBridge({
147
+ blockProps,
148
+ bindings,
149
+ onPropValueChange
150
+ }) {
151
+ const blockBindingsSources = unlock(useSelect(blocksStore)).getAllBlockBindingsSources();
152
+ return createElement(Fragment, null, Object.entries(bindings).map(([attrName, boundAttribute]) => {
153
+ // Bail early if the block doesn't have a valid source handler.
154
+ const source = blockBindingsSources[boundAttribute.source];
155
+ if (!source?.useSource) {
156
+ return null;
157
+ }
158
+ return createElement(BindingConnector, {
159
+ key: attrName,
160
+ attrName: attrName,
161
+ source: source,
162
+ blockProps: blockProps,
163
+ args: boundAttribute.args,
164
+ onPropValueChange: onPropValueChange
165
+ });
166
+ }));
167
+ }
168
+ const withBlockBindingSupport = createHigherOrderComponent(BlockEdit => props => {
169
+ /*
170
+ * Collect and update the bound attributes
171
+ * in a separate state.
172
+ */
173
+ const [boundAttributes, setBoundAttributes] = useState({});
174
+ const updateBoundAttributes = useCallback(newAttributes => setBoundAttributes(prev => ({
175
+ ...prev,
176
+ ...newAttributes
177
+ })), []);
178
+
179
+ /*
180
+ * Create binding object filtering
181
+ * only the attributes that can be bound.
182
+ */
183
+ const bindings = Object.fromEntries(Object.entries(props.attributes.metadata?.bindings || {}).filter(([attrName]) => canBindAttribute(props.name, attrName)));
184
+ return createElement(Fragment, null, Object.keys(bindings).length > 0 && createElement(BlockBindingBridge, {
185
+ blockProps: props,
186
+ bindings: bindings,
187
+ onPropValueChange: updateBoundAttributes
188
+ }), createElement(BlockEdit, {
71
189
  ...props,
72
- attributes: updatedAttributes
73
- });
74
- }, 'useBoundAttributes');
190
+ attributes: {
191
+ ...props.attributes,
192
+ ...boundAttributes
193
+ }
194
+ }));
195
+ }, 'withBlockBindingSupport');
75
196
 
76
197
  /**
77
198
  * Filters a registered block's settings to enhance a block's `edit` component
78
199
  * to upgrade bound attributes.
79
200
  *
80
- * @param {WPBlockSettings} settings Registered block settings.
81
- *
201
+ * @param {WPBlockSettings} settings - Registered block settings.
202
+ * @param {string} name - Block name.
82
203
  * @return {WPBlockSettings} Filtered block settings.
83
204
  */
84
- function shimAttributeSource(settings) {
85
- if (!(settings.name in BLOCK_BINDINGS_ALLOWED_BLOCKS)) {
205
+ function shimAttributeSource(settings, name) {
206
+ if (!canBindBlock(name)) {
86
207
  return settings;
87
208
  }
88
- settings.edit = createEditFunctionWithBindingsAttribute()(settings.edit);
89
- return settings;
209
+ return {
210
+ ...settings,
211
+ edit: withBlockBindingSupport(settings.edit)
212
+ };
90
213
  }
91
214
  addFilter('blocks.registerBlockType', 'core/editor/custom-sources-backwards-compatibility/shim-attribute-source', shimAttributeSource);
92
215
  //# sourceMappingURL=use-bindings-attributes.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getBlockType","createHigherOrderComponent","useSelect","addFilter","store","blockEditorStore","useBlockEditContext","unlock","BLOCK_BINDINGS_ALLOWED_BLOCKS","createEditFunctionWithBindingsAttribute","BlockEdit","props","clientId","name","blockName","getBlockBindingsSource","getBlockAttributes","updatedAttributes","metadata","bindings","Object","entries","forEach","attributeName","settings","source","useSource","placeholder","useValue","metaValue","args","htmlAttribute","attributes","attribute","createElement","key","shimAttributeSource","edit"],"sources":["@wordpress/block-editor/src/hooks/use-bindings-attributes.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockType } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { addFilter } from '@wordpress/hooks';\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { useBlockEditContext } from '../components/block-edit/context';\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\nexport const BLOCK_BINDINGS_ALLOWED_BLOCKS = {\n\t'core/paragraph': [ 'content' ],\n\t'core/heading': [ 'content' ],\n\t'core/image': [ 'url', 'title', 'alt' ],\n\t'core/button': [ 'url', 'text', 'linkTarget' ],\n};\n\nconst createEditFunctionWithBindingsAttribute = () =>\n\tcreateHigherOrderComponent(\n\t\t( BlockEdit ) => ( props ) => {\n\t\t\tconst { clientId, name: blockName } = useBlockEditContext();\n\t\t\tconst { getBlockBindingsSource } = unlock(\n\t\t\t\tuseSelect( blockEditorStore )\n\t\t\t);\n\t\t\tconst { getBlockAttributes } = useSelect( blockEditorStore );\n\n\t\t\tconst updatedAttributes = getBlockAttributes( clientId );\n\t\t\tif ( updatedAttributes?.metadata?.bindings ) {\n\t\t\t\tObject.entries( updatedAttributes.metadata.bindings ).forEach(\n\t\t\t\t\t( [ attributeName, settings ] ) => {\n\t\t\t\t\t\tconst source = getBlockBindingsSource(\n\t\t\t\t\t\t\tsettings.source\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( source && source.useSource ) {\n\t\t\t\t\t\t\t// Second argument (`updateMetaValue`) will be used to update the value in the future.\n\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\tplaceholder,\n\t\t\t\t\t\t\t\tuseValue: [ metaValue = null ] = [],\n\t\t\t\t\t\t\t} = source.useSource( props, settings.args );\n\n\t\t\t\t\t\t\tif ( placeholder && ! metaValue ) {\n\t\t\t\t\t\t\t\t// If the attribute is `src` or `href`, a placeholder can't be used because it is not a valid url.\n\t\t\t\t\t\t\t\t// Adding this workaround until attributes and metadata fields types are improved and include `url`.\n\t\t\t\t\t\t\t\tconst htmlAttribute =\n\t\t\t\t\t\t\t\t\tgetBlockType( blockName ).attributes[\n\t\t\t\t\t\t\t\t\t\tattributeName\n\t\t\t\t\t\t\t\t\t].attribute;\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\thtmlAttribute === 'src' ||\n\t\t\t\t\t\t\t\t\thtmlAttribute === 'href'\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tupdatedAttributes[ attributeName ] = null;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tupdatedAttributes[ attributeName ] =\n\t\t\t\t\t\t\t\t\t\tplaceholder;\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\tif ( metaValue ) {\n\t\t\t\t\t\t\t\tupdatedAttributes[ attributeName ] = metaValue;\n\t\t\t\t\t\t\t}\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 (\n\t\t\t\t<BlockEdit\n\t\t\t\t\tkey=\"edit\"\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tattributes={ updatedAttributes }\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t\t'useBoundAttributes'\n\t);\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 *\n * @return {WPBlockSettings} Filtered block settings.\n */\nfunction shimAttributeSource( settings ) {\n\tif ( ! ( settings.name in BLOCK_BINDINGS_ALLOWED_BLOCKS ) ) {\n\t\treturn settings;\n\t}\n\tsettings.edit = createEditFunctionWithBindingsAttribute()( settings.edit );\n\n\treturn settings;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/custom-sources-backwards-compatibility/shim-attribute-source',\n\tshimAttributeSource\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,mBAAmB;AAChD,SAASC,0BAA0B,QAAQ,oBAAoB;AAC/D,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,SAAS,QAAQ,kBAAkB;AAC5C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,UAAU;AACpD,SAASC,mBAAmB,QAAQ,kCAAkC;AACtE,SAASC,MAAM,QAAQ,gBAAgB;;AAEvC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,6BAA6B,GAAG;EAC5C,gBAAgB,EAAE,CAAE,SAAS,CAAE;EAC/B,cAAc,EAAE,CAAE,SAAS,CAAE;EAC7B,YAAY,EAAE,CAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAE;EACvC,aA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E,GACjCI,WAAW;UACb;QACD;QAEA,IAAKE,SAAS,EAAG;UAChBZ,iBAAiB,CAAEM,aAAa,CAAE,GAAGM,SAAS;QAC/C;MACD;IACD,CACD,CAAC;EACF;EAEA,OACCK,aAAA,CAACxB,SAAS;IACTyB,GAAG,EAAC,MAAM;IAAA,GACLxB,KAAK;IACVqB,UAAU,EAAGf;EAAmB,CAChC,CAAC;AAEJ,CAAC,EACD,oBACD,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASmB,mBAAmBA,CAAEZ,QAAQ,EAAG;EACxC,IAAK,EAAIA,QAAQ,CAACX,IAAI,IAAIL,6BAA6B,CAAE,EAAG;IAC3D,OAAOgB,QAAQ;EAChB;EACAA,QAAQ,CAACa,IAAI,GAAG5B,uCAAuC,CAAC,CAAC,CAAEe,QAAQ,CAACa,IAAK,CAAC;EAE1E,OAAOb,QAAQ;AAChB;AAEArB,SAAS,CACR,0BAA0B,EAC1B,0EAA0E,EAC1EiC,mBACD,CAAC"}
1
+ {"version":3,"names":["getBlockType","store","blocksStore","createHigherOrderComponent","useSelect","useLayoutEffect","useCallback","useState","addFilter","RichTextData","unlock","BLOCK_BINDINGS_ALLOWED_BLOCKS","canBindBlock","blockName","canBindAttribute","attributeName","includes","BindingConnector","args","attrName","blockProps","source","onPropValueChange","placeholder","value","propValue","useSource","name","attrValue","attributes","updateBoundAttibute","newAttrValue","prevAttrValue","toHTMLString","fromHTMLString","htmlAttribute","attribute","BlockBindingBridge","bindings","blockBindingsSources","getAllBlockBindingsSources","createElement","Fragment","Object","entries","map","boundAttribute","key","withBlockBindingSupport","BlockEdit","props","boundAttributes","setBoundAttributes","updateBoundAttributes","newAttributes","prev","fromEntries","metadata","filter","keys","length","shimAttributeSource","settings","edit"],"sources":["@wordpress/block-editor/src/hooks/use-bindings-attributes.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockType, store as blocksStore } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useLayoutEffect, useCallback, useState } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\nimport { RichTextData } from '@wordpress/rich-text';\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': [ 'url', 'title', 'alt' ],\n\t'core/button': [ 'url', 'text', 'linkTarget' ],\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\n/**\n * This component is responsible for detecting and\n * propagating data changes from the source to the block.\n *\n * @param {Object} props - The component props.\n * @param {string} props.attrName - The attribute name.\n * @param {Object} props.blockProps - The block props with bound attribute.\n * @param {Object} props.source - Source handler.\n * @param {Object} props.args - The arguments to pass to the source.\n * @param {Function} props.onPropValueChange - The function to call when the attribute value changes.\n * @return {null} Data-handling component. Render nothing.\n */\nconst BindingConnector = ( {\n\targs,\n\tattrName,\n\tblockProps,\n\tsource,\n\tonPropValueChange,\n} ) => {\n\tconst { placeholder, value: propValue } = source.useSource(\n\t\tblockProps,\n\t\targs\n\t);\n\n\tconst { name: blockName } = blockProps;\n\tconst attrValue = blockProps.attributes[ attrName ];\n\n\tconst updateBoundAttibute = useCallback(\n\t\t( newAttrValue, prevAttrValue ) => {\n\t\t\t/*\n\t\t\t * If the attribute is a RichTextData instance,\n\t\t\t * (core/paragraph, core/heading, core/button, etc.)\n\t\t\t * compare its HTML representation with the new value.\n\t\t\t *\n\t\t\t * To do: it looks like a workaround.\n\t\t\t * Consider improving the attribute and metadata fields types.\n\t\t\t */\n\t\t\tif ( prevAttrValue instanceof RichTextData ) {\n\t\t\t\t// Bail early if the Rich Text value is the same.\n\t\t\t\tif ( prevAttrValue.toHTMLString() === newAttrValue ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t/*\n\t\t\t\t * To preserve the value type,\n\t\t\t\t * convert the new value to a RichTextData instance.\n\t\t\t\t */\n\t\t\t\tnewAttrValue = RichTextData.fromHTMLString( newAttrValue );\n\t\t\t}\n\n\t\t\tif ( prevAttrValue === newAttrValue ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tonPropValueChange( { [ attrName ]: newAttrValue } );\n\t\t},\n\t\t[ attrName, onPropValueChange ]\n\t);\n\n\tuseLayoutEffect( () => {\n\t\tif ( typeof propValue !== 'undefined' ) {\n\t\t\tupdateBoundAttibute( propValue, attrValue );\n\t\t} else if ( placeholder ) {\n\t\t\t/*\n\t\t\t * Placeholder fallback.\n\t\t\t * If the attribute is `src` or `href`,\n\t\t\t * a placeholder can't be used because it is not a valid url.\n\t\t\t * Adding this workaround until\n\t\t\t * attributes and metadata fields types are improved and include `url`.\n\t\t\t */\n\t\t\tconst htmlAttribute =\n\t\t\t\tgetBlockType( blockName ).attributes[ attrName ].attribute;\n\n\t\t\tif ( htmlAttribute === 'src' || htmlAttribute === 'href' ) {\n\t\t\t\tupdateBoundAttibute( null );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tupdateBoundAttibute( placeholder );\n\t\t}\n\t}, [\n\t\tupdateBoundAttibute,\n\t\tpropValue,\n\t\tattrValue,\n\t\tplaceholder,\n\t\tblockName,\n\t\tattrName,\n\t] );\n\n\treturn null;\n};\n\n/**\n * BlockBindingBridge acts like a component wrapper\n * that connects the bound attributes of a block\n * to the source handlers.\n * For this, it creates a BindingConnector for each bound attribute.\n *\n * @param {Object} props - The component props.\n * @param {Object} props.blockProps - The BlockEdit props object.\n * @param {Object} props.bindings - The block bindings settings.\n * @param {Function} props.onPropValueChange - The function to call when the attribute value changes.\n * @return {null} Data-handling component. Render nothing.\n */\nfunction BlockBindingBridge( { blockProps, bindings, onPropValueChange } ) {\n\tconst blockBindingsSources = unlock(\n\t\tuseSelect( blocksStore )\n\t).getAllBlockBindingsSources();\n\n\treturn (\n\t\t<>\n\t\t\t{ Object.entries( bindings ).map(\n\t\t\t\t( [ attrName, boundAttribute ] ) => {\n\t\t\t\t\t// Bail early if the block doesn't have a valid source handler.\n\t\t\t\t\tconst source =\n\t\t\t\t\t\tblockBindingsSources[ boundAttribute.source ];\n\t\t\t\t\tif ( ! source?.useSource ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<BindingConnector\n\t\t\t\t\t\t\tkey={ attrName }\n\t\t\t\t\t\t\tattrName={ attrName }\n\t\t\t\t\t\t\tsource={ source }\n\t\t\t\t\t\t\tblockProps={ blockProps }\n\t\t\t\t\t\t\targs={ boundAttribute.args }\n\t\t\t\t\t\t\tonPropValueChange={ onPropValueChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nconst withBlockBindingSupport = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\t/*\n\t\t * Collect and update the bound attributes\n\t\t * in a separate state.\n\t\t */\n\t\tconst [ boundAttributes, setBoundAttributes ] = useState( {} );\n\t\tconst updateBoundAttributes = useCallback(\n\t\t\t( newAttributes ) =>\n\t\t\t\tsetBoundAttributes( ( prev ) => ( {\n\t\t\t\t\t...prev,\n\t\t\t\t\t...newAttributes,\n\t\t\t\t} ) ),\n\t\t\t[]\n\t\t);\n\n\t\t/*\n\t\t * Create binding object filtering\n\t\t * only the attributes that can be bound.\n\t\t */\n\t\tconst bindings = Object.fromEntries(\n\t\t\tObject.entries( props.attributes.metadata?.bindings || {} ).filter(\n\t\t\t\t( [ attrName ] ) => canBindAttribute( props.name, attrName )\n\t\t\t)\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ Object.keys( bindings ).length > 0 && (\n\t\t\t\t\t<BlockBindingBridge\n\t\t\t\t\t\tblockProps={ props }\n\t\t\t\t\t\tbindings={ bindings }\n\t\t\t\t\t\tonPropValueChange={ updateBoundAttributes }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\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/>\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":";AAAA;AACA;AACA;AACA,SAASA,YAAY,EAAEC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACtE,SAASC,0BAA0B,QAAQ,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AK,CAACvB,IAAI,EAAER,QAAS,CAC5D,CACD,CAAC;EAED,OACCsB,aAAA,CAAAC,QAAA,QACGC,MAAM,CAACgB,IAAI,CAAErB,QAAS,CAAC,CAACsB,MAAM,GAAG,CAAC,IACnCnB,aAAA,CAACJ,kBAAkB;IAClBjB,UAAU,EAAG8B,KAAO;IACpBZ,QAAQ,EAAGA,QAAU;IACrBhB,iBAAiB,EAAG+B;EAAuB,CAC3C,CACD,EAEDZ,aAAA,CAACQ,SAAS;IAAA,GACJC,KAAK;IACVrB,UAAU,EAAG;MAAE,GAAGqB,KAAK,CAACrB,UAAU;MAAE,GAAGsB;IAAgB;EAAG,CAC1D,CACA,CAAC;AAEL,CAAC,EACD,yBACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASU,mBAAmBA,CAAEC,QAAQ,EAAEnC,IAAI,EAAG;EAC9C,IAAK,CAAEf,YAAY,CAAEe,IAAK,CAAC,EAAG;IAC7B,OAAOmC,QAAQ;EAChB;EAEA,OAAO;IACN,GAAGA,QAAQ;IACXC,IAAI,EAAEf,uBAAuB,CAAEc,QAAQ,CAACC,IAAK;EAC9C,CAAC;AACF;AAEAvD,SAAS,CACR,0BAA0B,EAC1B,0EAA0E,EAC1EqD,mBACD,CAAC"}
@@ -13,7 +13,7 @@ import { privateApis as componentsPrivateApis } from '@wordpress/components';
13
13
  */
14
14
  import { getInlineStyles } from './style';
15
15
  import { getFontSizeClass } from '../components/font-sizes';
16
- import { getTypographyFontSizeValue, getFluidTypographyOptionsFromSettings } from '../components/global-styles/typography-utils';
16
+ import { getTypographyFontSizeValue } from '../components/global-styles/typography-utils';
17
17
  import { unlock } from '../lock-unlock';
18
18
 
19
19
  /*
@@ -35,12 +35,11 @@ export function getTypographyClassesAndStyles(attributes, settings) {
35
35
  kebabCase
36
36
  } = unlock(componentsPrivateApis);
37
37
  let typographyStyles = attributes?.style?.typography || {};
38
- const fluidTypographySettings = getFluidTypographyOptionsFromSettings(settings);
39
38
  typographyStyles = {
40
39
  ...typographyStyles,
41
40
  fontSize: getTypographyFontSizeValue({
42
41
  size: attributes?.style?.typography?.fontSize
43
- }, fluidTypographySettings)
42
+ }, settings)
44
43
  };
45
44
  const style = getInlineStyles({
46
45
  typography: typographyStyles
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","privateApis","componentsPrivateApis","getInlineStyles","getFontSizeClass","getTypographyFontSizeValue","getFluidTypographyOptionsFromSettings","unlock","getTypographyClassesAndStyles","attributes","settings","kebabCase","typographyStyles","style","typography","fluidTypographySettings","fontSize","size","fontFamilyClassName","fontFamily","className"],"sources":["@wordpress/block-editor/src/hooks/use-typography-props.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { getInlineStyles } from './style';\nimport { getFontSizeClass } from '../components/font-sizes';\nimport {\n\tgetTypographyFontSizeValue,\n\tgetFluidTypographyOptionsFromSettings,\n} from '../components/global-styles/typography-utils';\nimport { unlock } from '../lock-unlock';\n\n/*\n * This utility is intended to assist where the serialization of the typography\n * block support is being skipped for a block but the typography related CSS\n * styles still need to be generated so they can be applied to inner elements.\n */\n/**\n * Provides the CSS class names and inline styles for a block's typography support\n * attributes.\n *\n * @param {Object} attributes Block attributes.\n * @param {Object|boolean} settings Merged theme.json settings\n *\n * @return {Object} Typography block support derived CSS classes & styles.\n */\nexport function getTypographyClassesAndStyles( attributes, settings ) {\n\tconst { kebabCase } = unlock( componentsPrivateApis );\n\tlet typographyStyles = attributes?.style?.typography || {};\n\tconst fluidTypographySettings =\n\t\tgetFluidTypographyOptionsFromSettings( settings );\n\n\ttypographyStyles = {\n\t\t...typographyStyles,\n\t\tfontSize: getTypographyFontSizeValue(\n\t\t\t{ size: attributes?.style?.typography?.fontSize },\n\t\t\tfluidTypographySettings\n\t\t),\n\t};\n\n\tconst style = getInlineStyles( { typography: typographyStyles } );\n\tconst fontFamilyClassName = !! attributes?.fontFamily\n\t\t? `has-${ kebabCase( attributes.fontFamily ) }-font-family`\n\t\t: '';\n\n\tconst className = classnames(\n\t\tfontFamilyClassName,\n\t\tgetFontSizeClass( attributes?.fontSize )\n\t);\n\n\treturn {\n\t\tclassName,\n\t\tstyle,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,WAAW,IAAIC,qBAAqB,QAAQ,uBAAuB;;AAE5E;AACA;AACA;AACA,SAASC,eAAe,QAAQ,SAAS;AACzC,SAASC,gBAAgB,QAAQ,0BAA0B;AAC3D,SACCC,0BAA0B,EAC1BC,qCAAqC,QAC/B,8CAA8C;AACrD,SAASC,MAAM,QAAQ,gBAAgB;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,6BAA6BA,CAAEC,UAAU,EAAEC,QAAQ,EAAG;EACrE,MAAM;IAAEC;EAAU,CAAC,GAAGJ,MAAM,CAAEL,qBAAsB,CAAC;EACrD,IAAIU,gBAAgB,GAAGH,UAAU,EAAEI,KAAK,EAAEC,UAAU,IAAI,CAAC,CAAC;EAC1D,MAAMC,uBAAuB,GAC5BT,qCAAqC,CAAEI,QAAS,CAAC;EAElDE,gBAAgB,GAAG;IAClB,GAAGA,gBAAgB;IACnBI,QAAQ,EAAEX,0BAA0B,CACnC;MAAEY,IAAI,EAAER,UAAU,EAAEI,KAAK,EAAEC,UAAU,EAAEE;IAAS,CAAC,EACjDD,uBACD;EACD,CAAC;EAED,MAAMF,KAAK,GAAGV,eAAe,CAAE;IAAEW,UAAU,EAAEF;EAAiB,CAAE,CAAC;EACjE,MAAMM,mBAAmB,GAAG,CAAC,CAAET,UAAU,EAAEU,UAAU,GACjD,OAAOR,SAAS,CAAEF,UAAU,CAACU,UAAW,CAAG,cAAa,GACzD,EAAE;EAEL,MAAMC,SAAS,GAAGpB,UAAU,CAC3BkB,mBAAmB,EACnBd,gBAAgB,CAAEK,UAAU,EAAEO,QAAS,CACxC,CAAC;EAED,OAAO;IACNI,SAAS;IACTP;EACD,CAAC;AACF"}
1
+ {"version":3,"names":["classnames","privateApis","componentsPrivateApis","getInlineStyles","getFontSizeClass","getTypographyFontSizeValue","unlock","getTypographyClassesAndStyles","attributes","settings","kebabCase","typographyStyles","style","typography","fontSize","size","fontFamilyClassName","fontFamily","className"],"sources":["@wordpress/block-editor/src/hooks/use-typography-props.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { getInlineStyles } from './style';\nimport { getFontSizeClass } from '../components/font-sizes';\nimport { getTypographyFontSizeValue } from '../components/global-styles/typography-utils';\nimport { unlock } from '../lock-unlock';\n\n/*\n * This utility is intended to assist where the serialization of the typography\n * block support is being skipped for a block but the typography related CSS\n * styles still need to be generated so they can be applied to inner elements.\n */\n/**\n * Provides the CSS class names and inline styles for a block's typography support\n * attributes.\n *\n * @param {Object} attributes Block attributes.\n * @param {Object|boolean} settings Merged theme.json settings\n *\n * @return {Object} Typography block support derived CSS classes & styles.\n */\nexport function getTypographyClassesAndStyles( attributes, settings ) {\n\tconst { kebabCase } = unlock( componentsPrivateApis );\n\tlet typographyStyles = attributes?.style?.typography || {};\n\ttypographyStyles = {\n\t\t...typographyStyles,\n\t\tfontSize: getTypographyFontSizeValue(\n\t\t\t{ size: attributes?.style?.typography?.fontSize },\n\t\t\tsettings\n\t\t),\n\t};\n\n\tconst style = getInlineStyles( { typography: typographyStyles } );\n\tconst fontFamilyClassName = !! attributes?.fontFamily\n\t\t? `has-${ kebabCase( attributes.fontFamily ) }-font-family`\n\t\t: '';\n\n\tconst className = classnames(\n\t\tfontFamilyClassName,\n\t\tgetFontSizeClass( attributes?.fontSize )\n\t);\n\n\treturn {\n\t\tclassName,\n\t\tstyle,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,WAAW,IAAIC,qBAAqB,QAAQ,uBAAuB;;AAE5E;AACA;AACA;AACA,SAASC,eAAe,QAAQ,SAAS;AACzC,SAASC,gBAAgB,QAAQ,0BAA0B;AAC3D,SAASC,0BAA0B,QAAQ,8CAA8C;AACzF,SAASC,MAAM,QAAQ,gBAAgB;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,6BAA6BA,CAAEC,UAAU,EAAEC,QAAQ,EAAG;EACrE,MAAM;IAAEC;EAAU,CAAC,GAAGJ,MAAM,CAAEJ,qBAAsB,CAAC;EACrD,IAAIS,gBAAgB,GAAGH,UAAU,EAAEI,KAAK,EAAEC,UAAU,IAAI,CAAC,CAAC;EAC1DF,gBAAgB,GAAG;IAClB,GAAGA,gBAAgB;IACnBG,QAAQ,EAAET,0BAA0B,CACnC;MAAEU,IAAI,EAAEP,UAAU,EAAEI,KAAK,EAAEC,UAAU,EAAEC;IAAS,CAAC,EACjDL,QACD;EACD,CAAC;EAED,MAAMG,KAAK,GAAGT,eAAe,CAAE;IAAEU,UAAU,EAAEF;EAAiB,CAAE,CAAC;EACjE,MAAMK,mBAAmB,GAAG,CAAC,CAAER,UAAU,EAAES,UAAU,GACjD,OAAOP,SAAS,CAAEF,UAAU,CAACS,UAAW,CAAG,cAAa,GACzD,EAAE;EAEL,MAAMC,SAAS,GAAGlB,UAAU,CAC3BgB,mBAAmB,EACnBZ,gBAAgB,CAAEI,UAAU,EAAEM,QAAS,CACxC,CAAC;EAED,OAAO;IACNI,SAAS;IACTN;EACD,CAAC;AACF"}