@wordpress/block-editor 12.20.0 → 12.22.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 (558) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/block-actions/index.js +47 -36
  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-heading-level-dropdown/index.js +5 -5
  11. package/build/components/block-heading-level-dropdown/index.js.map +1 -1
  12. package/build/components/block-heading-level-dropdown/index.native.js +5 -4
  13. package/build/components/block-heading-level-dropdown/index.native.js.map +1 -1
  14. package/build/components/block-inspector/index.js +5 -4
  15. package/build/components/block-inspector/index.js.map +1 -1
  16. package/build/components/block-list/block-crash-boundary.native.js +49 -0
  17. package/build/components/block-list/block-crash-boundary.native.js.map +1 -0
  18. package/build/components/block-list/block-crash-warning.native.js +24 -0
  19. package/build/components/block-list/block-crash-warning.native.js.map +1 -0
  20. package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
  21. package/build/components/block-list/block-list-item.native.js +1 -1
  22. package/build/components/block-list/block-list-item.native.js.map +1 -1
  23. package/build/components/block-list/block-outline.native.js +23 -7
  24. package/build/components/block-list/block-outline.native.js.map +1 -1
  25. package/build/components/block-list/block-selection-button.native.js.map +1 -1
  26. package/build/components/block-list/block.native.js +7 -5
  27. package/build/components/block-list/block.native.js.map +1 -1
  28. package/build/components/block-list/use-block-props/index.js +8 -1
  29. package/build/components/block-list/use-block-props/index.js.map +1 -1
  30. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +3 -3
  31. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
  32. package/build/components/block-mover/index.native.js.map +1 -1
  33. package/build/components/block-popover/cover.js +68 -0
  34. package/build/components/block-popover/cover.js.map +1 -0
  35. package/build/components/block-popover/drop-zone.js +2 -3
  36. package/build/components/block-popover/drop-zone.js.map +1 -1
  37. package/build/components/block-popover/index.js +1 -19
  38. package/build/components/block-popover/index.js.map +1 -1
  39. package/build/components/block-preview/index.js +2 -1
  40. package/build/components/block-preview/index.js.map +1 -1
  41. package/build/components/block-removal-warning-modal/index.js +2 -4
  42. package/build/components/block-removal-warning-modal/index.js.map +1 -1
  43. package/build/components/block-rename/modal.js.map +1 -1
  44. package/build/components/block-settings/container.native.js +2 -1
  45. package/build/components/block-settings/container.native.js.map +1 -1
  46. package/build/components/block-settings-menu/block-settings-dropdown.js +41 -39
  47. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  48. package/build/components/block-settings-menu-controls/index.js +1 -3
  49. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  50. package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
  51. package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
  52. package/build/components/block-toolbar/index.js +24 -11
  53. package/build/components/block-toolbar/index.js.map +1 -1
  54. package/build/components/block-toolbar/shuffle.js +89 -0
  55. package/build/components/block-toolbar/shuffle.js.map +1 -0
  56. package/build/components/block-toolbar/use-has-block-toolbar.js +43 -0
  57. package/build/components/block-toolbar/use-has-block-toolbar.js.map +1 -0
  58. package/build/components/block-tools/block-selection-button.js +5 -1
  59. package/build/components/block-tools/block-selection-button.js.map +1 -1
  60. package/build/components/block-tools/empty-block-inserter.js +2 -5
  61. package/build/components/block-tools/empty-block-inserter.js.map +1 -1
  62. package/build/components/block-tools/index.js +9 -26
  63. package/build/components/block-tools/index.js.map +1 -1
  64. package/build/components/block-tools/use-show-block-tools.js +60 -0
  65. package/build/components/block-tools/use-show-block-tools.js.map +1 -0
  66. package/build/components/caption/index.native.js.map +1 -1
  67. package/build/components/child-layout-control/index.js +108 -11
  68. package/build/components/child-layout-control/index.js.map +1 -1
  69. package/build/components/color-palette/control.js.map +1 -1
  70. package/build/components/colors-gradients/control.js +1 -1
  71. package/build/components/colors-gradients/control.js.map +1 -1
  72. package/build/components/convert-to-group-buttons/toolbar.js +11 -0
  73. package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
  74. package/build/components/global-styles/border-panel.js +21 -8
  75. package/build/components/global-styles/border-panel.js.map +1 -1
  76. package/build/components/global-styles/color-panel.js +1 -1
  77. package/build/components/global-styles/color-panel.js.map +1 -1
  78. package/build/components/global-styles/dimensions-panel.js +8 -33
  79. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  80. package/build/components/global-styles/image-settings-panel.js.map +1 -1
  81. package/build/components/global-styles/index.js +6 -0
  82. package/build/components/global-styles/index.js.map +1 -1
  83. package/build/components/global-styles/shadow-panel-components.js +80 -23
  84. package/build/components/global-styles/shadow-panel-components.js.map +1 -1
  85. package/build/components/global-styles/typography-utils.js +7 -5
  86. package/build/components/global-styles/typography-utils.js.map +1 -1
  87. package/build/components/global-styles/use-global-styles-output.js +16 -16
  88. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  89. package/build/components/global-styles/utils.js +2 -4
  90. package/build/components/global-styles/utils.js.map +1 -1
  91. package/build/components/grid-visualizer/grid-item-resizer.js +77 -0
  92. package/build/components/grid-visualizer/grid-item-resizer.js.map +1 -0
  93. package/build/components/grid-visualizer/grid-visualizer.js +81 -0
  94. package/build/components/grid-visualizer/grid-visualizer.js.map +1 -0
  95. package/build/components/grid-visualizer/index.js +20 -0
  96. package/build/components/grid-visualizer/index.js.map +1 -0
  97. package/build/components/grid-visualizer/utils.js +10 -0
  98. package/build/components/grid-visualizer/utils.js.map +1 -0
  99. package/build/components/iframe/index.js +66 -17
  100. package/build/components/iframe/index.js.map +1 -1
  101. package/build/components/index.native.js +7 -0
  102. package/build/components/index.native.js.map +1 -1
  103. package/build/components/inner-blocks/use-nested-settings-update.js +8 -2
  104. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  105. package/build/components/inserter/block-patterns-explorer/index.js +3 -6
  106. package/build/components/inserter/block-patterns-explorer/index.js.map +1 -1
  107. package/build/components/inserter/block-patterns-explorer/pattern-list.js +3 -1
  108. package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  109. package/build/components/inserter/media-tab/media-preview.js.map +1 -1
  110. package/build/components/inserter/menu.native.js.map +1 -1
  111. package/build/components/inserter/mobile-tab-navigation.js +2 -2
  112. package/build/components/inserter/mobile-tab-navigation.js.map +1 -1
  113. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  114. package/build/components/inspector-controls-tabs/advanced-controls-panel.native.js +36 -0
  115. package/build/components/inspector-controls-tabs/advanced-controls-panel.native.js.map +1 -0
  116. package/build/components/inspector-controls-tabs/index.js +1 -1
  117. package/build/components/inspector-controls-tabs/index.js.map +1 -1
  118. package/build/components/inspector-controls-tabs/styles-tab.js +1 -1
  119. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  120. package/build/components/link-control/link-preview.js +4 -1
  121. package/build/components/link-control/link-preview.js.map +1 -1
  122. package/build/components/link-control/search-input.js.map +1 -1
  123. package/build/components/list-view/block-select-button.js +0 -2
  124. package/build/components/list-view/block-select-button.js.map +1 -1
  125. package/build/components/list-view/block.js +4 -11
  126. package/build/components/list-view/block.js.map +1 -1
  127. package/build/components/list-view/branch.js.map +1 -1
  128. package/build/components/list-view/drop-indicator.js.map +1 -1
  129. package/build/components/list-view/index.js.map +1 -1
  130. package/build/components/list-view/use-clipboard-handler.js +2 -1
  131. package/build/components/list-view/use-clipboard-handler.js.map +1 -1
  132. package/build/components/list-view/utils.js +5 -3
  133. package/build/components/list-view/utils.js.map +1 -1
  134. package/build/components/panel-color-settings/index.js.map +1 -1
  135. package/build/components/provider/index.js.map +1 -1
  136. package/build/components/resizable-box-popover/index.js +3 -5
  137. package/build/components/resizable-box-popover/index.js.map +1 -1
  138. package/build/components/responsive-block-control/index.js +1 -1
  139. package/build/components/responsive-block-control/index.js.map +1 -1
  140. package/build/components/rich-text/index.js +46 -26
  141. package/build/components/rich-text/index.js.map +1 -1
  142. package/build/components/rich-text/use-enter.js +3 -0
  143. package/build/components/rich-text/use-enter.js.map +1 -1
  144. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  145. package/build/components/spacing-sizes-control/sides-dropdown/index.js +1 -1
  146. package/build/components/spacing-sizes-control/sides-dropdown/index.js.map +1 -1
  147. package/build/components/url-popover/index.js +3 -3
  148. package/build/components/url-popover/index.js.map +1 -1
  149. package/build/components/use-moving-animation/index.js +4 -0
  150. package/build/components/use-moving-animation/index.js.map +1 -1
  151. package/build/components/warning/index.native.js +9 -4
  152. package/build/components/warning/index.native.js.map +1 -1
  153. package/build/components/writing-flow/use-clipboard-handler.js +2 -1
  154. package/build/components/writing-flow/use-clipboard-handler.js.map +1 -1
  155. package/build/components/writing-flow/utils.js +23 -6
  156. package/build/components/writing-flow/utils.js.map +1 -1
  157. package/build/hooks/anchor.js +7 -8
  158. package/build/hooks/anchor.js.map +1 -1
  159. package/build/hooks/background.js +39 -2
  160. package/build/hooks/background.js.map +1 -1
  161. package/build/hooks/block-hooks.js +34 -8
  162. package/build/hooks/block-hooks.js.map +1 -1
  163. package/build/hooks/border.js +6 -4
  164. package/build/hooks/border.js.map +1 -1
  165. package/build/hooks/dimensions.js +3 -4
  166. package/build/hooks/dimensions.js.map +1 -1
  167. package/build/hooks/font-size.js +6 -7
  168. package/build/hooks/font-size.js.map +1 -1
  169. package/build/hooks/index.js +3 -2
  170. package/build/hooks/index.js.map +1 -1
  171. package/build/hooks/layout-child.js +67 -6
  172. package/build/hooks/layout-child.js.map +1 -1
  173. package/build/hooks/layout.js +32 -14
  174. package/build/hooks/layout.js.map +1 -1
  175. package/build/hooks/line-height.js.map +1 -1
  176. package/build/hooks/position.js +1 -1
  177. package/build/hooks/position.js.map +1 -1
  178. package/build/hooks/spacing-visualizer.js +115 -0
  179. package/build/hooks/spacing-visualizer.js.map +1 -0
  180. package/build/hooks/use-bindings-attributes.js +171 -48
  181. package/build/hooks/use-bindings-attributes.js.map +1 -1
  182. package/build/hooks/use-typography-props.js +1 -2
  183. package/build/hooks/use-typography-props.js.map +1 -1
  184. package/build/layouts/grid.js +6 -2
  185. package/build/layouts/grid.js.map +1 -1
  186. package/build/private-apis.js +7 -3
  187. package/build/private-apis.js.map +1 -1
  188. package/build/private-apis.native.js +3 -1
  189. package/build/private-apis.native.js.map +1 -1
  190. package/build/store/actions.js +42 -12
  191. package/build/store/actions.js.map +1 -1
  192. package/build/store/private-actions.js +29 -55
  193. package/build/store/private-actions.js.map +1 -1
  194. package/build/store/private-selectors.js +0 -8
  195. package/build/store/private-selectors.js.map +1 -1
  196. package/build/store/reducer.js +34 -46
  197. package/build/store/reducer.js.map +1 -1
  198. package/build/store/selectors.js +27 -15
  199. package/build/store/selectors.js.map +1 -1
  200. package/build-module/components/block-actions/index.js +47 -36
  201. package/build-module/components/block-actions/index.js.map +1 -1
  202. package/build-module/components/block-bindings-toolbar-indicator/index.js +18 -0
  203. package/build-module/components/block-bindings-toolbar-indicator/index.js.map +1 -0
  204. package/build-module/components/block-edit/context.js +1 -0
  205. package/build-module/components/block-edit/context.js.map +1 -1
  206. package/build-module/components/block-edit/index.js +9 -4
  207. package/build-module/components/block-edit/index.js.map +1 -1
  208. package/build-module/components/block-heading-level-dropdown/index.js +5 -5
  209. package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
  210. package/build-module/components/block-heading-level-dropdown/index.native.js +5 -4
  211. package/build-module/components/block-heading-level-dropdown/index.native.js.map +1 -1
  212. package/build-module/components/block-inspector/index.js +6 -5
  213. package/build-module/components/block-inspector/index.js.map +1 -1
  214. package/build-module/components/block-list/block-crash-boundary.native.js +42 -0
  215. package/build-module/components/block-list/block-crash-boundary.native.js.map +1 -0
  216. package/build-module/components/block-list/block-crash-warning.native.js +15 -0
  217. package/build-module/components/block-list/block-crash-warning.native.js.map +1 -0
  218. package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
  219. package/build-module/components/block-list/block-list-item.native.js +1 -1
  220. package/build-module/components/block-list/block-list-item.native.js.map +1 -1
  221. package/build-module/components/block-list/block-outline.native.js +23 -7
  222. package/build-module/components/block-list/block-outline.native.js.map +1 -1
  223. package/build-module/components/block-list/block-selection-button.native.js.map +1 -1
  224. package/build-module/components/block-list/block.native.js +7 -5
  225. package/build-module/components/block-list/block.native.js.map +1 -1
  226. package/build-module/components/block-list/use-block-props/index.js +9 -2
  227. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  228. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +3 -3
  229. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
  230. package/build-module/components/block-mover/index.native.js.map +1 -1
  231. package/build-module/components/block-popover/cover.js +60 -0
  232. package/build-module/components/block-popover/cover.js.map +1 -0
  233. package/build-module/components/block-popover/drop-zone.js +2 -3
  234. package/build-module/components/block-popover/drop-zone.js.map +1 -1
  235. package/build-module/components/block-popover/index.js +1 -19
  236. package/build-module/components/block-popover/index.js.map +1 -1
  237. package/build-module/components/block-preview/index.js +2 -1
  238. package/build-module/components/block-preview/index.js.map +1 -1
  239. package/build-module/components/block-removal-warning-modal/index.js +3 -5
  240. package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
  241. package/build-module/components/block-rename/modal.js.map +1 -1
  242. package/build-module/components/block-settings/container.native.js +3 -2
  243. package/build-module/components/block-settings/container.native.js.map +1 -1
  244. package/build-module/components/block-settings-menu/block-settings-dropdown.js +42 -40
  245. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  246. package/build-module/components/block-settings-menu-controls/index.js +1 -3
  247. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  248. package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
  249. package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
  250. package/build-module/components/block-toolbar/index.js +24 -12
  251. package/build-module/components/block-toolbar/index.js.map +1 -1
  252. package/build-module/components/block-toolbar/shuffle.js +82 -0
  253. package/build-module/components/block-toolbar/shuffle.js.map +1 -0
  254. package/build-module/components/block-toolbar/use-has-block-toolbar.js +36 -0
  255. package/build-module/components/block-toolbar/use-has-block-toolbar.js.map +1 -0
  256. package/build-module/components/block-tools/block-selection-button.js +5 -1
  257. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  258. package/build-module/components/block-tools/empty-block-inserter.js +2 -5
  259. package/build-module/components/block-tools/empty-block-inserter.js.map +1 -1
  260. package/build-module/components/block-tools/index.js +9 -26
  261. package/build-module/components/block-tools/index.js.map +1 -1
  262. package/build-module/components/block-tools/use-show-block-tools.js +54 -0
  263. package/build-module/components/block-tools/use-show-block-tools.js.map +1 -0
  264. package/build-module/components/caption/index.native.js.map +1 -1
  265. package/build-module/components/child-layout-control/index.js +109 -12
  266. package/build-module/components/child-layout-control/index.js.map +1 -1
  267. package/build-module/components/color-palette/control.js.map +1 -1
  268. package/build-module/components/colors-gradients/control.js +1 -1
  269. package/build-module/components/colors-gradients/control.js.map +1 -1
  270. package/build-module/components/convert-to-group-buttons/toolbar.js +12 -1
  271. package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
  272. package/build-module/components/global-styles/border-panel.js +22 -10
  273. package/build-module/components/global-styles/border-panel.js.map +1 -1
  274. package/build-module/components/global-styles/color-panel.js +1 -1
  275. package/build-module/components/global-styles/color-panel.js.map +1 -1
  276. package/build-module/components/global-styles/dimensions-panel.js +9 -34
  277. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  278. package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
  279. package/build-module/components/global-styles/index.js +1 -1
  280. package/build-module/components/global-styles/index.js.map +1 -1
  281. package/build-module/components/global-styles/shadow-panel-components.js +82 -24
  282. package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
  283. package/build-module/components/global-styles/typography-utils.js +7 -5
  284. package/build-module/components/global-styles/typography-utils.js.map +1 -1
  285. package/build-module/components/global-styles/use-global-styles-output.js +17 -17
  286. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  287. package/build-module/components/global-styles/utils.js +2 -4
  288. package/build-module/components/global-styles/utils.js.map +1 -1
  289. package/build-module/components/grid-visualizer/grid-item-resizer.js +69 -0
  290. package/build-module/components/grid-visualizer/grid-item-resizer.js.map +1 -0
  291. package/build-module/components/grid-visualizer/grid-visualizer.js +73 -0
  292. package/build-module/components/grid-visualizer/grid-visualizer.js.map +1 -0
  293. package/build-module/components/grid-visualizer/index.js +3 -0
  294. package/build-module/components/grid-visualizer/index.js.map +1 -0
  295. package/build-module/components/grid-visualizer/utils.js +4 -0
  296. package/build-module/components/grid-visualizer/utils.js.map +1 -0
  297. package/build-module/components/iframe/index.js +66 -17
  298. package/build-module/components/iframe/index.js.map +1 -1
  299. package/build-module/components/index.native.js +1 -1
  300. package/build-module/components/index.native.js.map +1 -1
  301. package/build-module/components/inner-blocks/use-nested-settings-update.js +8 -2
  302. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  303. package/build-module/components/inserter/block-patterns-explorer/index.js +3 -6
  304. package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -1
  305. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +3 -1
  306. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  307. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
  308. package/build-module/components/inserter/menu.native.js.map +1 -1
  309. package/build-module/components/inserter/mobile-tab-navigation.js +2 -2
  310. package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -1
  311. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  312. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.native.js +28 -0
  313. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.native.js.map +1 -0
  314. package/build-module/components/inspector-controls-tabs/index.js +1 -1
  315. package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
  316. package/build-module/components/inspector-controls-tabs/styles-tab.js +2 -2
  317. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  318. package/build-module/components/link-control/link-preview.js +5 -2
  319. package/build-module/components/link-control/link-preview.js.map +1 -1
  320. package/build-module/components/link-control/search-input.js.map +1 -1
  321. package/build-module/components/list-view/block-select-button.js +0 -2
  322. package/build-module/components/list-view/block-select-button.js.map +1 -1
  323. package/build-module/components/list-view/block.js +6 -13
  324. package/build-module/components/list-view/block.js.map +1 -1
  325. package/build-module/components/list-view/branch.js.map +1 -1
  326. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  327. package/build-module/components/list-view/index.js.map +1 -1
  328. package/build-module/components/list-view/use-clipboard-handler.js +3 -2
  329. package/build-module/components/list-view/use-clipboard-handler.js.map +1 -1
  330. package/build-module/components/list-view/utils.js +2 -1
  331. package/build-module/components/list-view/utils.js.map +1 -1
  332. package/build-module/components/panel-color-settings/index.js.map +1 -1
  333. package/build-module/components/provider/index.js.map +1 -1
  334. package/build-module/components/resizable-box-popover/index.js +3 -5
  335. package/build-module/components/resizable-box-popover/index.js.map +1 -1
  336. package/build-module/components/responsive-block-control/index.js +1 -1
  337. package/build-module/components/responsive-block-control/index.js.map +1 -1
  338. package/build-module/components/rich-text/index.js +47 -28
  339. package/build-module/components/rich-text/index.js.map +1 -1
  340. package/build-module/components/rich-text/use-enter.js +3 -0
  341. package/build-module/components/rich-text/use-enter.js.map +1 -1
  342. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  343. package/build-module/components/spacing-sizes-control/sides-dropdown/index.js +1 -1
  344. package/build-module/components/spacing-sizes-control/sides-dropdown/index.js.map +1 -1
  345. package/build-module/components/url-popover/index.js +3 -3
  346. package/build-module/components/url-popover/index.js.map +1 -1
  347. package/build-module/components/use-moving-animation/index.js +4 -0
  348. package/build-module/components/use-moving-animation/index.js.map +1 -1
  349. package/build-module/components/warning/index.native.js +9 -4
  350. package/build-module/components/warning/index.native.js.map +1 -1
  351. package/build-module/components/writing-flow/use-clipboard-handler.js +3 -2
  352. package/build-module/components/writing-flow/use-clipboard-handler.js.map +1 -1
  353. package/build-module/components/writing-flow/utils.js +22 -7
  354. package/build-module/components/writing-flow/utils.js.map +1 -1
  355. package/build-module/hooks/anchor.js +8 -9
  356. package/build-module/hooks/anchor.js.map +1 -1
  357. package/build-module/hooks/background.js +38 -1
  358. package/build-module/hooks/background.js.map +1 -1
  359. package/build-module/hooks/block-hooks.js +34 -8
  360. package/build-module/hooks/block-hooks.js.map +1 -1
  361. package/build-module/hooks/border.js +7 -5
  362. package/build-module/hooks/border.js.map +1 -1
  363. package/build-module/hooks/dimensions.js +1 -2
  364. package/build-module/hooks/dimensions.js.map +1 -1
  365. package/build-module/hooks/font-size.js +7 -8
  366. package/build-module/hooks/font-size.js.map +1 -1
  367. package/build-module/hooks/index.js +3 -2
  368. package/build-module/hooks/index.js.map +1 -1
  369. package/build-module/hooks/layout-child.js +67 -6
  370. package/build-module/hooks/layout-child.js.map +1 -1
  371. package/build-module/hooks/layout.js +32 -14
  372. package/build-module/hooks/layout.js.map +1 -1
  373. package/build-module/hooks/line-height.js.map +1 -1
  374. package/build-module/hooks/position.js +1 -1
  375. package/build-module/hooks/position.js.map +1 -1
  376. package/build-module/hooks/spacing-visualizer.js +106 -0
  377. package/build-module/hooks/spacing-visualizer.js.map +1 -0
  378. package/build-module/hooks/use-bindings-attributes.js +172 -49
  379. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  380. package/build-module/hooks/use-typography-props.js +2 -3
  381. package/build-module/hooks/use-typography-props.js.map +1 -1
  382. package/build-module/layouts/grid.js +6 -2
  383. package/build-module/layouts/grid.js.map +1 -1
  384. package/build-module/private-apis.js +7 -3
  385. package/build-module/private-apis.js.map +1 -1
  386. package/build-module/private-apis.native.js +3 -1
  387. package/build-module/private-apis.native.js.map +1 -1
  388. package/build-module/store/actions.js +42 -12
  389. package/build-module/store/actions.js.map +1 -1
  390. package/build-module/store/private-actions.js +29 -54
  391. package/build-module/store/private-actions.js.map +1 -1
  392. package/build-module/store/private-selectors.js +0 -6
  393. package/build-module/store/private-selectors.js.map +1 -1
  394. package/build-module/store/reducer.js +34 -46
  395. package/build-module/store/reducer.js.map +1 -1
  396. package/build-module/store/selectors.js +23 -13
  397. package/build-module/store/selectors.js.map +1 -1
  398. package/build-style/content-rtl.css +22 -2
  399. package/build-style/content.css +22 -2
  400. package/build-style/default-editor-styles-rtl.css +1 -0
  401. package/build-style/default-editor-styles.css +1 -0
  402. package/build-style/style-rtl.css +106 -27
  403. package/build-style/style.css +106 -27
  404. package/package.json +31 -31
  405. package/src/components/block-actions/index.js +59 -55
  406. package/src/components/block-bindings-toolbar-indicator/index.js +20 -0
  407. package/src/components/block-bindings-toolbar-indicator/style.scss +16 -0
  408. package/src/components/block-draggable/test/index.native.js +2 -2
  409. package/src/components/block-edit/context.js +1 -0
  410. package/src/components/block-edit/index.js +5 -1
  411. package/src/components/block-heading-level-dropdown/README.md +5 -5
  412. package/src/components/block-heading-level-dropdown/index.js +5 -5
  413. package/src/components/block-heading-level-dropdown/index.native.js +5 -4
  414. package/src/components/block-inspector/index.js +7 -5
  415. package/src/components/block-list/block-crash-boundary.native.js +43 -0
  416. package/src/components/block-list/block-crash-warning.native.js +19 -0
  417. package/src/components/block-list/block-invalid-warning.native.js +1 -1
  418. package/src/components/block-list/block-list-item.native.js +1 -1
  419. package/src/components/block-list/block-outline.native.js +36 -21
  420. package/src/components/block-list/block-selection-button.native.js +1 -3
  421. package/src/components/block-list/block.native.js +14 -10
  422. package/src/components/block-list/content.scss +21 -1
  423. package/src/components/block-list/test/block-outline.native.js +255 -0
  424. package/src/components/block-list/use-block-props/index.js +12 -2
  425. package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +3 -7
  426. package/src/components/block-mover/index.native.js +1 -1
  427. package/src/components/block-popover/cover.js +63 -0
  428. package/src/components/block-popover/drop-zone.js +3 -4
  429. package/src/components/block-popover/index.js +1 -28
  430. package/src/components/block-preview/index.js +3 -1
  431. package/src/components/block-removal-warning-modal/index.js +5 -19
  432. package/src/components/block-rename/modal.js +1 -1
  433. package/src/components/block-settings/container.native.js +5 -1
  434. package/src/components/block-settings-menu/block-settings-dropdown.js +53 -65
  435. package/src/components/block-settings-menu-controls/README.md +0 -9
  436. package/src/components/block-settings-menu-controls/index.js +1 -6
  437. package/src/components/block-switcher/block-transformations-menu.native.js +1 -1
  438. package/src/components/block-toolbar/block-toolbar-menu.native.js +2 -2
  439. package/src/components/block-toolbar/index.js +22 -16
  440. package/src/components/block-toolbar/shuffle.js +93 -0
  441. package/src/components/block-toolbar/test/index.native.js +1 -7
  442. package/src/components/block-toolbar/use-has-block-toolbar.js +49 -0
  443. package/src/components/block-tools/block-selection-button.js +4 -0
  444. package/src/components/block-tools/empty-block-inserter.js +3 -6
  445. package/src/components/block-tools/index.js +13 -36
  446. package/src/components/block-tools/use-show-block-tools.js +73 -0
  447. package/src/components/caption/index.native.js +1 -1
  448. package/src/components/child-layout-control/index.js +148 -36
  449. package/src/components/color-palette/control.js +1 -1
  450. package/src/components/colors-gradients/control.js +1 -1
  451. package/src/components/colors-gradients/test/control.js +2 -2
  452. package/src/components/contrast-checker/test/index.js +10 -10
  453. package/src/components/convert-to-group-buttons/toolbar.js +13 -1
  454. package/src/components/default-block-appender/content.scss +5 -2
  455. package/src/components/global-styles/border-panel.js +35 -24
  456. package/src/components/global-styles/color-panel.js +1 -1
  457. package/src/components/global-styles/dimensions-panel.js +9 -34
  458. package/src/components/global-styles/image-settings-panel.js +1 -1
  459. package/src/components/global-styles/index.js +5 -1
  460. package/src/components/global-styles/shadow-panel-components.js +92 -23
  461. package/src/components/global-styles/style.scss +33 -10
  462. package/src/components/global-styles/test/typography-utils.js +231 -81
  463. package/src/components/global-styles/test/use-global-styles-output.js +31 -0
  464. package/src/components/global-styles/typography-utils.js +10 -7
  465. package/src/components/global-styles/use-global-styles-output.js +17 -17
  466. package/src/components/global-styles/utils.js +2 -26
  467. package/src/components/grid-visualizer/grid-item-resizer.js +100 -0
  468. package/src/components/grid-visualizer/grid-visualizer.js +81 -0
  469. package/src/components/grid-visualizer/index.js +2 -0
  470. package/src/components/grid-visualizer/style.scss +33 -0
  471. package/src/components/grid-visualizer/utils.js +5 -0
  472. package/src/components/iframe/index.js +89 -26
  473. package/src/components/index.native.js +1 -0
  474. package/src/components/inner-blocks/use-nested-settings-update.js +12 -2
  475. package/src/components/inserter/block-patterns-explorer/index.js +2 -9
  476. package/src/components/inserter/block-patterns-explorer/pattern-list.js +7 -1
  477. package/src/components/inserter/media-tab/media-preview.js +1 -1
  478. package/src/components/inserter/menu.native.js +3 -3
  479. package/src/components/inserter/mobile-tab-navigation.js +2 -2
  480. package/src/components/inserter/style.scss +10 -0
  481. package/src/components/inspector-controls/block-support-tools-panel.js +2 -2
  482. package/src/components/inspector-controls-tabs/advanced-controls-panel.native.js +31 -0
  483. package/src/components/inspector-controls-tabs/index.js +1 -1
  484. package/src/components/inspector-controls-tabs/styles-tab.js +2 -2
  485. package/src/components/line-height-control/test/index.js +1 -1
  486. package/src/components/link-control/link-preview.js +9 -2
  487. package/src/components/link-control/search-input.js +1 -1
  488. package/src/components/link-control/style.scss +9 -5
  489. package/src/components/list-view/block-select-button.js +0 -2
  490. package/src/components/list-view/block.js +12 -21
  491. package/src/components/list-view/branch.js +1 -1
  492. package/src/components/list-view/drop-indicator.js +1 -1
  493. package/src/components/list-view/index.js +1 -1
  494. package/src/components/list-view/style.scss +34 -16
  495. package/src/components/list-view/use-clipboard-handler.js +3 -2
  496. package/src/components/list-view/utils.js +4 -1
  497. package/src/components/panel-color-settings/index.js +1 -1
  498. package/src/components/panel-color-settings/test/index.js +3 -3
  499. package/src/components/provider/index.js +1 -4
  500. package/src/components/resizable-box-popover/index.js +4 -6
  501. package/src/components/responsive-block-control/README.md +4 -4
  502. package/src/components/responsive-block-control/index.js +1 -1
  503. package/src/components/responsive-block-control/test/index.js +5 -5
  504. package/src/components/rich-text/README.md +6 -0
  505. package/src/components/rich-text/index.js +76 -53
  506. package/src/components/rich-text/use-enter.js +4 -0
  507. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +4 -4
  508. package/src/components/spacing-sizes-control/sides-dropdown/index.js +1 -1
  509. package/src/components/url-popover/index.js +5 -5
  510. package/src/components/url-popover/style.scss +1 -0
  511. package/src/components/use-moving-animation/index.js +1 -0
  512. package/src/components/warning/index.native.js +19 -15
  513. package/src/components/writing-flow/use-clipboard-handler.js +3 -2
  514. package/src/components/writing-flow/utils.js +31 -16
  515. package/src/hooks/anchor.js +41 -61
  516. package/src/hooks/background.js +49 -4
  517. package/src/hooks/block-hooks.js +47 -9
  518. package/src/hooks/block-hooks.scss +6 -0
  519. package/src/hooks/border.js +16 -4
  520. package/src/hooks/dimensions.js +1 -2
  521. package/src/hooks/font-size.js +7 -12
  522. package/src/hooks/index.js +3 -0
  523. package/src/hooks/layout-child.js +82 -8
  524. package/src/hooks/layout.js +34 -19
  525. package/src/hooks/line-height.js +1 -1
  526. package/src/hooks/position.js +1 -1
  527. package/src/hooks/spacing-visualizer.js +126 -0
  528. package/src/hooks/{padding.scss → spacing.scss} +1 -1
  529. package/src/hooks/test/__snapshots__/anchor.native.js.snap +7 -0
  530. package/src/hooks/test/anchor.native.js +32 -0
  531. package/src/hooks/use-bindings-attributes.js +215 -65
  532. package/src/hooks/use-typography-props.js +2 -8
  533. package/src/layouts/grid.js +8 -3
  534. package/src/private-apis.js +6 -2
  535. package/src/private-apis.native.js +2 -0
  536. package/src/store/actions.js +56 -18
  537. package/src/store/private-actions.js +34 -79
  538. package/src/store/private-selectors.js +0 -8
  539. package/src/store/reducer.js +43 -64
  540. package/src/store/selectors.js +41 -46
  541. package/src/store/test/actions.js +0 -4
  542. package/src/style.scss +3 -1
  543. package/tsconfig.json +1 -0
  544. package/build/hooks/margin.js +0 -86
  545. package/build/hooks/margin.js.map +0 -1
  546. package/build/hooks/padding.js +0 -78
  547. package/build/hooks/padding.js.map +0 -1
  548. package/build/utils/use-can-block-toolbar-be-focused.js +0 -46
  549. package/build/utils/use-can-block-toolbar-be-focused.js.map +0 -1
  550. package/build-module/hooks/margin.js +0 -78
  551. package/build-module/hooks/margin.js.map +0 -1
  552. package/build-module/hooks/padding.js +0 -70
  553. package/build-module/hooks/padding.js.map +0 -1
  554. package/build-module/utils/use-can-block-toolbar-be-focused.js +0 -40
  555. package/build-module/utils/use-can-block-toolbar-be-focused.js.map +0 -1
  556. package/src/hooks/margin.js +0 -91
  557. package/src/hooks/padding.js +0 -82
  558. package/src/utils/use-can-block-toolbar-be-focused.js +0 -48
@@ -1 +1 @@
1
- {"version":3,"names":["_blocks","require","_lineHeightControl","_interopRequireDefault","_utils","_useSettings","LINE_HEIGHT_SUPPORT_KEY","exports","LineHeightEdit","props","attributes","style","setAttributes","onChange","newLineHeightValue","newStyle","typography","lineHeight","cleanEmptyObject","_react","createElement","default","__unstableInputWidth","__nextHasNoMarginBottom","value","size","useIsLineHeightDisabled","name","blockName","isEnabled","useSettings","hasBlockSupport"],"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":";;;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAKA,IAAAC,kBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKO,MAAMK,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,uBAAuB;;AAE9D;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,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,EAAE,IAAAO,uBAAgB,EAAEH,QAAS;IAAE,CAAE,CAAC;EACzD,CAAC;EACD,OACC,IAAAI,MAAA,CAAAC,aAAA,EAAClB,kBAAA,CAAAmB,OAAiB;IACjBC,oBAAoB,EAAC,MAAM;IAC3BC,uBAAuB,EAAG,IAAM;IAChCC,KAAK,EAAGb,KAAK,EAAEK,UAAU,EAAEC,UAAY;IACvCJ,QAAQ,EAAGA,QAAU;IACrBY,IAAI,EAAC;EAAkB,CACvB,CAAC;AAEJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,uBAAuBA,CAAE;EAAEC,IAAI,EAAEC;AAAU,CAAC,GAAG,CAAC,CAAC,EAAG;EACnE,MAAM,CAAEC,SAAS,CAAE,GAAG,IAAAC,wBAAW,EAAE,uBAAwB,CAAC;EAE5D,OACC,CAAED,SAAS,IAAI,CAAE,IAAAE,uBAAe,EAAEH,SAAS,EAAEtB,uBAAwB,CAAC;AAExE"}
1
+ {"version":3,"names":["_blocks","require","_lineHeightControl","_interopRequireDefault","_utils","_useSettings","LINE_HEIGHT_SUPPORT_KEY","exports","LineHeightEdit","props","attributes","style","setAttributes","onChange","newLineHeightValue","newStyle","typography","lineHeight","cleanEmptyObject","_react","createElement","default","__unstableInputWidth","__nextHasNoMarginBottom","value","size","useIsLineHeightDisabled","name","blockName","isEnabled","useSettings","hasBlockSupport"],"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":";;;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAKA,IAAAC,kBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKO,MAAMK,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,uBAAuB;;AAE9D;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,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,EAAE,IAAAO,uBAAgB,EAAEH,QAAS;IAAE,CAAE,CAAC;EACzD,CAAC;EACD,OACC,IAAAI,MAAA,CAAAC,aAAA,EAAClB,kBAAA,CAAAmB,OAAiB;IACjBC,oBAAoB,EAAC,MAAM;IAC3BC,uBAAuB;IACvBC,KAAK,EAAGb,KAAK,EAAEK,UAAU,EAAEC,UAAY;IACvCJ,QAAQ,EAAGA,QAAU;IACrBY,IAAI,EAAC;EAAkB,CACvB,CAAC;AAEJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,uBAAuBA,CAAE;EAAEC,IAAI,EAAEC;AAAU,CAAC,GAAG,CAAC,CAAC,EAAG;EACnE,MAAM,CAAEC,SAAS,CAAE,GAAG,IAAAC,wBAAW,EAAE,uBAAwB,CAAC;EAE5D,OACC,CAAED,SAAS,IAAI,CAAE,IAAAE,uBAAe,EAAEH,SAAS,EAAEtB,uBAAwB,CAAC;AAExE"}
@@ -156,7 +156,7 @@ function hasPositionValue(props) {
156
156
  * @return {boolean} Whether or not the block is set to a sticky or fixed position.
157
157
  */
158
158
  function hasStickyOrFixedPositionValue(attributes) {
159
- const positionType = attributes.style?.position?.type;
159
+ const positionType = attributes?.style?.position?.type;
160
160
  return positionType === 'sticky' || positionType === 'fixed';
161
161
  }
162
162
 
@@ -1 +1 @@
1
- {"version":3,"names":["_classnames","_interopRequireDefault","require","_i18n","_blocks","_components","_compose","_data","_element","_useSettings","_inspectorControls","_useBlockDisplayInformation","_utils","_lockUnlock","_store","CustomSelectControl","unlock","componentsPrivateApis","POSITION_SUPPORT_KEY","OPTION_CLASSNAME","DEFAULT_OPTION","key","value","name","__","className","STICKY_OPTION","_x","__experimentalHint","FIXED_OPTION","POSITION_SIDES","VALID_POSITION_TYPES","getPositionCSS","selector","style","output","type","positionType","position","includes","forEach","side","undefined","hasStickyPositionSupport","blockType","support","getBlockSupport","sticky","hasFixedPositionSupport","fixed","hasPositionSupport","hasPositionValue","props","attributes","hasStickyOrFixedPositionValue","resetPosition","setAttributes","cleanEmptyObject","top","right","bottom","left","useIsPositionDisabled","blockName","allowFixed","allowSticky","useSettings","isDisabled","PositionPanelPure","clientId","firstParentClientId","useSelect","select","getBlockParents","blockEditorStore","parents","length","blockInformation","useBlockDisplayInformation","stickyHelpText","sprintf","title","options","useMemo","availableOptions","push","onChangeType","next","placementValue","newStyle","selectedOption","find","option","Platform","web","_react","createElement","default","group","BaseControl","__nextHasNoMarginBottom","help","__next40pxDefaultSize","label","hideLabelFromVision","describedBy","__experimentalShowSelectedHint","onChange","selectedItem","size","native","_default","exports","edit","Edit","isPositionDisabled","useBlockProps","attributeKeys","hasSupport","hasBlockSupport","hasPositionBlockSupport","allowPositionStyles","id","useInstanceId","positionSelector","css","classnames","useStyleOverride"],"sources":["@wordpress/block-editor/src/hooks/position.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport {\n\tBaseControl,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo, Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../components/use-settings';\nimport InspectorControls from '../components/inspector-controls';\nimport useBlockDisplayInformation from '../components/use-block-display-information';\nimport { cleanEmptyObject, useStyleOverride } from './utils';\nimport { unlock } from '../lock-unlock';\nimport { store as blockEditorStore } from '../store';\n\nconst { CustomSelectControl } = unlock( componentsPrivateApis );\n\nconst POSITION_SUPPORT_KEY = 'position';\n\nconst OPTION_CLASSNAME =\n\t'block-editor-hooks__position-selection__select-control__option';\n\nconst DEFAULT_OPTION = {\n\tkey: 'default',\n\tvalue: '',\n\tname: __( 'Default' ),\n\tclassName: OPTION_CLASSNAME,\n};\n\nconst STICKY_OPTION = {\n\tkey: 'sticky',\n\tvalue: 'sticky',\n\tname: _x( 'Sticky', 'Name for the value of the CSS position property' ),\n\tclassName: OPTION_CLASSNAME,\n\t__experimentalHint: __(\n\t\t'The block will stick to the top of the window instead of scrolling.'\n\t),\n};\n\nconst FIXED_OPTION = {\n\tkey: 'fixed',\n\tvalue: 'fixed',\n\tname: _x( 'Fixed', 'Name for the value of the CSS position property' ),\n\tclassName: OPTION_CLASSNAME,\n\t__experimentalHint: __(\n\t\t'The block will not move when the page is scrolled.'\n\t),\n};\n\nconst POSITION_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nconst VALID_POSITION_TYPES = [ 'sticky', 'fixed' ];\n\n/**\n * Get calculated position CSS.\n *\n * @param {Object} props Component props.\n * @param {string} props.selector Selector to use.\n * @param {Object} props.style Style object.\n * @return {string} The generated CSS rules.\n */\nexport function getPositionCSS( { selector, style } ) {\n\tlet output = '';\n\n\tconst { type: positionType } = style?.position || {};\n\n\tif ( ! VALID_POSITION_TYPES.includes( positionType ) ) {\n\t\treturn output;\n\t}\n\n\toutput += `${ selector } {`;\n\toutput += `position: ${ positionType };`;\n\n\tPOSITION_SIDES.forEach( ( side ) => {\n\t\tif ( style?.position?.[ side ] !== undefined ) {\n\t\t\toutput += `${ side }: ${ style.position[ side ] };`;\n\t\t}\n\t} );\n\n\tif ( positionType === 'sticky' || positionType === 'fixed' ) {\n\t\t// TODO: Replace hard-coded z-index value with a z-index preset approach in theme.json.\n\t\toutput += `z-index: 10`;\n\t}\n\toutput += `}`;\n\n\treturn output;\n}\n\n/**\n * Determines if there is sticky position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasStickyPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.sticky );\n}\n\n/**\n * Determines if there is fixed position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasFixedPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.fixed );\n}\n\n/**\n * Determines if there is position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! support;\n}\n\n/**\n * Checks if there is a current value in the position block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a position value set.\n */\nexport function hasPositionValue( props ) {\n\treturn props.attributes.style?.position?.type !== undefined;\n}\n\n/**\n * Checks if the block is currently set to a sticky or fixed position.\n * This check is helpful for determining how to position block toolbars or other elements.\n *\n * @param {Object} attributes Block attributes.\n * @return {boolean} Whether or not the block is set to a sticky or fixed position.\n */\nexport function hasStickyOrFixedPositionValue( attributes ) {\n\tconst positionType = attributes.style?.position?.type;\n\treturn positionType === 'sticky' || positionType === 'fixed';\n}\n\n/**\n * Resets the position block support attributes. This can be used when disabling\n * the position support controls for a block via a `ToolsPanel`.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetPosition( { attributes = {}, setAttributes } ) {\n\tconst { style = {} } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: undefined,\n\t\t\t\ttop: undefined,\n\t\t\t\tright: undefined,\n\t\t\t\tbottom: undefined,\n\t\t\t\tleft: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if position settings have been disabled.\n *\n * @param {string} name The name of the block.\n *\n * @return {boolean} Whether padding setting is disabled.\n */\nexport function useIsPositionDisabled( { name: blockName } = {} ) {\n\tconst [ allowFixed, allowSticky ] = useSettings(\n\t\t'position.fixed',\n\t\t'position.sticky'\n\t);\n\tconst isDisabled = ! allowFixed && ! allowSticky;\n\n\treturn ! hasPositionSupport( blockName ) || isDisabled;\n}\n\n/*\n * Position controls rendered in an inspector control panel.\n *\n * @param {Object} props\n *\n * @return {Element} Position panel.\n */\nexport function PositionPanelPure( {\n\tstyle = {},\n\tclientId,\n\tname: blockName,\n\tsetAttributes,\n} ) {\n\tconst allowFixed = hasFixedPositionSupport( blockName );\n\tconst allowSticky = hasStickyPositionSupport( blockName );\n\tconst value = style?.position?.type;\n\n\tconst { firstParentClientId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParents } = select( blockEditorStore );\n\t\t\tconst parents = getBlockParents( clientId );\n\t\t\treturn { firstParentClientId: parents[ parents.length - 1 ] };\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst blockInformation = useBlockDisplayInformation( firstParentClientId );\n\tconst stickyHelpText =\n\t\tallowSticky && value === STICKY_OPTION.value && blockInformation\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %s: the name of the parent block. */\n\t\t\t\t\t__(\n\t\t\t\t\t\t'The block will stick to the scrollable area of the parent %s block.'\n\t\t\t\t\t),\n\t\t\t\t\tblockInformation.title\n\t\t\t )\n\t\t\t: null;\n\n\tconst options = useMemo( () => {\n\t\tconst availableOptions = [ DEFAULT_OPTION ];\n\t\t// Display options if they are allowed, or if a block already has a valid value set.\n\t\t// This allows for a block to be switched off from a position type that is not allowed.\n\t\tif ( allowSticky || value === STICKY_OPTION.value ) {\n\t\t\tavailableOptions.push( STICKY_OPTION );\n\t\t}\n\t\tif ( allowFixed || value === FIXED_OPTION.value ) {\n\t\t\tavailableOptions.push( FIXED_OPTION );\n\t\t}\n\t\treturn availableOptions;\n\t}, [ allowFixed, allowSticky, value ] );\n\n\tconst onChangeType = ( next ) => {\n\t\t// For now, use a hard-coded `0px` value for the position.\n\t\t// `0px` is preferred over `0` as it can be used in `calc()` functions.\n\t\t// In the future, it could be useful to allow for an offset value.\n\t\tconst placementValue = '0px';\n\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: next,\n\t\t\t\ttop:\n\t\t\t\t\tnext === 'sticky' || next === 'fixed'\n\t\t\t\t\t\t? placementValue\n\t\t\t\t\t\t: undefined,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\tconst selectedOption = value\n\t\t? options.find( ( option ) => option.value === value ) || DEFAULT_OPTION\n\t\t: DEFAULT_OPTION;\n\n\t// Only display position controls if there is at least one option to choose from.\n\treturn Platform.select( {\n\t\tweb:\n\t\t\toptions.length > 1 ? (\n\t\t\t\t<InspectorControls group=\"position\">\n\t\t\t\t\t<BaseControl\n\t\t\t\t\t\tclassName=\"block-editor-hooks__position-selection\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\thelp={ stickyHelpText }\n\t\t\t\t\t>\n\t\t\t\t\t\t<CustomSelectControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tclassName=\"block-editor-hooks__position-selection__select-control\"\n\t\t\t\t\t\t\tlabel={ __( 'Position' ) }\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\tdescribedBy={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Currently selected position.\n\t\t\t\t\t\t\t\t__( 'Currently selected position: %s' ),\n\t\t\t\t\t\t\t\tselectedOption.name\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\toptions={ options }\n\t\t\t\t\t\t\tvalue={ selectedOption }\n\t\t\t\t\t\t\t__experimentalShowSelectedHint\n\t\t\t\t\t\t\tonChange={ ( { selectedItem } ) => {\n\t\t\t\t\t\t\t\tonChangeType( selectedItem.value );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BaseControl>\n\t\t\t\t</InspectorControls>\n\t\t\t) : null,\n\t\tnative: null,\n\t} );\n}\n\nexport default {\n\tedit: function Edit( props ) {\n\t\tconst isPositionDisabled = useIsPositionDisabled( props );\n\t\tif ( isPositionDisabled ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn <PositionPanelPure { ...props } />;\n\t},\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, POSITION_SUPPORT_KEY );\n\t},\n};\n\nfunction useBlockProps( { name, style } ) {\n\tconst hasPositionBlockSupport = hasBlockSupport(\n\t\tname,\n\t\tPOSITION_SUPPORT_KEY\n\t);\n\tconst isPositionDisabled = useIsPositionDisabled( { name } );\n\tconst allowPositionStyles = hasPositionBlockSupport && ! isPositionDisabled;\n\n\tconst id = useInstanceId( useBlockProps );\n\n\t// Higher specificity to override defaults in editor UI.\n\tconst positionSelector = `.wp-container-${ id }.wp-container-${ id }`;\n\n\t// Get CSS string for the current position values.\n\tlet css;\n\tif ( allowPositionStyles ) {\n\t\tcss =\n\t\t\tgetPositionCSS( {\n\t\t\t\tselector: positionSelector,\n\t\t\t\tstyle,\n\t\t\t} ) || '';\n\t}\n\n\t// Attach a `wp-container-` id-based class name.\n\tconst className = classnames( {\n\t\t[ `wp-container-${ id }` ]: allowPositionStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t[ `is-position-${ style?.position?.type }` ]:\n\t\t\tallowPositionStyles && !! css && !! style?.position?.type,\n\t} );\n\n\tuseStyleOverride( { css } );\n\n\treturn { className };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAIA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAKA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,2BAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,WAAA,GAAAX,OAAA;AACA,IAAAY,MAAA,GAAAZ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GACF7F,cAAc,CAAE;MACfC,QAAQ,EAAE2F,gBAAgB;MAC1B1F;IACD,CAAE,CAAC,IAAI,EAAE;EACX;;EAEA;EACA,MAAMT,SAAS,GAAG,IAAAqG,mBAAU,EAAE;IAC7B,CAAG,gBAAgBJ,EAAI,EAAC,GAAID,mBAAmB,IAAI,CAAC,CAAEI,GAAG;IAAE;IAC3D,CAAG,eAAe3F,KAAK,EAAEI,QAAQ,EAAEF,IAAM,EAAC,GACzCqF,mBAAmB,IAAI,CAAC,CAAEI,GAAG,IAAI,CAAC,CAAE3F,KAAK,EAAEI,QAAQ,EAAEF;EACvD,CAAE,CAAC;EAEH,IAAA2F,uBAAgB,EAAE;IAAEF;EAAI,CAAE,CAAC;EAE3B,OAAO;IAAEpG;EAAU,CAAC;AACrB"}
1
+ {"version":3,"names":["_classnames","_interopRequireDefault","require","_i18n","_blocks","_components","_compose","_data","_element","_useSettings","_inspectorControls","_useBlockDisplayInformation","_utils","_lockUnlock","_store","CustomSelectControl","unlock","componentsPrivateApis","POSITION_SUPPORT_KEY","OPTION_CLASSNAME","DEFAULT_OPTION","key","value","name","__","className","STICKY_OPTION","_x","__experimentalHint","FIXED_OPTION","POSITION_SIDES","VALID_POSITION_TYPES","getPositionCSS","selector","style","output","type","positionType","position","includes","forEach","side","undefined","hasStickyPositionSupport","blockType","support","getBlockSupport","sticky","hasFixedPositionSupport","fixed","hasPositionSupport","hasPositionValue","props","attributes","hasStickyOrFixedPositionValue","resetPosition","setAttributes","cleanEmptyObject","top","right","bottom","left","useIsPositionDisabled","blockName","allowFixed","allowSticky","useSettings","isDisabled","PositionPanelPure","clientId","firstParentClientId","useSelect","select","getBlockParents","blockEditorStore","parents","length","blockInformation","useBlockDisplayInformation","stickyHelpText","sprintf","title","options","useMemo","availableOptions","push","onChangeType","next","placementValue","newStyle","selectedOption","find","option","Platform","web","_react","createElement","default","group","BaseControl","__nextHasNoMarginBottom","help","__next40pxDefaultSize","label","hideLabelFromVision","describedBy","__experimentalShowSelectedHint","onChange","selectedItem","size","native","_default","exports","edit","Edit","isPositionDisabled","useBlockProps","attributeKeys","hasSupport","hasBlockSupport","hasPositionBlockSupport","allowPositionStyles","id","useInstanceId","positionSelector","css","classnames","useStyleOverride"],"sources":["@wordpress/block-editor/src/hooks/position.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport {\n\tBaseControl,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo, Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../components/use-settings';\nimport InspectorControls from '../components/inspector-controls';\nimport useBlockDisplayInformation from '../components/use-block-display-information';\nimport { cleanEmptyObject, useStyleOverride } from './utils';\nimport { unlock } from '../lock-unlock';\nimport { store as blockEditorStore } from '../store';\n\nconst { CustomSelectControl } = unlock( componentsPrivateApis );\n\nconst POSITION_SUPPORT_KEY = 'position';\n\nconst OPTION_CLASSNAME =\n\t'block-editor-hooks__position-selection__select-control__option';\n\nconst DEFAULT_OPTION = {\n\tkey: 'default',\n\tvalue: '',\n\tname: __( 'Default' ),\n\tclassName: OPTION_CLASSNAME,\n};\n\nconst STICKY_OPTION = {\n\tkey: 'sticky',\n\tvalue: 'sticky',\n\tname: _x( 'Sticky', 'Name for the value of the CSS position property' ),\n\tclassName: OPTION_CLASSNAME,\n\t__experimentalHint: __(\n\t\t'The block will stick to the top of the window instead of scrolling.'\n\t),\n};\n\nconst FIXED_OPTION = {\n\tkey: 'fixed',\n\tvalue: 'fixed',\n\tname: _x( 'Fixed', 'Name for the value of the CSS position property' ),\n\tclassName: OPTION_CLASSNAME,\n\t__experimentalHint: __(\n\t\t'The block will not move when the page is scrolled.'\n\t),\n};\n\nconst POSITION_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nconst VALID_POSITION_TYPES = [ 'sticky', 'fixed' ];\n\n/**\n * Get calculated position CSS.\n *\n * @param {Object} props Component props.\n * @param {string} props.selector Selector to use.\n * @param {Object} props.style Style object.\n * @return {string} The generated CSS rules.\n */\nexport function getPositionCSS( { selector, style } ) {\n\tlet output = '';\n\n\tconst { type: positionType } = style?.position || {};\n\n\tif ( ! VALID_POSITION_TYPES.includes( positionType ) ) {\n\t\treturn output;\n\t}\n\n\toutput += `${ selector } {`;\n\toutput += `position: ${ positionType };`;\n\n\tPOSITION_SIDES.forEach( ( side ) => {\n\t\tif ( style?.position?.[ side ] !== undefined ) {\n\t\t\toutput += `${ side }: ${ style.position[ side ] };`;\n\t\t}\n\t} );\n\n\tif ( positionType === 'sticky' || positionType === 'fixed' ) {\n\t\t// TODO: Replace hard-coded z-index value with a z-index preset approach in theme.json.\n\t\toutput += `z-index: 10`;\n\t}\n\toutput += `}`;\n\n\treturn output;\n}\n\n/**\n * Determines if there is sticky position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasStickyPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.sticky );\n}\n\n/**\n * Determines if there is fixed position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasFixedPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.fixed );\n}\n\n/**\n * Determines if there is position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! support;\n}\n\n/**\n * Checks if there is a current value in the position block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a position value set.\n */\nexport function hasPositionValue( props ) {\n\treturn props.attributes.style?.position?.type !== undefined;\n}\n\n/**\n * Checks if the block is currently set to a sticky or fixed position.\n * This check is helpful for determining how to position block toolbars or other elements.\n *\n * @param {Object} attributes Block attributes.\n * @return {boolean} Whether or not the block is set to a sticky or fixed position.\n */\nexport function hasStickyOrFixedPositionValue( attributes ) {\n\tconst positionType = attributes?.style?.position?.type;\n\treturn positionType === 'sticky' || positionType === 'fixed';\n}\n\n/**\n * Resets the position block support attributes. This can be used when disabling\n * the position support controls for a block via a `ToolsPanel`.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetPosition( { attributes = {}, setAttributes } ) {\n\tconst { style = {} } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: undefined,\n\t\t\t\ttop: undefined,\n\t\t\t\tright: undefined,\n\t\t\t\tbottom: undefined,\n\t\t\t\tleft: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if position settings have been disabled.\n *\n * @param {string} name The name of the block.\n *\n * @return {boolean} Whether padding setting is disabled.\n */\nexport function useIsPositionDisabled( { name: blockName } = {} ) {\n\tconst [ allowFixed, allowSticky ] = useSettings(\n\t\t'position.fixed',\n\t\t'position.sticky'\n\t);\n\tconst isDisabled = ! allowFixed && ! allowSticky;\n\n\treturn ! hasPositionSupport( blockName ) || isDisabled;\n}\n\n/*\n * Position controls rendered in an inspector control panel.\n *\n * @param {Object} props\n *\n * @return {Element} Position panel.\n */\nexport function PositionPanelPure( {\n\tstyle = {},\n\tclientId,\n\tname: blockName,\n\tsetAttributes,\n} ) {\n\tconst allowFixed = hasFixedPositionSupport( blockName );\n\tconst allowSticky = hasStickyPositionSupport( blockName );\n\tconst value = style?.position?.type;\n\n\tconst { firstParentClientId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParents } = select( blockEditorStore );\n\t\t\tconst parents = getBlockParents( clientId );\n\t\t\treturn { firstParentClientId: parents[ parents.length - 1 ] };\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst blockInformation = useBlockDisplayInformation( firstParentClientId );\n\tconst stickyHelpText =\n\t\tallowSticky && value === STICKY_OPTION.value && blockInformation\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %s: the name of the parent block. */\n\t\t\t\t\t__(\n\t\t\t\t\t\t'The block will stick to the scrollable area of the parent %s block.'\n\t\t\t\t\t),\n\t\t\t\t\tblockInformation.title\n\t\t\t )\n\t\t\t: null;\n\n\tconst options = useMemo( () => {\n\t\tconst availableOptions = [ DEFAULT_OPTION ];\n\t\t// Display options if they are allowed, or if a block already has a valid value set.\n\t\t// This allows for a block to be switched off from a position type that is not allowed.\n\t\tif ( allowSticky || value === STICKY_OPTION.value ) {\n\t\t\tavailableOptions.push( STICKY_OPTION );\n\t\t}\n\t\tif ( allowFixed || value === FIXED_OPTION.value ) {\n\t\t\tavailableOptions.push( FIXED_OPTION );\n\t\t}\n\t\treturn availableOptions;\n\t}, [ allowFixed, allowSticky, value ] );\n\n\tconst onChangeType = ( next ) => {\n\t\t// For now, use a hard-coded `0px` value for the position.\n\t\t// `0px` is preferred over `0` as it can be used in `calc()` functions.\n\t\t// In the future, it could be useful to allow for an offset value.\n\t\tconst placementValue = '0px';\n\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: next,\n\t\t\t\ttop:\n\t\t\t\t\tnext === 'sticky' || next === 'fixed'\n\t\t\t\t\t\t? placementValue\n\t\t\t\t\t\t: undefined,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\tconst selectedOption = value\n\t\t? options.find( ( option ) => option.value === value ) || DEFAULT_OPTION\n\t\t: DEFAULT_OPTION;\n\n\t// Only display position controls if there is at least one option to choose from.\n\treturn Platform.select( {\n\t\tweb:\n\t\t\toptions.length > 1 ? (\n\t\t\t\t<InspectorControls group=\"position\">\n\t\t\t\t\t<BaseControl\n\t\t\t\t\t\tclassName=\"block-editor-hooks__position-selection\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\thelp={ stickyHelpText }\n\t\t\t\t\t>\n\t\t\t\t\t\t<CustomSelectControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tclassName=\"block-editor-hooks__position-selection__select-control\"\n\t\t\t\t\t\t\tlabel={ __( 'Position' ) }\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\tdescribedBy={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Currently selected position.\n\t\t\t\t\t\t\t\t__( 'Currently selected position: %s' ),\n\t\t\t\t\t\t\t\tselectedOption.name\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\toptions={ options }\n\t\t\t\t\t\t\tvalue={ selectedOption }\n\t\t\t\t\t\t\t__experimentalShowSelectedHint\n\t\t\t\t\t\t\tonChange={ ( { selectedItem } ) => {\n\t\t\t\t\t\t\t\tonChangeType( selectedItem.value );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BaseControl>\n\t\t\t\t</InspectorControls>\n\t\t\t) : null,\n\t\tnative: null,\n\t} );\n}\n\nexport default {\n\tedit: function Edit( props ) {\n\t\tconst isPositionDisabled = useIsPositionDisabled( props );\n\t\tif ( isPositionDisabled ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn <PositionPanelPure { ...props } />;\n\t},\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, POSITION_SUPPORT_KEY );\n\t},\n};\n\nfunction useBlockProps( { name, style } ) {\n\tconst hasPositionBlockSupport = hasBlockSupport(\n\t\tname,\n\t\tPOSITION_SUPPORT_KEY\n\t);\n\tconst isPositionDisabled = useIsPositionDisabled( { name } );\n\tconst allowPositionStyles = hasPositionBlockSupport && ! isPositionDisabled;\n\n\tconst id = useInstanceId( useBlockProps );\n\n\t// Higher specificity to override defaults in editor UI.\n\tconst positionSelector = `.wp-container-${ id }.wp-container-${ id }`;\n\n\t// Get CSS string for the current position values.\n\tlet css;\n\tif ( allowPositionStyles ) {\n\t\tcss =\n\t\t\tgetPositionCSS( {\n\t\t\t\tselector: positionSelector,\n\t\t\t\tstyle,\n\t\t\t} ) || '';\n\t}\n\n\t// Attach a `wp-container-` id-based class name.\n\tconst className = classnames( {\n\t\t[ `wp-container-${ id }` ]: allowPositionStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t[ `is-position-${ style?.position?.type }` ]:\n\t\t\tallowPositionStyles && !! css && !! style?.position?.type,\n\t} );\n\n\tuseStyleOverride( { css } );\n\n\treturn { className };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAIA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAKA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,2BAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,WAAA,GAAAX,OAAA;AACA,IAAAY,MAAA,GAAAZ,OAAA;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;;AAQA,MAAM;EAAEa;AAAoB,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;AA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AU,EAAE;IAC7B,CAAG,gBAAgBJ,EAAI,EAAC,GAAID,mBAAmB,IAAI,CAAC,CAAEI,GAAG;IAAE;IAC3D,CAAG,eAAe3F,KAAK,EAAEI,QAAQ,EAAEF,IAAM,EAAC,GACzCqF,mBAAmB,IAAI,CAAC,CAAEI,GAAG,IAAI,CAAC,CAAE3F,KAAK,EAAEI,QAAQ,EAAEF;EACvD,CAAE,CAAC;EAEH,IAAA2F,uBAAgB,EAAE;IAAEF;EAAI,CAAE,CAAC;EAE3B,OAAO;IAAEpG;EAAU,CAAC;AACrB"}
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.MarginVisualizer = MarginVisualizer;
8
+ exports.PaddingVisualizer = PaddingVisualizer;
9
+ var _react = require("react");
10
+ var _element = require("@wordpress/element");
11
+ var _isShallowEqual = _interopRequireDefault(require("@wordpress/is-shallow-equal"));
12
+ var _cover = _interopRequireDefault(require("../components/block-popover/cover"));
13
+ var _useBlockRefs = require("../components/block-list/use-block-props/use-block-refs");
14
+ /**
15
+ * WordPress dependencies
16
+ */
17
+
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+
22
+ function SpacingVisualizer({
23
+ clientId,
24
+ value,
25
+ computeStyle,
26
+ forceShow
27
+ }) {
28
+ const blockElement = (0, _useBlockRefs.__unstableUseBlockElement)(clientId);
29
+ const [style, updateStyle] = (0, _element.useReducer)(() => computeStyle(blockElement));
30
+ (0, _element.useLayoutEffect)(() => {
31
+ if (!blockElement) {
32
+ return;
33
+ }
34
+ // It's not sufficient to read the computed spacing value when value.spacing changes as
35
+ // useEffect may run before the browser recomputes CSS. We therefore combine
36
+ // useLayoutEffect and two rAF calls to ensure that we read the spacing after the current
37
+ // paint but before the next paint.
38
+ // See https://github.com/WordPress/gutenberg/pull/59227.
39
+ window.requestAnimationFrame(() => window.requestAnimationFrame(updateStyle));
40
+ }, [blockElement, value]);
41
+ const previousValue = (0, _element.useRef)(value);
42
+ const [isActive, setIsActive] = (0, _element.useState)(false);
43
+ (0, _element.useEffect)(() => {
44
+ if ((0, _isShallowEqual.default)(value, previousValue.current) || forceShow) {
45
+ return;
46
+ }
47
+ setIsActive(true);
48
+ previousValue.current = value;
49
+ const timeout = setTimeout(() => {
50
+ setIsActive(false);
51
+ }, 400);
52
+ return () => {
53
+ setIsActive(false);
54
+ clearTimeout(timeout);
55
+ };
56
+ }, [value, forceShow]);
57
+ if (!isActive && !forceShow) {
58
+ return null;
59
+ }
60
+ return (0, _react.createElement)(_cover.default, {
61
+ clientId: clientId,
62
+ __unstablePopoverSlot: "block-toolbar"
63
+ }, (0, _react.createElement)("div", {
64
+ className: "block-editor__spacing-visualizer",
65
+ style: style
66
+ }));
67
+ }
68
+ function getComputedCSS(element, property) {
69
+ return element.ownerDocument.defaultView.getComputedStyle(element).getPropertyValue(property);
70
+ }
71
+ function MarginVisualizer({
72
+ clientId,
73
+ value,
74
+ forceShow
75
+ }) {
76
+ return (0, _react.createElement)(SpacingVisualizer, {
77
+ clientId: clientId,
78
+ value: value?.spacing?.margin,
79
+ computeStyle: blockElement => {
80
+ const top = getComputedCSS(blockElement, 'margin-top');
81
+ const right = getComputedCSS(blockElement, 'margin-right');
82
+ const bottom = getComputedCSS(blockElement, 'margin-bottom');
83
+ const left = getComputedCSS(blockElement, 'margin-left');
84
+ return {
85
+ borderTopWidth: top,
86
+ borderRightWidth: right,
87
+ borderBottomWidth: bottom,
88
+ borderLeftWidth: left,
89
+ top: top ? `-${top}` : 0,
90
+ right: right ? `-${right}` : 0,
91
+ bottom: bottom ? `-${bottom}` : 0,
92
+ left: left ? `-${left}` : 0
93
+ };
94
+ },
95
+ forceShow: forceShow
96
+ });
97
+ }
98
+ function PaddingVisualizer({
99
+ clientId,
100
+ value,
101
+ forceShow
102
+ }) {
103
+ return (0, _react.createElement)(SpacingVisualizer, {
104
+ clientId: clientId,
105
+ value: value?.spacing?.padding,
106
+ computeStyle: blockElement => ({
107
+ borderTopWidth: getComputedCSS(blockElement, 'padding-top'),
108
+ borderRightWidth: getComputedCSS(blockElement, 'padding-right'),
109
+ borderBottomWidth: getComputedCSS(blockElement, 'padding-bottom'),
110
+ borderLeftWidth: getComputedCSS(blockElement, 'padding-left')
111
+ }),
112
+ forceShow: forceShow
113
+ });
114
+ }
115
+ //# sourceMappingURL=spacing-visualizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_element","require","_isShallowEqual","_interopRequireDefault","_cover","_useBlockRefs","SpacingVisualizer","clientId","value","computeStyle","forceShow","blockElement","useBlockElement","style","updateStyle","useReducer","useLayoutEffect","window","requestAnimationFrame","previousValue","useRef","isActive","setIsActive","useState","useEffect","isShallowEqual","current","timeout","setTimeout","clearTimeout","_react","createElement","default","__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\tblockElement,\n\t\t\t\t\t'padding-bottom'\n\t\t\t\t),\n\t\t\t\tborderLeftWidth: getComputedCSS( blockElement, 'padding-left' ),\n\t\t\t} ) }\n\t\t\tforceShow={ forceShow }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAOA,IAAAC,eAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAhBA;AACA;AACA;;AAUA;AACA;AACA;;AAIA,SAASK,iBAAiBA,CAAE;EAAEC,QAAQ;EAAEC,KAAK;EAAEC,YAAY;EAAEC;AAAU,CAAC,EAAG;EAC1E,MAAMC,YAAY,GAAG,IAAAC,uCAAe,EAAEL,QAAS,CAAC;EAChD,MAAM,CAAEM,KAAK,EAAEC,WAAW,CAAE,GAAG,IAAAC,mBAAU,EAAE,MAC1CN,YAAY,CAAEE,YAAa,CAC5B,CAA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,QAAQ,EAAGA,QAAU;IACrBC,KAAK,EAAGA,KAAK,EAAEmC,OAAO,EAAEW,OAAS;IACjC7C,YAAY,EAAKE,YAAY,KAAQ;MACpCsC,cAAc,EAAEd,cAAc,CAAExB,YAAY,EAAE,aAAc,CAAC;MAC7DuC,gBAAgB,EAAEf,cAAc,CAC/BxB,YAAY,EACZ,eACD,CAAC;MACDwC,iBAAiB,EAAEhB,cAAc,CAChCxB,YAAY,EACZ,gBACD,CAAC;MACDyC,eAAe,EAAEjB,cAAc,CAAExB,YAAY,EAAE,cAAe;IAC/D,CAAC,CAAI;IACLD,SAAS,EAAGA;EAAW,CACvB,CAAC;AAEJ"}
@@ -3,14 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.BLOCK_BINDINGS_ALLOWED_BLOCKS = void 0;
6
+ exports.canBindAttribute = canBindAttribute;
7
+ exports.canBindBlock = canBindBlock;
7
8
  var _react = require("react");
8
9
  var _blocks = require("@wordpress/blocks");
9
10
  var _compose = require("@wordpress/compose");
10
11
  var _data = require("@wordpress/data");
12
+ var _element = require("@wordpress/element");
11
13
  var _hooks = require("@wordpress/hooks");
12
- var _store = require("../store");
13
- var _context = require("../components/block-edit/context");
14
+ var _richText = require("@wordpress/rich-text");
14
15
  var _lockUnlock = require("../lock-unlock");
15
16
  /**
16
17
  * WordPress dependencies
@@ -30,70 +31,192 @@ var _lockUnlock = require("../lock-unlock");
30
31
  * @return {WPHigherOrderComponent} Higher-order component.
31
32
  */
32
33
 
33
- const BLOCK_BINDINGS_ALLOWED_BLOCKS = exports.BLOCK_BINDINGS_ALLOWED_BLOCKS = {
34
+ const BLOCK_BINDINGS_ALLOWED_BLOCKS = {
34
35
  'core/paragraph': ['content'],
35
36
  'core/heading': ['content'],
36
37
  'core/image': ['url', 'title', 'alt'],
37
38
  'core/button': ['url', 'text', 'linkTarget']
38
39
  };
39
- const createEditFunctionWithBindingsAttribute = () => (0, _compose.createHigherOrderComponent)(BlockEdit => props => {
40
- const {
41
- clientId,
42
- name: blockName
43
- } = (0, _context.useBlockEditContext)();
40
+
41
+ /**
42
+ * Based on the given block name,
43
+ * check if it is possible to bind the block.
44
+ *
45
+ * @param {string} blockName - The block name.
46
+ * @return {boolean} Whether it is possible to bind the block to sources.
47
+ */
48
+ function canBindBlock(blockName) {
49
+ return blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS;
50
+ }
51
+
52
+ /**
53
+ * Based on the given block name and attribute name,
54
+ * check if it is possible to bind the block attribute.
55
+ *
56
+ * @param {string} blockName - The block name.
57
+ * @param {string} attributeName - The attribute name.
58
+ * @return {boolean} Whether it is possible to bind the block attribute.
59
+ */
60
+ function canBindAttribute(blockName, attributeName) {
61
+ return canBindBlock(blockName) && BLOCK_BINDINGS_ALLOWED_BLOCKS[blockName].includes(attributeName);
62
+ }
63
+
64
+ /**
65
+ * This component is responsible for detecting and
66
+ * propagating data changes from the source to the block.
67
+ *
68
+ * @param {Object} props - The component props.
69
+ * @param {string} props.attrName - The attribute name.
70
+ * @param {Object} props.blockProps - The block props with bound attribute.
71
+ * @param {Object} props.source - Source handler.
72
+ * @param {Object} props.args - The arguments to pass to the source.
73
+ * @param {Function} props.onPropValueChange - The function to call when the attribute value changes.
74
+ * @return {null} Data-handling component. Render nothing.
75
+ */
76
+ const BindingConnector = ({
77
+ args,
78
+ attrName,
79
+ blockProps,
80
+ source,
81
+ onPropValueChange
82
+ }) => {
44
83
  const {
45
- getBlockBindingsSource
46
- } = (0, _lockUnlock.unlock)((0, _data.useSelect)(_store.store));
84
+ placeholder,
85
+ value: propValue
86
+ } = source.useSource(blockProps, args);
47
87
  const {
48
- getBlockAttributes
49
- } = (0, _data.useSelect)(_store.store);
50
- const updatedAttributes = getBlockAttributes(clientId);
51
- if (updatedAttributes?.metadata?.bindings) {
52
- Object.entries(updatedAttributes.metadata.bindings).forEach(([attributeName, settings]) => {
53
- const source = getBlockBindingsSource(settings.source);
54
- if (source && source.useSource) {
55
- // Second argument (`updateMetaValue`) will be used to update the value in the future.
56
- const {
57
- placeholder,
58
- useValue: [metaValue = null] = []
59
- } = source.useSource(props, settings.args);
60
- if (placeholder && !metaValue) {
61
- // If the attribute is `src` or `href`, a placeholder can't be used because it is not a valid url.
62
- // Adding this workaround until attributes and metadata fields types are improved and include `url`.
63
- const htmlAttribute = (0, _blocks.getBlockType)(blockName).attributes[attributeName].attribute;
64
- if (htmlAttribute === 'src' || htmlAttribute === 'href') {
65
- updatedAttributes[attributeName] = null;
66
- } else {
67
- updatedAttributes[attributeName] = placeholder;
68
- }
69
- }
70
- if (metaValue) {
71
- updatedAttributes[attributeName] = metaValue;
72
- }
88
+ name: blockName
89
+ } = blockProps;
90
+ const attrValue = blockProps.attributes[attrName];
91
+ const updateBoundAttibute = (0, _element.useCallback)((newAttrValue, prevAttrValue) => {
92
+ /*
93
+ * If the attribute is a RichTextData instance,
94
+ * (core/paragraph, core/heading, core/button, etc.)
95
+ * compare its HTML representation with the new value.
96
+ *
97
+ * To do: it looks like a workaround.
98
+ * Consider improving the attribute and metadata fields types.
99
+ */
100
+ if (prevAttrValue instanceof _richText.RichTextData) {
101
+ // Bail early if the Rich Text value is the same.
102
+ if (prevAttrValue.toHTMLString() === newAttrValue) {
103
+ return;
73
104
  }
105
+
106
+ /*
107
+ * To preserve the value type,
108
+ * convert the new value to a RichTextData instance.
109
+ */
110
+ newAttrValue = _richText.RichTextData.fromHTMLString(newAttrValue);
111
+ }
112
+ if (prevAttrValue === newAttrValue) {
113
+ return;
114
+ }
115
+ onPropValueChange({
116
+ [attrName]: newAttrValue
74
117
  });
75
- }
76
- return (0, _react.createElement)(BlockEdit, {
77
- key: "edit",
118
+ }, [attrName, onPropValueChange]);
119
+ (0, _element.useLayoutEffect)(() => {
120
+ if (typeof propValue !== 'undefined') {
121
+ updateBoundAttibute(propValue, attrValue);
122
+ } else if (placeholder) {
123
+ /*
124
+ * Placeholder fallback.
125
+ * If the attribute is `src` or `href`,
126
+ * a placeholder can't be used because it is not a valid url.
127
+ * Adding this workaround until
128
+ * attributes and metadata fields types are improved and include `url`.
129
+ */
130
+ const htmlAttribute = (0, _blocks.getBlockType)(blockName).attributes[attrName].attribute;
131
+ if (htmlAttribute === 'src' || htmlAttribute === 'href') {
132
+ updateBoundAttibute(null);
133
+ return;
134
+ }
135
+ updateBoundAttibute(placeholder);
136
+ }
137
+ }, [updateBoundAttibute, propValue, attrValue, placeholder, blockName, attrName]);
138
+ return null;
139
+ };
140
+
141
+ /**
142
+ * BlockBindingBridge acts like a component wrapper
143
+ * that connects the bound attributes of a block
144
+ * to the source handlers.
145
+ * For this, it creates a BindingConnector for each bound attribute.
146
+ *
147
+ * @param {Object} props - The component props.
148
+ * @param {Object} props.blockProps - The BlockEdit props object.
149
+ * @param {Object} props.bindings - The block bindings settings.
150
+ * @param {Function} props.onPropValueChange - The function to call when the attribute value changes.
151
+ * @return {null} Data-handling component. Render nothing.
152
+ */
153
+ function BlockBindingBridge({
154
+ blockProps,
155
+ bindings,
156
+ onPropValueChange
157
+ }) {
158
+ const blockBindingsSources = (0, _lockUnlock.unlock)((0, _data.useSelect)(_blocks.store)).getAllBlockBindingsSources();
159
+ return (0, _react.createElement)(_react.Fragment, null, Object.entries(bindings).map(([attrName, boundAttribute]) => {
160
+ // Bail early if the block doesn't have a valid source handler.
161
+ const source = blockBindingsSources[boundAttribute.source];
162
+ if (!source?.useSource) {
163
+ return null;
164
+ }
165
+ return (0, _react.createElement)(BindingConnector, {
166
+ key: attrName,
167
+ attrName: attrName,
168
+ source: source,
169
+ blockProps: blockProps,
170
+ args: boundAttribute.args,
171
+ onPropValueChange: onPropValueChange
172
+ });
173
+ }));
174
+ }
175
+ const withBlockBindingSupport = (0, _compose.createHigherOrderComponent)(BlockEdit => props => {
176
+ /*
177
+ * Collect and update the bound attributes
178
+ * in a separate state.
179
+ */
180
+ const [boundAttributes, setBoundAttributes] = (0, _element.useState)({});
181
+ const updateBoundAttributes = (0, _element.useCallback)(newAttributes => setBoundAttributes(prev => ({
182
+ ...prev,
183
+ ...newAttributes
184
+ })), []);
185
+
186
+ /*
187
+ * Create binding object filtering
188
+ * only the attributes that can be bound.
189
+ */
190
+ const bindings = Object.fromEntries(Object.entries(props.attributes.metadata?.bindings || {}).filter(([attrName]) => canBindAttribute(props.name, attrName)));
191
+ return (0, _react.createElement)(_react.Fragment, null, Object.keys(bindings).length > 0 && (0, _react.createElement)(BlockBindingBridge, {
192
+ blockProps: props,
193
+ bindings: bindings,
194
+ onPropValueChange: updateBoundAttributes
195
+ }), (0, _react.createElement)(BlockEdit, {
78
196
  ...props,
79
- attributes: updatedAttributes
80
- });
81
- }, 'useBoundAttributes');
197
+ attributes: {
198
+ ...props.attributes,
199
+ ...boundAttributes
200
+ }
201
+ }));
202
+ }, 'withBlockBindingSupport');
82
203
 
83
204
  /**
84
205
  * Filters a registered block's settings to enhance a block's `edit` component
85
206
  * to upgrade bound attributes.
86
207
  *
87
- * @param {WPBlockSettings} settings Registered block settings.
88
- *
208
+ * @param {WPBlockSettings} settings - Registered block settings.
209
+ * @param {string} name - Block name.
89
210
  * @return {WPBlockSettings} Filtered block settings.
90
211
  */
91
- function shimAttributeSource(settings) {
92
- if (!(settings.name in BLOCK_BINDINGS_ALLOWED_BLOCKS)) {
212
+ function shimAttributeSource(settings, name) {
213
+ if (!canBindBlock(name)) {
93
214
  return settings;
94
215
  }
95
- settings.edit = createEditFunctionWithBindingsAttribute()(settings.edit);
96
- return settings;
216
+ return {
217
+ ...settings,
218
+ edit: withBlockBindingSupport(settings.edit)
219
+ };
97
220
  }
98
221
  (0, _hooks.addFilter)('blocks.registerBlockType', 'core/editor/custom-sources-backwards-compatibility/shim-attribute-source', shimAttributeSource);
99
222
  //# sourceMappingURL=use-bindings-attributes.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_blocks","require","_compose","_data","_hooks","_store","_context","_lockUnlock","BLOCK_BINDINGS_ALLOWED_BLOCKS","exports","createEditFunctionWithBindingsAttribute","createHigherOrderComponent","BlockEdit","props","clientId","name","blockName","useBlockEditContext","getBlockBindingsSource","unlock","useSelect","blockEditorStore","getBlockAttributes","updatedAttributes","metadata","bindings","Object","entries","forEach","attributeName","settings","source","useSource","placeholder","useValue","metaValue","args","htmlAttribute","getBlockType","attributes","attribute","_react","createElement","key","shimAttributeSource","edit","addFilter"],"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":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAIA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAZA;AACA;AACA;;AAKA;AACA;AACA;;AAKA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEO,MAAMO,6BAA6B,GAAAC,OAAA,CAAAD,6BAAA,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,aAAa,EAAE,CAAE,KAAK,EAAE,MAAM,EAAE,YAAY;AAC7C,CAAC;AAED,MAAME,uCAAuC,GAAGA,CAAA,KAC/C,IAAAC,mCAA0B,EACvBC,SAAS,IAAQC,KAAK,IAAM;EAC7B,MAAM;IAAEC,QAAQ;IAAEC,IAAI,EAAEC;EAAU,CAAC,GAAG,IAAAC,4BAAmB,EAAC,CAAC;EAC3D,MAAM;IAAEC;EAAuB,CAAC,GAAG,IAAAC,kBAAM,EACxC,IAAAC,eAAS,EA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,EACD,oBACD,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASqB,mBAAmBA,CAAEd,QAAQ,EAAG;EACxC,IAAK,EAAIA,QAAQ,CAACf,IAAI,IAAIP,6BAA6B,CAAE,EAAG;IAC3D,OAAOsB,QAAQ;EAChB;EACAA,QAAQ,CAACe,IAAI,GAAGnC,uCAAuC,CAAC,CAAC,CAAEoB,QAAQ,CAACe,IAAK,CAAC;EAE1E,OAAOf,QAAQ;AAChB;AAEA,IAAAgB,gBAAS,EACR,0BAA0B,EAC1B,0EAA0E,EAC1EF,mBACD,CAAC"}
1
+ {"version":3,"names":["_blocks","require","_compose","_data","_element","_hooks","_richText","_lockUnlock","BLOCK_BINDINGS_ALLOWED_BLOCKS","canBindBlock","blockName","canBindAttribute","attributeName","includes","BindingConnector","args","attrName","blockProps","source","onPropValueChange","placeholder","value","propValue","useSource","name","attrValue","attributes","updateBoundAttibute","useCallback","newAttrValue","prevAttrValue","RichTextData","toHTMLString","fromHTMLString","useLayoutEffect","htmlAttribute","getBlockType","attribute","BlockBindingBridge","bindings","blockBindingsSources","unlock","useSelect","blocksStore","getAllBlockBindingsSources","_react","createElement","Fragment","Object","entries","map","boundAttribute","key","withBlockBindingSupport","createHigherOrderComponent","BlockEdit","props","boundAttributes","setBoundAttributes","useState","updateBoundAttributes","newAttributes","prev","fromEntries","metadata","filter","keys","length","shimAttributeSource","settings","edit","addFilter"],"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":";;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAKA,IAAAM,WAAA,GAAAN,OAAA;AAbA;AACA;AACA;;AAQA;AACA;AACA;;AAGA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA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AAA,CAAAC,aAAA,EAACR,kBAAkB;IAClBrB,UAAU,EAAGuC,KAAO;IACpBjB,QAAQ,EAAGA,QAAU;IACrBpB,iBAAiB,EAAGyC;EAAuB,CAC3C,CACD,EAED,IAAAf,MAAA,CAAAC,aAAA,EAACS,SAAS;IAAA,GACJC,KAAK;IACV9B,UAAU,EAAG;MAAE,GAAG8B,KAAK,CAAC9B,UAAU;MAAE,GAAG+B;IAAgB;EAAG,CAC1D,CACA,CAAC;AAEL,CAAC,EACD,yBACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASW,mBAAmBA,CAAEC,QAAQ,EAAE7C,IAAI,EAAG;EAC9C,IAAK,CAAEf,YAAY,CAAEe,IAAK,CAAC,EAAG;IAC7B,OAAO6C,QAAQ;EAChB;EAEA,OAAO;IACN,GAAGA,QAAQ;IACXC,IAAI,EAAEjB,uBAAuB,CAAEgB,QAAQ,CAACC,IAAK;EAC9C,CAAC;AACF;AAEA,IAAAC,gBAAS,EACR,0BAA0B,EAC1B,0EAA0E,EAC1EH,mBACD,CAAC"}
@@ -42,12 +42,11 @@ function getTypographyClassesAndStyles(attributes, settings) {
42
42
  kebabCase
43
43
  } = (0, _lockUnlock.unlock)(_components.privateApis);
44
44
  let typographyStyles = attributes?.style?.typography || {};
45
- const fluidTypographySettings = (0, _typographyUtils.getFluidTypographyOptionsFromSettings)(settings);
46
45
  typographyStyles = {
47
46
  ...typographyStyles,
48
47
  fontSize: (0, _typographyUtils.getTypographyFontSizeValue)({
49
48
  size: attributes?.style?.typography?.fontSize
50
- }, fluidTypographySettings)
49
+ }, settings)
51
50
  };
52
51
  const style = (0, _style.getInlineStyles)({
53
52
  typography: typographyStyles
@@ -1 +1 @@
1
- {"version":3,"names":["_classnames","_interopRequireDefault","require","_components","_style","_fontSizes","_typographyUtils","_lockUnlock","getTypographyClassesAndStyles","attributes","settings","kebabCase","unlock","componentsPrivateApis","typographyStyles","style","typography","fluidTypographySettings","getFluidTypographyOptionsFromSettings","fontSize","getTypographyFontSizeValue","size","getInlineStyles","fontFamilyClassName","fontFamily","className","classnames","getFontSizeClass"],"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":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AAIA,IAAAK,WAAA,GAAAL,OAAA;AAnBA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASM,6BAA6BA,CAAEC,UAAU,EAAEC,QAAQ,EAAG;EACrE,MAAM;IAAEC;EAAU,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;EACrD,IAAIC,gBAAgB,GAAGL,UAAU,EAAEM,KAAK,EAAEC,UAAU,IAAI,CAAC,CAAC;EAC1D,MAAMC,uBAAuB,GAC5B,IAAAC,sDAAqC,EAAER,QAAS,CAAC;EAElDI,gBAAgB,GAAG;IAClB,GAAGA,gBAAgB;IACnBK,QAAQ,EAAE,IAAAC,2CAA0B,EACnC;MAAEC,IAAI,EAAEZ,UAAU,EAAEM,KAAK,EAAEC,UAAU,EAAEG;IAAS,CAAC,EACjDF,uBACD;EACD,CAAC;EAED,MAAMF,KAAK,GAAG,IAAAO,sBAAe,EAAE;IAAEN,UAAU,EAAEF;EAAiB,CAAE,CAAC;EACjE,MAAMS,mBAAmB,GAAG,CAAC,CAAEd,UAAU,EAAEe,UAAU,GACjD,OAAOb,SAAS,CAAEF,UAAU,CAACe,UAAW,CAAG,cAAa,GACzD,EAAE;EAEL,MAAMC,SAAS,GAAG,IAAAC,mBAAU,EAC3BH,mBAAmB,EACnB,IAAAI,2BAAgB,EAAElB,UAAU,EAAEU,QAAS,CACxC,CAAC;EAED,OAAO;IACNM,SAAS;IACTV;EACD,CAAC;AACF"}
1
+ {"version":3,"names":["_classnames","_interopRequireDefault","require","_components","_style","_fontSizes","_typographyUtils","_lockUnlock","getTypographyClassesAndStyles","attributes","settings","kebabCase","unlock","componentsPrivateApis","typographyStyles","style","typography","fontSize","getTypographyFontSizeValue","size","getInlineStyles","fontFamilyClassName","fontFamily","className","classnames","getFontSizeClass"],"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":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASM,6BAA6BA,CAAEC,UAAU,EAAEC,QAAQ,EAAG;EACrE,MAAM;IAAEC;EAAU,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;EACrD,IAAIC,gBAAgB,GAAGL,UAAU,EAAEM,KAAK,EAAEC,UAAU,IAAI,CAAC,CAAC;EAC1DF,gBAAgB,GAAG;IAClB,GAAGA,gBAAgB;IACnBG,QAAQ,EAAE,IAAAC,2CAA0B,EACnC;MAAEC,IAAI,EAAEV,UAAU,EAAEM,KAAK,EAAEC,UAAU,EAAEC;IAAS,CAAC,EACjDP,QACD;EACD,CAAC;EAED,MAAMK,KAAK,GAAG,IAAAK,sBAAe,EAAE;IAAEJ,UAAU,EAAEF;EAAiB,CAAE,CAAC;EACjE,MAAMO,mBAAmB,GAAG,CAAC,CAAEZ,UAAU,EAAEa,UAAU,GACjD,OAAOX,SAAS,CAAEF,UAAU,CAACa,UAAW,CAAG,cAAa,GACzD,EAAE;EAEL,MAAMC,SAAS,GAAG,IAAAC,mBAAU,EAC3BH,mBAAmB,EACnB,IAAAI,2BAAgB,EAAEhB,UAAU,EAAEQ,QAAS,CACxC,CAAC;EAED,OAAO;IACNM,SAAS;IACTR;EACD,CAAC;AACF"}