@wordpress/block-editor 13.4.0 → 14.1.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 (533) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +20 -15
  3. package/build/autocompleters/block.js +1 -1
  4. package/build/autocompleters/block.js.map +1 -1
  5. package/build/components/block-breadcrumb/index.js +3 -1
  6. package/build/components/block-breadcrumb/index.js.map +1 -1
  7. package/build/components/block-draggable/index.js +2 -2
  8. package/build/components/block-draggable/index.js.map +1 -1
  9. package/build/components/block-list/use-block-props/index.js +2 -2
  10. package/build/components/block-list/use-block-props/index.js.map +1 -1
  11. package/build/components/block-list/use-block-props/use-block-refs.js +24 -32
  12. package/build/components/block-list/use-block-props/use-block-refs.js.map +1 -1
  13. package/build/components/block-list/use-in-between-inserter.js +11 -4
  14. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  15. package/build/components/block-mover/index.js +1 -2
  16. package/build/components/block-mover/index.js.map +1 -1
  17. package/build/components/block-popover/cover.js +1 -1
  18. package/build/components/block-popover/cover.js.map +1 -1
  19. package/build/components/block-popover/inbetween.js +2 -2
  20. package/build/components/block-popover/inbetween.js.map +1 -1
  21. package/build/components/block-popover/index.js +2 -2
  22. package/build/components/block-popover/index.js.map +1 -1
  23. package/build/components/block-settings-menu/block-mode-toggle.js +28 -34
  24. package/build/components/block-settings-menu/block-mode-toggle.js.map +1 -1
  25. package/build/components/block-tools/block-selection-button.js +1 -2
  26. package/build/components/block-tools/block-selection-button.js.map +1 -1
  27. package/build/components/block-tools/index.js +1 -1
  28. package/build/components/block-tools/index.js.map +1 -1
  29. package/build/components/block-tools/insertion-point.js +14 -3
  30. package/build/components/block-tools/insertion-point.js.map +1 -1
  31. package/build/components/block-tools/use-block-toolbar-popover-props.js +1 -1
  32. package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  33. package/build/components/block-tools/use-show-block-tools.js +2 -1
  34. package/build/components/block-tools/use-show-block-tools.js.map +1 -1
  35. package/build/components/block-tools/zoom-out-mode-inserters.js +22 -19
  36. package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  37. package/build/components/block-tools/zoom-out-toolbar.js +0 -1
  38. package/build/components/block-tools/zoom-out-toolbar.js.map +1 -1
  39. package/build/components/border-radius-control/index.js +1 -0
  40. package/build/components/border-radius-control/index.js.map +1 -1
  41. package/build/components/child-layout-control/index.js +3 -1
  42. package/build/components/child-layout-control/index.js.map +1 -1
  43. package/build/components/convert-to-group-buttons/index.js +1 -1
  44. package/build/components/convert-to-group-buttons/index.js.map +1 -1
  45. package/build/components/date-format-picker/index.js +2 -0
  46. package/build/components/date-format-picker/index.js.map +1 -1
  47. package/build/components/dimensions-tool/scale-tool.js +1 -0
  48. package/build/components/dimensions-tool/scale-tool.js.map +1 -1
  49. package/build/components/font-appearance-control/index.js +3 -0
  50. package/build/components/font-appearance-control/index.js.map +1 -1
  51. package/build/components/font-family/index.js +15 -0
  52. package/build/components/font-family/index.js.map +1 -1
  53. package/build/components/global-styles/background-panel.js +153 -77
  54. package/build/components/global-styles/background-panel.js.map +1 -1
  55. package/build/components/global-styles/get-global-styles-changes.js +3 -1
  56. package/build/components/global-styles/get-global-styles-changes.js.map +1 -1
  57. package/build/components/global-styles/hooks.js +0 -7
  58. package/build/components/global-styles/hooks.js.map +1 -1
  59. package/build/components/global-styles/image-settings-panel.js +1 -0
  60. package/build/components/global-styles/image-settings-panel.js.map +1 -1
  61. package/build/components/global-styles/index.js +0 -6
  62. package/build/components/global-styles/index.js.map +1 -1
  63. package/build/components/global-styles/typography-panel.js +0 -1
  64. package/build/components/global-styles/typography-panel.js.map +1 -1
  65. package/build/components/global-styles/use-global-styles-output.js +59 -40
  66. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  67. package/build/components/global-styles/utils.js +80 -0
  68. package/build/components/global-styles/utils.js.map +1 -1
  69. package/build/components/grid/grid-item-movers.js +30 -26
  70. package/build/components/grid/grid-item-movers.js.map +1 -1
  71. package/build/components/grid/grid-item-resizer.js +14 -15
  72. package/build/components/grid/grid-item-resizer.js.map +1 -1
  73. package/build/components/grid/grid-visualizer.js +21 -6
  74. package/build/components/grid/grid-visualizer.js.map +1 -1
  75. package/build/components/grid/use-grid-layout-sync.js +56 -20
  76. package/build/components/grid/use-grid-layout-sync.js.map +1 -1
  77. package/build/components/height-control/index.js +1 -0
  78. package/build/components/height-control/index.js.map +1 -1
  79. package/build/components/iframe/index.js +2 -4
  80. package/build/components/iframe/index.js.map +1 -1
  81. package/build/components/image-editor/zoom-dropdown.js +11 -7
  82. package/build/components/image-editor/zoom-dropdown.js.map +1 -1
  83. package/build/components/inner-blocks/button-block-appender.js +8 -8
  84. package/build/components/inner-blocks/button-block-appender.js.map +1 -1
  85. package/build/components/inner-blocks/default-block-appender.js +7 -25
  86. package/build/components/inner-blocks/default-block-appender.js.map +1 -1
  87. package/build/components/inner-blocks/index.js +9 -11
  88. package/build/components/inner-blocks/index.js.map +1 -1
  89. package/build/components/inserter/category-tabs/index.js +29 -2
  90. package/build/components/inserter/category-tabs/index.js.map +1 -1
  91. package/build/components/inserter/library.js +4 -2
  92. package/build/components/inserter/library.js.map +1 -1
  93. package/build/components/inserter/menu.js +32 -14
  94. package/build/components/inserter/menu.js.map +1 -1
  95. package/build/components/inserter/quick-inserter.js +4 -0
  96. package/build/components/inserter/quick-inserter.js.map +1 -1
  97. package/build/components/line-height-control/index.js +3 -15
  98. package/build/components/line-height-control/index.js.map +1 -1
  99. package/build/components/link-control/search-input.js +0 -1
  100. package/build/components/link-control/search-input.js.map +1 -1
  101. package/build/components/media-placeholder/index.js +9 -4
  102. package/build/components/media-placeholder/index.js.map +1 -1
  103. package/build/components/media-replace-flow/index.js +3 -1
  104. package/build/components/media-replace-flow/index.js.map +1 -1
  105. package/build/components/media-upload/index.native.js +4 -1
  106. package/build/components/media-upload/index.native.js.map +1 -1
  107. package/build/components/multi-selection-inspector/index.js +12 -12
  108. package/build/components/multi-selection-inspector/index.js.map +1 -1
  109. package/build/components/resolution-tool/index.js +1 -0
  110. package/build/components/resolution-tool/index.js.map +1 -1
  111. package/build/components/skip-to-selected-block/index.js +4 -2
  112. package/build/components/skip-to-selected-block/index.js.map +1 -1
  113. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +8 -8
  114. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  115. package/build/components/text-alignment-control/index.js +13 -8
  116. package/build/components/text-alignment-control/index.js.map +1 -1
  117. package/build/components/text-decoration-control/index.js +13 -8
  118. package/build/components/text-decoration-control/index.js.map +1 -1
  119. package/build/components/text-transform-control/index.js +13 -8
  120. package/build/components/text-transform-control/index.js.map +1 -1
  121. package/build/components/url-input/button.js +0 -1
  122. package/build/components/url-input/button.js.map +1 -1
  123. package/build/components/url-input/index.js +1 -11
  124. package/build/components/url-input/index.js.map +1 -1
  125. package/build/components/url-popover/image-url-input-ui.js +2 -0
  126. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  127. package/build/components/url-popover/link-editor.js +0 -1
  128. package/build/components/url-popover/link-editor.js.map +1 -1
  129. package/build/components/use-block-drop-zone/index.js +42 -4
  130. package/build/components/use-block-drop-zone/index.js.map +1 -1
  131. package/build/components/use-on-block-drop/index.js +3 -6
  132. package/build/components/use-on-block-drop/index.js.map +1 -1
  133. package/build/components/use-resize-canvas/index.js +1 -3
  134. package/build/components/use-resize-canvas/index.js.map +1 -1
  135. package/build/components/use-settings/index.js +2 -1
  136. package/build/components/use-settings/index.js.map +1 -1
  137. package/build/components/writing-mode-control/index.js +13 -8
  138. package/build/components/writing-mode-control/index.js.map +1 -1
  139. package/build/hooks/background.js +19 -23
  140. package/build/hooks/background.js.map +1 -1
  141. package/build/hooks/block-bindings.js +209 -39
  142. package/build/hooks/block-bindings.js.map +1 -1
  143. package/build/hooks/block-hooks.js +1 -0
  144. package/build/hooks/block-hooks.js.map +1 -1
  145. package/build/hooks/block-style-variation.js +2 -2
  146. package/build/hooks/block-style-variation.js.map +1 -1
  147. package/build/hooks/contrast-checker.js +6 -6
  148. package/build/hooks/contrast-checker.js.map +1 -1
  149. package/build/hooks/duotone.js +3 -3
  150. package/build/hooks/duotone.js.map +1 -1
  151. package/build/hooks/index.js +7 -1
  152. package/build/hooks/index.js.map +1 -1
  153. package/build/hooks/line-height.js +0 -1
  154. package/build/hooks/line-height.js.map +1 -1
  155. package/build/hooks/spacing-visualizer.js +1 -1
  156. package/build/hooks/spacing-visualizer.js.map +1 -1
  157. package/build/hooks/use-bindings-attributes.js +4 -0
  158. package/build/hooks/use-bindings-attributes.js.map +1 -1
  159. package/build/hooks/use-zoom-out.js +1 -1
  160. package/build/hooks/use-zoom-out.js.map +1 -1
  161. package/build/hooks/utils.js +20 -0
  162. package/build/hooks/utils.js.map +1 -1
  163. package/build/index.js +7 -0
  164. package/build/index.js.map +1 -1
  165. package/build/layouts/constrained.js +1 -0
  166. package/build/layouts/constrained.js.map +1 -1
  167. package/build/layouts/flex.js +2 -0
  168. package/build/layouts/flex.js.map +1 -1
  169. package/build/layouts/grid.js +3 -0
  170. package/build/layouts/grid.js.map +1 -1
  171. package/build/private-apis.js +3 -2
  172. package/build/private-apis.js.map +1 -1
  173. package/build/store/actions.js +9 -1
  174. package/build/store/actions.js.map +1 -1
  175. package/build/store/private-selectors.js +30 -0
  176. package/build/store/private-selectors.js.map +1 -1
  177. package/build/store/reducer.js +10 -1
  178. package/build/store/reducer.js.map +1 -1
  179. package/build/store/selectors.js +4 -4
  180. package/build/store/selectors.js.map +1 -1
  181. package/build/utils/block-bindings.js +112 -0
  182. package/build/utils/block-bindings.js.map +1 -0
  183. package/build/utils/get-editor-region.js +1 -1
  184. package/build/utils/get-editor-region.js.map +1 -1
  185. package/build/utils/get-px-from-css-unit.js +1 -1
  186. package/build/utils/get-px-from-css-unit.js.map +1 -1
  187. package/build-module/autocompleters/block.js +1 -1
  188. package/build-module/autocompleters/block.js.map +1 -1
  189. package/build-module/components/block-breadcrumb/index.js +4 -2
  190. package/build-module/components/block-breadcrumb/index.js.map +1 -1
  191. package/build-module/components/block-draggable/index.js +3 -3
  192. package/build-module/components/block-draggable/index.js.map +1 -1
  193. package/build-module/components/block-list/use-block-props/index.js +2 -2
  194. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  195. package/build-module/components/block-list/use-block-props/use-block-refs.js +24 -34
  196. package/build-module/components/block-list/use-block-props/use-block-refs.js.map +1 -1
  197. package/build-module/components/block-list/use-in-between-inserter.js +11 -4
  198. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  199. package/build-module/components/block-mover/index.js +1 -2
  200. package/build-module/components/block-mover/index.js.map +1 -1
  201. package/build-module/components/block-popover/cover.js +1 -1
  202. package/build-module/components/block-popover/cover.js.map +1 -1
  203. package/build-module/components/block-popover/inbetween.js +1 -1
  204. package/build-module/components/block-popover/inbetween.js.map +1 -1
  205. package/build-module/components/block-popover/index.js +1 -1
  206. package/build-module/components/block-popover/index.js.map +1 -1
  207. package/build-module/components/block-settings-menu/block-mode-toggle.js +29 -34
  208. package/build-module/components/block-settings-menu/block-mode-toggle.js.map +1 -1
  209. package/build-module/components/block-tools/block-selection-button.js +1 -2
  210. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  211. package/build-module/components/block-tools/index.js +1 -1
  212. package/build-module/components/block-tools/index.js.map +1 -1
  213. package/build-module/components/block-tools/insertion-point.js +14 -3
  214. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  215. package/build-module/components/block-tools/use-block-toolbar-popover-props.js +1 -1
  216. package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  217. package/build-module/components/block-tools/use-show-block-tools.js +2 -1
  218. package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
  219. package/build-module/components/block-tools/zoom-out-mode-inserters.js +23 -20
  220. package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  221. package/build-module/components/block-tools/zoom-out-toolbar.js +0 -1
  222. package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -1
  223. package/build-module/components/border-radius-control/index.js +1 -0
  224. package/build-module/components/border-radius-control/index.js.map +1 -1
  225. package/build-module/components/child-layout-control/index.js +3 -1
  226. package/build-module/components/child-layout-control/index.js.map +1 -1
  227. package/build-module/components/convert-to-group-buttons/index.js +1 -1
  228. package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
  229. package/build-module/components/date-format-picker/index.js +2 -0
  230. package/build-module/components/date-format-picker/index.js.map +1 -1
  231. package/build-module/components/dimensions-tool/scale-tool.js +1 -0
  232. package/build-module/components/dimensions-tool/scale-tool.js.map +1 -1
  233. package/build-module/components/font-appearance-control/index.js +3 -0
  234. package/build-module/components/font-appearance-control/index.js.map +1 -1
  235. package/build-module/components/font-family/index.js +14 -0
  236. package/build-module/components/font-family/index.js.map +1 -1
  237. package/build-module/components/global-styles/background-panel.js +156 -80
  238. package/build-module/components/global-styles/background-panel.js.map +1 -1
  239. package/build-module/components/global-styles/get-global-styles-changes.js +3 -1
  240. package/build-module/components/global-styles/get-global-styles-changes.js.map +1 -1
  241. package/build-module/components/global-styles/hooks.js +0 -6
  242. package/build-module/components/global-styles/hooks.js.map +1 -1
  243. package/build-module/components/global-styles/image-settings-panel.js +1 -0
  244. package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
  245. package/build-module/components/global-styles/index.js +1 -1
  246. package/build-module/components/global-styles/index.js.map +1 -1
  247. package/build-module/components/global-styles/typography-panel.js +0 -1
  248. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  249. package/build-module/components/global-styles/use-global-styles-output.js +61 -42
  250. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  251. package/build-module/components/global-styles/utils.js +77 -0
  252. package/build-module/components/global-styles/utils.js.map +1 -1
  253. package/build-module/components/grid/grid-item-movers.js +30 -26
  254. package/build-module/components/grid/grid-item-movers.js.map +1 -1
  255. package/build-module/components/grid/grid-item-resizer.js +14 -15
  256. package/build-module/components/grid/grid-item-resizer.js.map +1 -1
  257. package/build-module/components/grid/grid-visualizer.js +21 -6
  258. package/build-module/components/grid/grid-visualizer.js.map +1 -1
  259. package/build-module/components/grid/use-grid-layout-sync.js +56 -20
  260. package/build-module/components/grid/use-grid-layout-sync.js.map +1 -1
  261. package/build-module/components/height-control/index.js +1 -0
  262. package/build-module/components/height-control/index.js.map +1 -1
  263. package/build-module/components/iframe/index.js +2 -4
  264. package/build-module/components/iframe/index.js.map +1 -1
  265. package/build-module/components/image-editor/zoom-dropdown.js +12 -8
  266. package/build-module/components/image-editor/zoom-dropdown.js.map +1 -1
  267. package/build-module/components/inner-blocks/button-block-appender.js +7 -6
  268. package/build-module/components/inner-blocks/button-block-appender.js.map +1 -1
  269. package/build-module/components/inner-blocks/default-block-appender.js +6 -23
  270. package/build-module/components/inner-blocks/default-block-appender.js.map +1 -1
  271. package/build-module/components/inner-blocks/index.js +9 -11
  272. package/build-module/components/inner-blocks/index.js.map +1 -1
  273. package/build-module/components/inserter/category-tabs/index.js +30 -3
  274. package/build-module/components/inserter/category-tabs/index.js.map +1 -1
  275. package/build-module/components/inserter/library.js +4 -2
  276. package/build-module/components/inserter/library.js.map +1 -1
  277. package/build-module/components/inserter/menu.js +32 -14
  278. package/build-module/components/inserter/menu.js.map +1 -1
  279. package/build-module/components/inserter/quick-inserter.js +5 -1
  280. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  281. package/build-module/components/line-height-control/index.js +3 -14
  282. package/build-module/components/line-height-control/index.js.map +1 -1
  283. package/build-module/components/link-control/search-input.js +0 -1
  284. package/build-module/components/link-control/search-input.js.map +1 -1
  285. package/build-module/components/media-placeholder/index.js +9 -4
  286. package/build-module/components/media-placeholder/index.js.map +1 -1
  287. package/build-module/components/media-replace-flow/index.js +3 -1
  288. package/build-module/components/media-replace-flow/index.js.map +1 -1
  289. package/build-module/components/media-upload/index.native.js +4 -1
  290. package/build-module/components/media-upload/index.native.js.map +1 -1
  291. package/build-module/components/multi-selection-inspector/index.js +12 -12
  292. package/build-module/components/multi-selection-inspector/index.js.map +1 -1
  293. package/build-module/components/resolution-tool/index.js +1 -0
  294. package/build-module/components/resolution-tool/index.js.map +1 -1
  295. package/build-module/components/skip-to-selected-block/index.js +5 -3
  296. package/build-module/components/skip-to-selected-block/index.js.map +1 -1
  297. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +8 -8
  298. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  299. package/build-module/components/text-alignment-control/index.js +13 -8
  300. package/build-module/components/text-alignment-control/index.js.map +1 -1
  301. package/build-module/components/text-decoration-control/index.js +13 -8
  302. package/build-module/components/text-decoration-control/index.js.map +1 -1
  303. package/build-module/components/text-transform-control/index.js +13 -8
  304. package/build-module/components/text-transform-control/index.js.map +1 -1
  305. package/build-module/components/url-input/button.js +0 -1
  306. package/build-module/components/url-input/button.js.map +1 -1
  307. package/build-module/components/url-input/index.js +1 -11
  308. package/build-module/components/url-input/index.js.map +1 -1
  309. package/build-module/components/url-popover/image-url-input-ui.js +2 -0
  310. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  311. package/build-module/components/url-popover/link-editor.js +0 -1
  312. package/build-module/components/url-popover/link-editor.js.map +1 -1
  313. package/build-module/components/use-block-drop-zone/index.js +42 -4
  314. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  315. package/build-module/components/use-on-block-drop/index.js +3 -6
  316. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  317. package/build-module/components/use-resize-canvas/index.js +1 -3
  318. package/build-module/components/use-resize-canvas/index.js.map +1 -1
  319. package/build-module/components/use-settings/index.js +2 -1
  320. package/build-module/components/use-settings/index.js.map +1 -1
  321. package/build-module/components/writing-mode-control/index.js +13 -8
  322. package/build-module/components/writing-mode-control/index.js.map +1 -1
  323. package/build-module/hooks/background.js +19 -23
  324. package/build-module/hooks/background.js.map +1 -1
  325. package/build-module/hooks/block-bindings.js +214 -43
  326. package/build-module/hooks/block-bindings.js.map +1 -1
  327. package/build-module/hooks/block-hooks.js +1 -0
  328. package/build-module/hooks/block-hooks.js.map +1 -1
  329. package/build-module/hooks/block-style-variation.js +3 -3
  330. package/build-module/hooks/block-style-variation.js.map +1 -1
  331. package/build-module/hooks/contrast-checker.js +7 -7
  332. package/build-module/hooks/contrast-checker.js.map +1 -1
  333. package/build-module/hooks/duotone.js +4 -4
  334. package/build-module/hooks/duotone.js.map +1 -1
  335. package/build-module/hooks/index.js +2 -1
  336. package/build-module/hooks/index.js.map +1 -1
  337. package/build-module/hooks/line-height.js +0 -1
  338. package/build-module/hooks/line-height.js.map +1 -1
  339. package/build-module/hooks/spacing-visualizer.js +1 -1
  340. package/build-module/hooks/spacing-visualizer.js.map +1 -1
  341. package/build-module/hooks/use-bindings-attributes.js +3 -0
  342. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  343. package/build-module/hooks/use-zoom-out.js +1 -1
  344. package/build-module/hooks/use-zoom-out.js.map +1 -1
  345. package/build-module/hooks/utils.js +19 -0
  346. package/build-module/hooks/utils.js.map +1 -1
  347. package/build-module/index.js +1 -1
  348. package/build-module/index.js.map +1 -1
  349. package/build-module/layouts/constrained.js +1 -0
  350. package/build-module/layouts/constrained.js.map +1 -1
  351. package/build-module/layouts/flex.js +2 -0
  352. package/build-module/layouts/flex.js.map +1 -1
  353. package/build-module/layouts/grid.js +3 -0
  354. package/build-module/layouts/grid.js.map +1 -1
  355. package/build-module/private-apis.js +4 -3
  356. package/build-module/private-apis.js.map +1 -1
  357. package/build-module/store/actions.js +9 -1
  358. package/build-module/store/actions.js.map +1 -1
  359. package/build-module/store/private-selectors.js +27 -0
  360. package/build-module/store/private-selectors.js.map +1 -1
  361. package/build-module/store/reducer.js +9 -1
  362. package/build-module/store/reducer.js.map +1 -1
  363. package/build-module/store/selectors.js +4 -4
  364. package/build-module/store/selectors.js.map +1 -1
  365. package/build-module/utils/block-bindings.js +105 -0
  366. package/build-module/utils/block-bindings.js.map +1 -0
  367. package/build-module/utils/get-editor-region.js +1 -1
  368. package/build-module/utils/get-editor-region.js.map +1 -1
  369. package/build-module/utils/get-px-from-css-unit.js +1 -1
  370. package/build-module/utils/get-px-from-css-unit.js.map +1 -1
  371. package/build-style/content-rtl.css +12 -26
  372. package/build-style/content.css +12 -26
  373. package/build-style/default-editor-styles-rtl.css +5 -2
  374. package/build-style/default-editor-styles.css +5 -2
  375. package/build-style/style-rtl.css +123 -83
  376. package/build-style/style.css +123 -83
  377. package/package.json +32 -32
  378. package/src/autocompleters/block.js +2 -1
  379. package/src/autocompleters/style.scss +4 -0
  380. package/src/components/block-breadcrumb/index.js +4 -2
  381. package/src/components/block-canvas/style.scss +1 -0
  382. package/src/components/block-draggable/index.js +3 -3
  383. package/src/components/block-list/content.scss +5 -13
  384. package/src/components/block-list/use-block-props/index.js +2 -2
  385. package/src/components/block-list/use-block-props/use-block-refs.js +27 -43
  386. package/src/components/block-list/use-in-between-inserter.js +17 -5
  387. package/src/components/block-mover/index.js +5 -2
  388. package/src/components/block-popover/cover.js +1 -1
  389. package/src/components/block-popover/inbetween.js +1 -1
  390. package/src/components/block-popover/index.js +1 -1
  391. package/src/components/block-settings-menu/block-mode-toggle.js +28 -31
  392. package/src/components/block-settings-menu/test/block-mode-toggle.js +26 -23
  393. package/src/components/block-tools/block-selection-button.js +1 -2
  394. package/src/components/block-tools/index.js +5 -6
  395. package/src/components/block-tools/insertion-point.js +11 -0
  396. package/src/components/block-tools/style.scss +1 -1
  397. package/src/components/block-tools/use-block-toolbar-popover-props.js +1 -1
  398. package/src/components/block-tools/use-show-block-tools.js +4 -1
  399. package/src/components/block-tools/zoom-out-mode-inserters.js +21 -19
  400. package/src/components/block-tools/zoom-out-toolbar.js +0 -1
  401. package/src/components/block-variation-transforms/style.scss +1 -1
  402. package/src/components/border-radius-control/index.js +1 -0
  403. package/src/components/border-radius-control/style.scss +0 -10
  404. package/src/components/button-block-appender/content.scss +1 -1
  405. package/src/components/child-layout-control/index.js +2 -0
  406. package/src/components/color-palette/test/__snapshots__/control.js.snap +2 -2
  407. package/src/components/colors-gradients/test/control.js +3 -2
  408. package/src/components/convert-to-group-buttons/index.js +1 -1
  409. package/src/components/date-format-picker/index.js +2 -0
  410. package/src/components/dimensions-tool/scale-tool.js +1 -0
  411. package/src/components/font-appearance-control/index.js +3 -0
  412. package/src/components/font-family/README.md +17 -0
  413. package/src/components/font-family/index.js +19 -0
  414. package/src/components/font-family/stories/index.story.js +54 -0
  415. package/src/components/global-styles/background-panel.js +180 -93
  416. package/src/components/global-styles/get-global-styles-changes.js +4 -1
  417. package/src/components/global-styles/hooks.js +0 -5
  418. package/src/components/global-styles/image-settings-panel.js +1 -0
  419. package/src/components/global-styles/index.js +0 -1
  420. package/src/components/global-styles/style.scss +13 -12
  421. package/src/components/global-styles/test/use-global-styles-output.js +68 -7
  422. package/src/components/global-styles/test/utils.js +120 -0
  423. package/src/components/global-styles/typography-panel.js +0 -1
  424. package/src/components/global-styles/use-global-styles-output.js +71 -53
  425. package/src/components/global-styles/utils.js +90 -0
  426. package/src/components/grid/grid-item-movers.js +46 -44
  427. package/src/components/grid/grid-item-resizer.js +11 -17
  428. package/src/components/grid/grid-visualizer.js +23 -8
  429. package/src/components/grid/style.scss +60 -10
  430. package/src/components/grid/use-grid-layout-sync.js +68 -14
  431. package/src/components/height-control/index.js +1 -0
  432. package/src/components/iframe/content.scss +2 -2
  433. package/src/components/iframe/index.js +1 -3
  434. package/src/components/image-editor/zoom-dropdown.js +17 -9
  435. package/src/components/inner-blocks/button-block-appender.js +5 -7
  436. package/src/components/inner-blocks/default-block-appender.js +4 -23
  437. package/src/components/inner-blocks/index.js +10 -9
  438. package/src/components/inserter/category-tabs/index.js +35 -2
  439. package/src/components/inserter/library.js +2 -0
  440. package/src/components/inserter/menu.js +34 -29
  441. package/src/components/inserter/quick-inserter.js +4 -1
  442. package/src/components/inserter/style.scss +17 -12
  443. package/src/components/inserter-list-item/style.scss +1 -0
  444. package/src/components/inspector-controls/README.md +5 -0
  445. package/src/components/line-height-control/README.md +4 -5
  446. package/src/components/line-height-control/index.js +4 -21
  447. package/src/components/line-height-control/stories/index.story.js +0 -1
  448. package/src/components/line-height-control/test/index.js +1 -7
  449. package/src/components/link-control/search-input.js +0 -1
  450. package/src/components/link-control/style.scss +1 -1
  451. package/src/components/media-placeholder/index.js +12 -7
  452. package/src/components/media-replace-flow/README.md +7 -0
  453. package/src/components/media-replace-flow/index.js +3 -1
  454. package/src/components/media-upload/README.md +2 -0
  455. package/src/components/media-upload/index.native.js +2 -0
  456. package/src/components/multi-selection-inspector/index.js +8 -9
  457. package/src/components/resolution-tool/index.js +1 -0
  458. package/src/components/responsive-block-control/README.md +1 -0
  459. package/src/components/responsive-block-control/test/index.js +6 -1
  460. package/src/components/skip-to-selected-block/index.js +5 -3
  461. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +11 -10
  462. package/src/components/spacing-sizes-control/style.scss +16 -16
  463. package/src/components/tabbed-sidebar/style.scss +1 -19
  464. package/src/components/text-alignment-control/index.js +20 -8
  465. package/src/components/text-decoration-control/index.js +20 -8
  466. package/src/components/text-decoration-control/stories/index.story.js +0 -4
  467. package/src/components/text-transform-control/index.js +20 -8
  468. package/src/components/text-transform-control/stories/index.story.js +0 -4
  469. package/src/components/url-input/README.md +0 -5
  470. package/src/components/url-input/button.js +0 -1
  471. package/src/components/url-input/index.js +1 -15
  472. package/src/components/url-input/style.scss +2 -2
  473. package/src/components/url-popover/image-url-input-ui.js +2 -0
  474. package/src/components/url-popover/link-editor.js +0 -1
  475. package/src/components/use-block-drop-zone/index.js +86 -16
  476. package/src/components/use-on-block-drop/index.js +1 -9
  477. package/src/components/use-resize-canvas/index.js +1 -3
  478. package/src/components/use-settings/index.js +2 -1
  479. package/src/components/writing-mode-control/index.js +20 -8
  480. package/src/hooks/background.js +21 -27
  481. package/src/hooks/block-bindings.js +248 -54
  482. package/src/hooks/block-bindings.scss +13 -2
  483. package/src/hooks/block-hooks.js +1 -0
  484. package/src/hooks/block-hooks.scss +1 -0
  485. package/src/hooks/block-style-variation.js +3 -3
  486. package/src/hooks/contrast-checker.js +7 -7
  487. package/src/hooks/duotone.js +4 -4
  488. package/src/hooks/index.js +2 -1
  489. package/src/hooks/line-height.js +0 -1
  490. package/src/hooks/spacing-visualizer.js +1 -1
  491. package/src/hooks/test/background.js +60 -0
  492. package/src/hooks/use-bindings-attributes.js +4 -0
  493. package/src/hooks/use-editor-wrapper-styles.native.scss +1 -0
  494. package/src/hooks/use-zoom-out.js +1 -1
  495. package/src/hooks/utils.js +14 -1
  496. package/src/index.js +1 -0
  497. package/src/layouts/constrained.js +1 -0
  498. package/src/layouts/flex.js +2 -0
  499. package/src/layouts/grid.js +3 -0
  500. package/src/private-apis.js +3 -2
  501. package/src/store/actions.js +13 -5
  502. package/src/store/private-selectors.js +36 -0
  503. package/src/store/reducer.js +7 -0
  504. package/src/store/selectors.js +4 -4
  505. package/src/store/test/private-selectors.js +89 -0
  506. package/src/style.scss +1 -2
  507. package/src/utils/block-bindings.js +98 -0
  508. package/src/utils/get-editor-region.js +1 -1
  509. package/src/utils/get-px-from-css-unit.js +1 -1
  510. package/src/utils/test/transform-styles.js +49 -0
  511. package/tsconfig.tsbuildinfo +1 -1
  512. package/build/components/global-styles/theme-file-uri-utils.js +0 -80
  513. package/build/components/global-styles/theme-file-uri-utils.js.map +0 -1
  514. package/build/components/inner-blocks/with-client-id.js +0 -28
  515. package/build/components/inner-blocks/with-client-id.js.map +0 -1
  516. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +0 -30
  517. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +0 -1
  518. package/build/components/segmented-text-control/index.js +0 -63
  519. package/build/components/segmented-text-control/index.js.map +0 -1
  520. package/build-module/components/global-styles/theme-file-uri-utils.js +0 -73
  521. package/build-module/components/global-styles/theme-file-uri-utils.js.map +0 -1
  522. package/build-module/components/inner-blocks/with-client-id.js +0 -21
  523. package/build-module/components/inner-blocks/with-client-id.js.map +0 -1
  524. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +0 -23
  525. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +0 -1
  526. package/build-module/components/segmented-text-control/index.js +0 -58
  527. package/build-module/components/segmented-text-control/index.js.map +0 -1
  528. package/src/components/global-styles/test/theme-file-uri-utils.js +0 -66
  529. package/src/components/global-styles/theme-file-uri-utils.js +0 -77
  530. package/src/components/inner-blocks/with-client-id.js +0 -19
  531. package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +0 -25
  532. package/src/components/segmented-text-control/index.js +0 -63
  533. package/src/components/segmented-text-control/style.scss +0 -15
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useBlockBindingsUtils = useBlockBindingsUtils;
7
+ var _data = require("@wordpress/data");
8
+ var _store = require("../store");
9
+ var _blockEdit = require("../components/block-edit");
10
+ /**
11
+ * WordPress dependencies
12
+ */
13
+
14
+ /**
15
+ * Internal dependencies
16
+ */
17
+
18
+ function useBlockBindingsUtils() {
19
+ const {
20
+ clientId
21
+ } = (0, _blockEdit.useBlockEditContext)();
22
+ const {
23
+ updateBlockAttributes
24
+ } = (0, _data.useDispatch)(_store.store);
25
+ const {
26
+ getBlockAttributes
27
+ } = (0, _data.useSelect)(_store.store);
28
+
29
+ /**
30
+ * Updates the value of the bindings connected to block attributes.
31
+ * It removes the binding when the new value is `undefined`.
32
+ *
33
+ * @param {Object} bindings Bindings including the attributes to update and the new object.
34
+ * @param {string} bindings.source The source name to connect to.
35
+ * @param {Object} [bindings.args] Object containing the arguments needed by the source.
36
+ *
37
+ * @example
38
+ * ```js
39
+ * import { useBlockBindingsUtils } from '@wordpress/block-editor'
40
+ *
41
+ * const { updateBlockBindings } = useBlockBindingsUtils();
42
+ * updateBlockBindings( {
43
+ * url: {
44
+ * source: 'core/post-meta',
45
+ * args: {
46
+ * key: 'url_custom_field',
47
+ * },
48
+ * },
49
+ * alt: {
50
+ * source: 'core/post-meta',
51
+ * args: {
52
+ * key: 'text_custom_field',
53
+ * },
54
+ * }
55
+ * } );
56
+ * ```
57
+ */
58
+ const updateBlockBindings = bindings => {
59
+ const {
60
+ metadata
61
+ } = getBlockAttributes(clientId);
62
+ const newBindings = {
63
+ ...metadata?.bindings
64
+ };
65
+ Object.entries(bindings).forEach(([attribute, binding]) => {
66
+ if (!binding && newBindings[attribute]) {
67
+ delete newBindings[attribute];
68
+ return;
69
+ }
70
+ newBindings[attribute] = binding;
71
+ });
72
+ const newMetadata = {
73
+ ...metadata,
74
+ bindings: newBindings
75
+ };
76
+ if (Object.keys(newMetadata.bindings).length === 0) {
77
+ delete newMetadata.bindings;
78
+ }
79
+ updateBlockAttributes(clientId, {
80
+ metadata: Object.keys(newMetadata).length === 0 ? undefined : newMetadata
81
+ });
82
+ };
83
+
84
+ /**
85
+ * Removes the bindings property of the `metadata` attribute.
86
+ *
87
+ * @example
88
+ * ```js
89
+ * import { useBlockBindingsUtils } from '@wordpress/block-editor'
90
+ *
91
+ * const { removeAllBlockBindings } = useBlockBindingsUtils();
92
+ * removeAllBlockBindings();
93
+ * ```
94
+ */
95
+ const removeAllBlockBindings = () => {
96
+ const {
97
+ metadata
98
+ } = getBlockAttributes(clientId);
99
+ const newMetadata = {
100
+ ...metadata
101
+ };
102
+ delete newMetadata.bindings;
103
+ updateBlockAttributes(clientId, {
104
+ metadata: Object.keys(newMetadata).length === 0 ? undefined : newMetadata
105
+ });
106
+ };
107
+ return {
108
+ updateBlockBindings,
109
+ removeAllBlockBindings
110
+ };
111
+ }
112
+ //# sourceMappingURL=block-bindings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_data","require","_store","_blockEdit","useBlockBindingsUtils","clientId","useBlockEditContext","updateBlockAttributes","useDispatch","blockEditorStore","getBlockAttributes","useSelect","updateBlockBindings","bindings","metadata","newBindings","Object","entries","forEach","attribute","binding","newMetadata","keys","length","undefined","removeAllBlockBindings"],"sources":["@wordpress/block-editor/src/utils/block-bindings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { useBlockEditContext } from '../components/block-edit';\n\nexport function useBlockBindingsUtils() {\n\tconst { clientId } = useBlockEditContext();\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst { getBlockAttributes } = useSelect( blockEditorStore );\n\n\t/**\n\t * Updates the value of the bindings connected to block attributes.\n\t * It removes the binding when the new value is `undefined`.\n\t *\n\t * @param {Object} bindings Bindings including the attributes to update and the new object.\n\t * @param {string} bindings.source The source name to connect to.\n\t * @param {Object} [bindings.args] Object containing the arguments needed by the source.\n\t *\n\t * @example\n\t * ```js\n\t * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n\t *\n\t * const { updateBlockBindings } = useBlockBindingsUtils();\n\t * updateBlockBindings( {\n\t * url: {\n\t * source: 'core/post-meta',\n\t * args: {\n\t * key: 'url_custom_field',\n\t * },\n\t * \t },\n\t * alt: {\n\t * source: 'core/post-meta',\n\t * args: {\n\t * key: 'text_custom_field',\n\t * },\n\t * \t }\n\t * } );\n\t * ```\n\t */\n\tconst updateBlockBindings = ( bindings ) => {\n\t\tconst { metadata } = getBlockAttributes( clientId );\n\t\tconst newBindings = { ...metadata?.bindings };\n\t\tObject.entries( bindings ).forEach( ( [ attribute, binding ] ) => {\n\t\t\tif ( ! binding && newBindings[ attribute ] ) {\n\t\t\t\tdelete newBindings[ attribute ];\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tnewBindings[ attribute ] = binding;\n\t\t} );\n\n\t\tconst newMetadata = {\n\t\t\t...metadata,\n\t\t\tbindings: newBindings,\n\t\t};\n\n\t\tif ( Object.keys( newMetadata.bindings ).length === 0 ) {\n\t\t\tdelete newMetadata.bindings;\n\t\t}\n\n\t\tupdateBlockAttributes( clientId, {\n\t\t\tmetadata:\n\t\t\t\tObject.keys( newMetadata ).length === 0\n\t\t\t\t\t? undefined\n\t\t\t\t\t: newMetadata,\n\t\t} );\n\t};\n\n\t/**\n\t * Removes the bindings property of the `metadata` attribute.\n\t *\n\t * @example\n\t * ```js\n\t * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n\t *\n\t * const { removeAllBlockBindings } = useBlockBindingsUtils();\n\t * removeAllBlockBindings();\n\t * ```\n\t */\n\tconst removeAllBlockBindings = () => {\n\t\tconst { metadata } = getBlockAttributes( clientId );\n\t\tconst newMetadata = { ...metadata };\n\t\tdelete newMetadata.bindings;\n\t\tupdateBlockAttributes( clientId, {\n\t\t\tmetadata:\n\t\t\t\tObject.keys( newMetadata ).length === 0\n\t\t\t\t\t? undefined\n\t\t\t\t\t: newMetadata,\n\t\t} );\n\t};\n\n\treturn { updateBlockBindings, removeAllBlockBindings };\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIO,SAASG,qBAAqBA,CAAA,EAAG;EACvC,MAAM;IAAEC;EAAS,CAAC,GAAG,IAAAC,8BAAmB,EAAC,CAAC;EAC1C,MAAM;IAAEC;EAAsB,CAAC,GAAG,IAAAC,iBAAW,EAAEC,YAAiB,CAAC;EACjE,MAAM;IAAEC;EAAmB,CAAC,GAAG,IAAAC,eAAS,EAAEF,YAAiB,CAAC;;EAE5D;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMG,mBAAmB,GAAKC,QAAQ,IAAM;IAC3C,MAAM;MAAEC;IAAS,CAAC,GAAGJ,kBAAkB,CAAEL,QAAS,CAAC;IACnD,MAAMU,WAAW,GAAG;MAAE,GAAGD,QAAQ,EAAED;IAAS,CAAC;IAC7CG,MAAM,CAACC,OAAO,CAAEJ,QAAS,CAAC,CAACK,OAAO,CAAE,CAAE,CAAEC,SAAS,EAAEC,OAAO,CAAE,KAAM;MACjE,IAAK,CAAEA,OAAO,IAAIL,WAAW,CAAEI,SAAS,CAAE,EAAG;QAC5C,OAAOJ,WAAW,CAAEI,SAAS,CAAE;QAC/B;MACD;MACAJ,WAAW,CAAEI,SAAS,CAAE,GAAGC,OAAO;IACnC,CAAE,CAAC;IAEH,MAAMC,WAAW,GAAG;MACnB,GAAGP,QAAQ;MACXD,QAAQ,EAAEE;IACX,CAAC;IAED,IAAKC,MAAM,CAACM,IAAI,CAAED,WAAW,CAACR,QAAS,CAAC,CAACU,MAAM,KAAK,CAAC,EAAG;MACvD,OAAOF,WAAW,CAACR,QAAQ;IAC5B;IAEAN,qBAAqB,CAAEF,QAAQ,EAAE;MAChCS,QAAQ,EACPE,MAAM,CAACM,IAAI,CAAED,WAAY,CAAC,CAACE,MAAM,KAAK,CAAC,GACpCC,SAAS,GACTH;IACL,CAAE,CAAC;EACJ,CAAC;;EAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMI,sBAAsB,GAAGA,CAAA,KAAM;IACpC,MAAM;MAAEX;IAAS,CAAC,GAAGJ,kBAAkB,CAAEL,QAAS,CAAC;IACnD,MAAMgB,WAAW,GAAG;MAAE,GAAGP;IAAS,CAAC;IACnC,OAAOO,WAAW,CAACR,QAAQ;IAC3BN,qBAAqB,CAAEF,QAAQ,EAAE;MAChCS,QAAQ,EACPE,MAAM,CAACM,IAAI,CAAED,WAAY,CAAC,CAACE,MAAM,KAAK,CAAC,GACpCC,SAAS,GACTH;IACL,CAAE,CAAC;EACJ,CAAC;EAED,OAAO;IAAET,mBAAmB;IAAEa;EAAuB,CAAC;AACvD","ignoreList":[]}
@@ -25,7 +25,7 @@ function getEditorRegion(editor) {
25
25
  return iframeDocument === editor.ownerDocument;
26
26
  })) !== null && _Array$from$find !== void 0 ? _Array$from$find : editor;
27
27
 
28
- // The region is provivided by the editor, not the block-editor.
28
+ // The region is provided by the editor, not the block-editor.
29
29
  // We should send focus to the region if one is available to reuse the
30
30
  // same interface for navigating landmarks. If no region is available,
31
31
  // use the canvas instead.
@@ -1 +1 @@
1
- {"version":3,"names":["getEditorRegion","editor","_Array$from$find","_editorCanvas$closest","editorCanvas","Array","from","document","querySelectorAll","values","find","iframe","iframeDocument","contentDocument","contentWindow","ownerDocument","closest"],"sources":["@wordpress/block-editor/src/utils/get-editor-region.js"],"sourcesContent":["/**\n * Gets the editor region for a given editor canvas element or\n * returns the passed element if no region is found\n *\n * @param { Object } editor The editor canvas element.\n * @return { Object } The editor region or given editor element\n */\nexport default function getEditorRegion( editor ) {\n\tif ( ! editor ) {\n\t\treturn null;\n\t}\n\n\t// If there are multiple editors, we need to find the iframe that contains our contentRef to make sure\n\t// we're focusing the region that contains this editor.\n\tconst editorCanvas =\n\t\tArray.from(\n\t\t\tdocument.querySelectorAll( 'iframe[name=\"editor-canvas\"]' ).values()\n\t\t).find( ( iframe ) => {\n\t\t\t// Find the iframe that contains our contentRef\n\t\t\tconst iframeDocument =\n\t\t\t\tiframe.contentDocument || iframe.contentWindow.document;\n\n\t\t\treturn iframeDocument === editor.ownerDocument;\n\t\t} ) ?? editor;\n\n\t// The region is provivided by the editor, not the block-editor.\n\t// We should send focus to the region if one is available to reuse the\n\t// same interface for navigating landmarks. If no region is available,\n\t// use the canvas instead.\n\treturn editorCanvas?.closest( '[role=\"region\"]' ) ?? editorCanvas;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,eAAeA,CAAEC,MAAM,EAAG;EAAA,IAAAC,gBAAA,EAAAC,qBAAA;EACjD,IAAK,CAAEF,MAAM,EAAG;IACf,OAAO,IAAI;EACZ;;EAEA;EACA;EACA,MAAMG,YAAY,IAAAF,gBAAA,GACjBG,KAAK,CAACC,IAAI,CACTC,QAAQ,CAACC,gBAAgB,CAAE,8BAA+B,CAAC,CAACC,MAAM,CAAC,CACpE,CAAC,CAACC,IAAI,CAAIC,MAAM,IAAM;IACrB;IACA,MAAMC,cAAc,GACnBD,MAAM,CAACE,eAAe,IAAIF,MAAM,CAACG,aAAa,CAACP,QAAQ;IAExD,OAAOK,cAAc,KAAKX,MAAM,CAACc,aAAa;EAC/C,CAAE,CAAC,cAAAb,gBAAA,cAAAA,gBAAA,GAAID,MAAM;;EAEd;EACA;EACA;EACA;EACA,QAAAE,qBAAA,GAAOC,YAAY,EAAEY,OAAO,CAAE,iBAAkB,CAAC,cAAAb,qBAAA,cAAAA,qBAAA,GAAIC,YAAY;AAClE","ignoreList":[]}
1
+ {"version":3,"names":["getEditorRegion","editor","_Array$from$find","_editorCanvas$closest","editorCanvas","Array","from","document","querySelectorAll","values","find","iframe","iframeDocument","contentDocument","contentWindow","ownerDocument","closest"],"sources":["@wordpress/block-editor/src/utils/get-editor-region.js"],"sourcesContent":["/**\n * Gets the editor region for a given editor canvas element or\n * returns the passed element if no region is found\n *\n * @param { Object } editor The editor canvas element.\n * @return { Object } The editor region or given editor element\n */\nexport default function getEditorRegion( editor ) {\n\tif ( ! editor ) {\n\t\treturn null;\n\t}\n\n\t// If there are multiple editors, we need to find the iframe that contains our contentRef to make sure\n\t// we're focusing the region that contains this editor.\n\tconst editorCanvas =\n\t\tArray.from(\n\t\t\tdocument.querySelectorAll( 'iframe[name=\"editor-canvas\"]' ).values()\n\t\t).find( ( iframe ) => {\n\t\t\t// Find the iframe that contains our contentRef\n\t\t\tconst iframeDocument =\n\t\t\t\tiframe.contentDocument || iframe.contentWindow.document;\n\n\t\t\treturn iframeDocument === editor.ownerDocument;\n\t\t} ) ?? editor;\n\n\t// The region is provided by the editor, not the block-editor.\n\t// We should send focus to the region if one is available to reuse the\n\t// same interface for navigating landmarks. If no region is available,\n\t// use the canvas instead.\n\treturn editorCanvas?.closest( '[role=\"region\"]' ) ?? editorCanvas;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,eAAeA,CAAEC,MAAM,EAAG;EAAA,IAAAC,gBAAA,EAAAC,qBAAA;EACjD,IAAK,CAAEF,MAAM,EAAG;IACf,OAAO,IAAI;EACZ;;EAEA;EACA;EACA,MAAMG,YAAY,IAAAF,gBAAA,GACjBG,KAAK,CAACC,IAAI,CACTC,QAAQ,CAACC,gBAAgB,CAAE,8BAA+B,CAAC,CAACC,MAAM,CAAC,CACpE,CAAC,CAACC,IAAI,CAAIC,MAAM,IAAM;IACrB;IACA,MAAMC,cAAc,GACnBD,MAAM,CAACE,eAAe,IAAIF,MAAM,CAACG,aAAa,CAACP,QAAQ;IAExD,OAAOK,cAAc,KAAKX,MAAM,CAACc,aAAa;EAC/C,CAAE,CAAC,cAAAb,gBAAA,cAAAA,gBAAA,GAAID,MAAM;;EAEd;EACA;EACA;EACA;EACA,QAAAE,qBAAA,GAAOC,YAAY,EAAEY,OAAO,CAAE,iBAAkB,CAAC,cAAAb,qBAAA,cAAAA,qBAAA,GAAIC,YAAY;AAClE","ignoreList":[]}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  /**
8
- * This function was accidentially exposed for mobile/native usage.
8
+ * This function was accidentally exposed for mobile/native usage.
9
9
  *
10
10
  * @deprecated
11
11
  *
@@ -1 +1 @@
1
- {"version":3,"names":["_default","exports","default"],"sources":["@wordpress/block-editor/src/utils/get-px-from-css-unit.js"],"sourcesContent":["/**\n * This function was accidentially exposed for mobile/native usage.\n *\n * @deprecated\n *\n * @return {string} Empty string.\n */\nexport default () => '';\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AANA,IAAAA,QAAA,GAOeA,CAAA,KAAM,EAAE;AAAAC,OAAA,CAAAC,OAAA,GAAAF,QAAA","ignoreList":[]}
1
+ {"version":3,"names":["_default","exports","default"],"sources":["@wordpress/block-editor/src/utils/get-px-from-css-unit.js"],"sourcesContent":["/**\n * This function was accidentally exposed for mobile/native usage.\n *\n * @deprecated\n *\n * @return {string} Empty string.\n */\nexport default () => '';\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AANA,IAAAA,QAAA,GAOeA,CAAA,KAAM,EAAE;AAAAC,OAAA,CAAAC,OAAA,GAAAF,QAAA","ignoreList":[]}
@@ -52,7 +52,7 @@ function createBlockCompleter() {
52
52
  prioritizedBlocks: getBlockListSettings(_rootClientId)?.prioritizedInserterBlocks
53
53
  };
54
54
  }, []);
55
- const [items, categories, collections] = useBlockTypesState(rootClientId, noop);
55
+ const [items, categories, collections] = useBlockTypesState(rootClientId, noop, true);
56
56
  const filteredItems = useMemo(() => {
57
57
  const initialFilteredItems = !!filterValue.trim() ? searchBlockItems(items, categories, collections, filterValue) : orderInserterBlockItems(orderBy(items, 'frecency', 'desc'), prioritizedBlocks);
58
58
  return initialFilteredItems.filter(item => item.name !== selectedBlockName).slice(0, SHOWN_BLOCK_TYPES);
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","createBlock","createBlocksFromInnerBlocksTemplate","parse","useMemo","searchBlockItems","useBlockTypesState","BlockIcon","store","blockEditorStore","orderBy","orderInserterBlockItems","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","noop","SHOWN_BLOCK_TYPES","createBlockCompleter","name","className","triggerPrefix","useItems","filterValue","rootClientId","selectedBlockName","prioritizedBlocks","select","getSelectedBlockClientId","getBlockName","getBlockListSettings","getBlockRootClientId","selectedBlockClientId","_rootClientId","prioritizedInserterBlocks","items","categories","collections","filteredItems","initialFilteredItems","trim","filter","item","slice","options","map","blockItem","title","icon","isDisabled","key","id","value","label","children","showColors","allowContext","before","after","test","getOptionCompletion","inserterItem","initialAttributes","innerBlocks","syncStatus","content","action","__unstableSkipMigrationLogs"],"sources":["@wordpress/block-editor/src/autocompleters/block.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tcreateBlock,\n\tcreateBlocksFromInnerBlocksTemplate,\n\tparse,\n} from '@wordpress/blocks';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { searchBlockItems } from '../components/inserter/search-items';\nimport useBlockTypesState from '../components/inserter/hooks/use-block-types-state';\nimport BlockIcon from '../components/block-icon';\nimport { store as blockEditorStore } from '../store';\nimport { orderBy } from '../utils/sorting';\nimport { orderInserterBlockItems } from '../utils/order-inserter-block-items';\n\nconst noop = () => {};\nconst SHOWN_BLOCK_TYPES = 9;\n\n/** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */\n\n/**\n * Creates a blocks repeater for replacing the current block with a selected block type.\n *\n * @return {WPCompleter} A blocks completer.\n */\nfunction createBlockCompleter() {\n\treturn {\n\t\tname: 'blocks',\n\t\tclassName: 'block-editor-autocompleters__block',\n\t\ttriggerPrefix: '/',\n\n\t\tuseItems( filterValue ) {\n\t\t\tconst { rootClientId, selectedBlockName, prioritizedBlocks } =\n\t\t\t\tuseSelect( ( select ) => {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\t\t\tgetBlockName,\n\t\t\t\t\t\tgetBlockListSettings,\n\t\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\t} = select( blockEditorStore );\n\t\t\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\t\t\t\tconst _rootClientId = getBlockRootClientId(\n\t\t\t\t\t\tselectedBlockClientId\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tselectedBlockName: selectedBlockClientId\n\t\t\t\t\t\t\t? getBlockName( selectedBlockClientId )\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\trootClientId: _rootClientId,\n\t\t\t\t\t\tprioritizedBlocks:\n\t\t\t\t\t\t\tgetBlockListSettings( _rootClientId )\n\t\t\t\t\t\t\t\t?.prioritizedInserterBlocks,\n\t\t\t\t\t};\n\t\t\t\t}, [] );\n\t\t\tconst [ items, categories, collections ] = useBlockTypesState(\n\t\t\t\trootClientId,\n\t\t\t\tnoop\n\t\t\t);\n\n\t\t\tconst filteredItems = useMemo( () => {\n\t\t\t\tconst initialFilteredItems = !! filterValue.trim()\n\t\t\t\t\t? searchBlockItems(\n\t\t\t\t\t\t\titems,\n\t\t\t\t\t\t\tcategories,\n\t\t\t\t\t\t\tcollections,\n\t\t\t\t\t\t\tfilterValue\n\t\t\t\t\t )\n\t\t\t\t\t: orderInserterBlockItems(\n\t\t\t\t\t\t\torderBy( items, 'frecency', 'desc' ),\n\t\t\t\t\t\t\tprioritizedBlocks\n\t\t\t\t\t );\n\n\t\t\t\treturn initialFilteredItems\n\t\t\t\t\t.filter( ( item ) => item.name !== selectedBlockName )\n\t\t\t\t\t.slice( 0, SHOWN_BLOCK_TYPES );\n\t\t\t}, [\n\t\t\t\tfilterValue,\n\t\t\t\tselectedBlockName,\n\t\t\t\titems,\n\t\t\t\tcategories,\n\t\t\t\tcollections,\n\t\t\t\tprioritizedBlocks,\n\t\t\t] );\n\n\t\t\tconst options = useMemo(\n\t\t\t\t() =>\n\t\t\t\t\tfilteredItems.map( ( blockItem ) => {\n\t\t\t\t\t\tconst { title, icon, isDisabled } = blockItem;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tkey: `block-${ blockItem.id }`,\n\t\t\t\t\t\t\tvalue: blockItem,\n\t\t\t\t\t\t\tlabel: (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<BlockIcon\n\t\t\t\t\t\t\t\t\t\tkey=\"icon\"\n\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\tshowColors\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tisDisabled,\n\t\t\t\t\t\t};\n\t\t\t\t\t} ),\n\t\t\t\t[ filteredItems ]\n\t\t\t);\n\n\t\t\treturn [ options ];\n\t\t},\n\t\tallowContext( before, after ) {\n\t\t\treturn ! ( /\\S/.test( before ) || /\\S/.test( after ) );\n\t\t},\n\t\tgetOptionCompletion( inserterItem ) {\n\t\t\tconst {\n\t\t\t\tname,\n\t\t\t\tinitialAttributes,\n\t\t\t\tinnerBlocks,\n\t\t\t\tsyncStatus,\n\t\t\t\tcontent,\n\t\t\t} = inserterItem;\n\n\t\t\treturn {\n\t\t\t\taction: 'replace',\n\t\t\t\tvalue:\n\t\t\t\t\tsyncStatus === 'unsynced'\n\t\t\t\t\t\t? parse( content, {\n\t\t\t\t\t\t\t\t__unstableSkipMigrationLogs: true,\n\t\t\t\t\t\t } )\n\t\t\t\t\t\t: createBlock(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tinitialAttributes,\n\t\t\t\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate(\n\t\t\t\t\t\t\t\t\tinnerBlocks\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t ),\n\t\t\t};\n\t\t},\n\t};\n}\n\n/**\n * Creates a blocks repeater for replacing the current block with a selected block type.\n *\n * @return {WPCompleter} A blocks completer.\n */\nexport default createBlockCompleter();\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,WAAW,EACXC,mCAAmC,EACnCC,KAAK,QACC,mBAAmB;AAC1B,SAASC,OAAO,QAAQ,oBAAoB;;AAE5C;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,qCAAqC;AACtE,OAAOC,kBAAkB,MAAM,oDAAoD;AACnF,OAAOC,SAAS,MAAM,0BAA0B;AAChD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,UAAU;AACpD,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,uBAAuB,QAAQ,qCAAqC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAE9E,MAA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AAmC,CAClC+D,WACD,CACA;MACL,CAAC;IACF;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe7C,oBAAoB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","createBlock","createBlocksFromInnerBlocksTemplate","parse","useMemo","searchBlockItems","useBlockTypesState","BlockIcon","store","blockEditorStore","orderBy","orderInserterBlockItems","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","noop","SHOWN_BLOCK_TYPES","createBlockCompleter","name","className","triggerPrefix","useItems","filterValue","rootClientId","selectedBlockName","prioritizedBlocks","select","getSelectedBlockClientId","getBlockName","getBlockListSettings","getBlockRootClientId","selectedBlockClientId","_rootClientId","prioritizedInserterBlocks","items","categories","collections","filteredItems","initialFilteredItems","trim","filter","item","slice","options","map","blockItem","title","icon","isDisabled","key","id","value","label","children","showColors","allowContext","before","after","test","getOptionCompletion","inserterItem","initialAttributes","innerBlocks","syncStatus","content","action","__unstableSkipMigrationLogs"],"sources":["@wordpress/block-editor/src/autocompleters/block.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tcreateBlock,\n\tcreateBlocksFromInnerBlocksTemplate,\n\tparse,\n} from '@wordpress/blocks';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { searchBlockItems } from '../components/inserter/search-items';\nimport useBlockTypesState from '../components/inserter/hooks/use-block-types-state';\nimport BlockIcon from '../components/block-icon';\nimport { store as blockEditorStore } from '../store';\nimport { orderBy } from '../utils/sorting';\nimport { orderInserterBlockItems } from '../utils/order-inserter-block-items';\n\nconst noop = () => {};\nconst SHOWN_BLOCK_TYPES = 9;\n\n/** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */\n\n/**\n * Creates a blocks repeater for replacing the current block with a selected block type.\n *\n * @return {WPCompleter} A blocks completer.\n */\nfunction createBlockCompleter() {\n\treturn {\n\t\tname: 'blocks',\n\t\tclassName: 'block-editor-autocompleters__block',\n\t\ttriggerPrefix: '/',\n\n\t\tuseItems( filterValue ) {\n\t\t\tconst { rootClientId, selectedBlockName, prioritizedBlocks } =\n\t\t\t\tuseSelect( ( select ) => {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\t\t\tgetBlockName,\n\t\t\t\t\t\tgetBlockListSettings,\n\t\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\t} = select( blockEditorStore );\n\t\t\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\t\t\t\tconst _rootClientId = getBlockRootClientId(\n\t\t\t\t\t\tselectedBlockClientId\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tselectedBlockName: selectedBlockClientId\n\t\t\t\t\t\t\t? getBlockName( selectedBlockClientId )\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\trootClientId: _rootClientId,\n\t\t\t\t\t\tprioritizedBlocks:\n\t\t\t\t\t\t\tgetBlockListSettings( _rootClientId )\n\t\t\t\t\t\t\t\t?.prioritizedInserterBlocks,\n\t\t\t\t\t};\n\t\t\t\t}, [] );\n\t\t\tconst [ items, categories, collections ] = useBlockTypesState(\n\t\t\t\trootClientId,\n\t\t\t\tnoop,\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\tconst filteredItems = useMemo( () => {\n\t\t\t\tconst initialFilteredItems = !! filterValue.trim()\n\t\t\t\t\t? searchBlockItems(\n\t\t\t\t\t\t\titems,\n\t\t\t\t\t\t\tcategories,\n\t\t\t\t\t\t\tcollections,\n\t\t\t\t\t\t\tfilterValue\n\t\t\t\t\t )\n\t\t\t\t\t: orderInserterBlockItems(\n\t\t\t\t\t\t\torderBy( items, 'frecency', 'desc' ),\n\t\t\t\t\t\t\tprioritizedBlocks\n\t\t\t\t\t );\n\n\t\t\t\treturn initialFilteredItems\n\t\t\t\t\t.filter( ( item ) => item.name !== selectedBlockName )\n\t\t\t\t\t.slice( 0, SHOWN_BLOCK_TYPES );\n\t\t\t}, [\n\t\t\t\tfilterValue,\n\t\t\t\tselectedBlockName,\n\t\t\t\titems,\n\t\t\t\tcategories,\n\t\t\t\tcollections,\n\t\t\t\tprioritizedBlocks,\n\t\t\t] );\n\n\t\t\tconst options = useMemo(\n\t\t\t\t() =>\n\t\t\t\t\tfilteredItems.map( ( blockItem ) => {\n\t\t\t\t\t\tconst { title, icon, isDisabled } = blockItem;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tkey: `block-${ blockItem.id }`,\n\t\t\t\t\t\t\tvalue: blockItem,\n\t\t\t\t\t\t\tlabel: (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<BlockIcon\n\t\t\t\t\t\t\t\t\t\tkey=\"icon\"\n\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\tshowColors\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tisDisabled,\n\t\t\t\t\t\t};\n\t\t\t\t\t} ),\n\t\t\t\t[ filteredItems ]\n\t\t\t);\n\n\t\t\treturn [ options ];\n\t\t},\n\t\tallowContext( before, after ) {\n\t\t\treturn ! ( /\\S/.test( before ) || /\\S/.test( after ) );\n\t\t},\n\t\tgetOptionCompletion( inserterItem ) {\n\t\t\tconst {\n\t\t\t\tname,\n\t\t\t\tinitialAttributes,\n\t\t\t\tinnerBlocks,\n\t\t\t\tsyncStatus,\n\t\t\t\tcontent,\n\t\t\t} = inserterItem;\n\n\t\t\treturn {\n\t\t\t\taction: 'replace',\n\t\t\t\tvalue:\n\t\t\t\t\tsyncStatus === 'unsynced'\n\t\t\t\t\t\t? parse( content, {\n\t\t\t\t\t\t\t\t__unstableSkipMigrationLogs: true,\n\t\t\t\t\t\t } )\n\t\t\t\t\t\t: createBlock(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tinitialAttributes,\n\t\t\t\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate(\n\t\t\t\t\t\t\t\t\tinnerBlocks\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t ),\n\t\t\t};\n\t\t},\n\t};\n}\n\n/**\n * Creates a blocks repeater for replacing the current block with a selected block type.\n *\n * @return {WPCompleter} A blocks completer.\n */\nexport default createBlockCompleter();\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,WAAW,EACXC,mCAAmC,EACnCC,KAAK,QACC,mBAAmB;AAC1B,SAASC,OAAO,QAAQ,oBAAoB;;AAE5C;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,qCAAqC;AACtE,OAAOC,kBAAkB,MAAM,oDAAoD;AACnF,OAAOC,SAAS,MAAM,0BAA0B;AAChD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,UAAU;AACpD,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,uBAAuB,QAAQ,qCAAqC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAE9E,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrB,MAAMC,iBAAiB,GAAG,CAAC;;AAE3B;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASC,oBAAoBA,CAAA,EAAG;EAC/B,OAAO;IACNC,IAAI,EAAE,QAAQ;IACdC,SAAS,EAAE,oCAAoC;IAC/CC,aAAa,EAAE,GAAG;IAElBC,QAAQA,CAAEC,WAAW,EAAG;MACvB,MAAM;QAAEC,YAAY;QAAEC,iBAAiB;QAAEC;MAAkB,CAAC,GAC3D5B,SAAS,CAAI6B,MAAM,IAAM;QACxB,MAAM;UACLC,wBAAwB;UACxBC,YAAY;UACZC,oBAAoB;UACpBC;QACD,CAAC,GAAGJ,MAAM,CAAEpB,gBAAiB,CAAC;QAC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eACJtC,KAAA,CAAAF,SAAA;YAAAyC,QAAA,gBACC3C,IAAA,CAACN,SAAS;cAET2C,IAAI,EAAGA,IAAM;cACbO,UAAU;YAAA,GAFN,MAGJ,CAAC,EACAR,KAAK;UAAA,CACN,CACF;UACDE;QACD,CAAC;MACF,CAAE,CAAC,EACJ,CAAEX,aAAa,CAChB,CAAC;MAED,OAAO,CAAEM,OAAO,CAAE;IACnB,CAAC;IACDY,YAAYA,CAAEC,MAAM,EAAEC,KAAK,EAAG;MAC7B,OAAO,EAAI,IAAI,CAACC,IAAI,CAAEF,MAAO,CAAC,IAAI,IAAI,CAACE,IAAI,CAAED,KAAM,CAAC,CAAE;IACvD,CAAC;IACDE,mBAAmBA,CAAEC,YAAY,EAAG;MACnC,MAAM;QACL1C,IAAI;QACJ2C,iBAAiB;QACjBC,WAAW;QACXC,UAAU;QACVC;MACD,CAAC,GAAGJ,YAAY;MAEhB,OAAO;QACNK,MAAM,EAAE,SAAS;QACjBd,KAAK,EACJY,UAAU,KAAK,UAAU,GACtB/D,KAAK,CAAEgE,OAAO,EAAE;UAChBE,2BAA2B,EAAE;QAC7B,CAAE,CAAC,GACHpE,WAAW,CACXoB,IAAI,EACJ2C,iBAAiB,EACjB9D,mCAAmC,CAClC+D,WACD,CACA;MACL,CAAC;IACF;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe7C,oBAAoB,CAAC,CAAC","ignoreList":[]}
@@ -5,6 +5,7 @@ import { Button } from '@wordpress/components';
5
5
  import { useSelect, useDispatch } from '@wordpress/data';
6
6
  import { __ } from '@wordpress/i18n';
7
7
  import { chevronRightSmall, Icon } from '@wordpress/icons';
8
+ import { useRef } from '@wordpress/element';
8
9
 
9
10
  /**
10
11
  * Internal dependencies
@@ -12,7 +13,7 @@ import { chevronRightSmall, Icon } from '@wordpress/icons';
12
13
  import BlockTitle from '../block-title';
13
14
  import { store as blockEditorStore } from '../../store';
14
15
  import { unlock } from '../../lock-unlock';
15
- import { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';
16
+ import { useBlockElementRef } from '../block-list/use-block-props/use-block-refs';
16
17
  import getEditorRegion from '../../utils/get-editor-region';
17
18
 
18
19
  /**
@@ -52,7 +53,8 @@ function BlockBreadcrumb({
52
53
 
53
54
  // We don't care about this specific ref, but this is a way
54
55
  // to get a ref within the editor canvas so we can focus it later.
55
- const blockRef = useBlockRef(clientId);
56
+ const blockRef = useRef();
57
+ useBlockElementRef(clientId, blockRef);
56
58
 
57
59
  /*
58
60
  * Disable reason: The `list` ARIA role is redundant but
@@ -1 +1 @@
1
- {"version":3,"names":["Button","useSelect","useDispatch","__","chevronRightSmall","Icon","BlockTitle","store","blockEditorStore","unlock","__unstableUseBlockRef","useBlockRef","getEditorRegion","jsx","_jsx","jsxs","_jsxs","BlockBreadcrumb","rootLabelText","selectBlock","clearSelectedBlock","clientId","parents","hasSelection","select","getSelectionStart","getSelectedBlockClientId","getEnabledBlockParents","selectedBlockClientId","rootLabel","blockRef","className","role","children","undefined","variant","onClick","blockEditor","current","closest","focus","icon","map","parentClientId","maximumLength"],"sources":["@wordpress/block-editor/src/components/block-breadcrumb/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { chevronRightSmall, Icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport BlockTitle from '../block-title';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';\nimport getEditorRegion from '../../utils/get-editor-region';\n\n/**\n * Block breadcrumb component, displaying the hierarchy of the current block selection as a breadcrumb.\n *\n * @param {Object} props Component props.\n * @param {string} props.rootLabelText Translated label for the root element of the breadcrumb trail.\n * @return {Element} Block Breadcrumb.\n */\nfunction BlockBreadcrumb( { rootLabelText } ) {\n\tconst { selectBlock, clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst { clientId, parents, hasSelection } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetSelectionStart,\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetEnabledBlockParents,\n\t\t} = unlock( select( blockEditorStore ) );\n\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\treturn {\n\t\t\tparents: getEnabledBlockParents( selectedBlockClientId ),\n\t\t\tclientId: selectedBlockClientId,\n\t\t\thasSelection: !! getSelectionStart().clientId,\n\t\t};\n\t}, [] );\n\tconst rootLabel = rootLabelText || __( 'Document' );\n\n\t// We don't care about this specific ref, but this is a way\n\t// to get a ref within the editor canvas so we can focus it later.\n\tconst blockRef = useBlockRef( clientId );\n\n\t/*\n\t * Disable reason: The `list` ARIA role is redundant but\n\t * Safari+VoiceOver won't announce the list otherwise.\n\t */\n\t/* eslint-disable jsx-a11y/no-redundant-roles */\n\treturn (\n\t\t<ul\n\t\t\tclassName=\"block-editor-block-breadcrumb\"\n\t\t\trole=\"list\"\n\t\t\taria-label={ __( 'Block breadcrumb' ) }\n\t\t>\n\t\t\t<li\n\t\t\t\tclassName={\n\t\t\t\t\t! hasSelection\n\t\t\t\t\t\t? 'block-editor-block-breadcrumb__current'\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\taria-current={ ! hasSelection ? 'true' : undefined }\n\t\t\t>\n\t\t\t\t{ hasSelection && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__button\"\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t// Find the block editor wrapper for the selected block\n\t\t\t\t\t\t\tconst blockEditor = blockRef.current?.closest(\n\t\t\t\t\t\t\t\t'.editor-styles-wrapper'\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tclearSelectedBlock();\n\n\t\t\t\t\t\t\tgetEditorRegion( blockEditor )?.focus();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ rootLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\t{ ! hasSelection && rootLabel }\n\t\t\t\t{ !! clientId && (\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ chevronRightSmall }\n\t\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__separator\"\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</li>\n\n\t\t\t{ parents.map( ( parentClientId ) => (\n\t\t\t\t<li key={ parentClientId }>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__button\"\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => selectBlock( parentClientId ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockTitle\n\t\t\t\t\t\t\tclientId={ parentClientId }\n\t\t\t\t\t\t\tmaximumLength={ 35 }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ chevronRightSmall }\n\t\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__separator\"\n\t\t\t\t\t/>\n\t\t\t\t</li>\n\t\t\t) ) }\n\t\t\t{ !! clientId && (\n\t\t\t\t<li\n\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__current\"\n\t\t\t\t\taria-current=\"true\"\n\t\t\t\t>\n\t\t\t\t\t<BlockTitle clientId={ clientId } maximumLength={ 35 } />\n\t\t\t\t</li>\n\t\t\t) }\n\t\t</ul>\n\t\t/* eslint-enable jsx-a11y/no-redundant-roles */\n\t);\n}\n\nexport default BlockBreadcrumb;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,iBAAiB,EAAEC,IAAI,QAAQ,k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,aAAa,EAAG;MAAI,CAAE;IAAC,CACtD,CACJ;EAAA,CACE;EACJ;AAEF;AAEA,eAAe3B,eAAe","ignoreList":[]}
1
+ {"version":3,"names":["Button","useSelect","useDispatch","__","chevronRightSmall","Icon","useRef","BlockTitle","store","blockEditorStore","unlock","useBlockElementRef","getEditorRegion","jsx","_jsx","jsxs","_jsxs","BlockBreadcrumb","rootLabelText","selectBlock","clearSelectedBlock","clientId","parents","hasSelection","select","getSelectionStart","getSelectedBlockClientId","getEnabledBlockParents","selectedBlockClientId","rootLabel","blockRef","className","role","children","undefined","variant","onClick","blockEditor","current","closest","focus","icon","map","parentClientId","maximumLength"],"sources":["@wordpress/block-editor/src/components/block-breadcrumb/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { chevronRightSmall, Icon } from '@wordpress/icons';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockTitle from '../block-title';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useBlockElementRef } from '../block-list/use-block-props/use-block-refs';\nimport getEditorRegion from '../../utils/get-editor-region';\n\n/**\n * Block breadcrumb component, displaying the hierarchy of the current block selection as a breadcrumb.\n *\n * @param {Object} props Component props.\n * @param {string} props.rootLabelText Translated label for the root element of the breadcrumb trail.\n * @return {Element} Block Breadcrumb.\n */\nfunction BlockBreadcrumb( { rootLabelText } ) {\n\tconst { selectBlock, clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst { clientId, parents, hasSelection } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetSelectionStart,\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetEnabledBlockParents,\n\t\t} = unlock( select( blockEditorStore ) );\n\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\treturn {\n\t\t\tparents: getEnabledBlockParents( selectedBlockClientId ),\n\t\t\tclientId: selectedBlockClientId,\n\t\t\thasSelection: !! getSelectionStart().clientId,\n\t\t};\n\t}, [] );\n\tconst rootLabel = rootLabelText || __( 'Document' );\n\n\t// We don't care about this specific ref, but this is a way\n\t// to get a ref within the editor canvas so we can focus it later.\n\tconst blockRef = useRef();\n\tuseBlockElementRef( clientId, blockRef );\n\n\t/*\n\t * Disable reason: The `list` ARIA role is redundant but\n\t * Safari+VoiceOver won't announce the list otherwise.\n\t */\n\t/* eslint-disable jsx-a11y/no-redundant-roles */\n\treturn (\n\t\t<ul\n\t\t\tclassName=\"block-editor-block-breadcrumb\"\n\t\t\trole=\"list\"\n\t\t\taria-label={ __( 'Block breadcrumb' ) }\n\t\t>\n\t\t\t<li\n\t\t\t\tclassName={\n\t\t\t\t\t! hasSelection\n\t\t\t\t\t\t? 'block-editor-block-breadcrumb__current'\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\taria-current={ ! hasSelection ? 'true' : undefined }\n\t\t\t>\n\t\t\t\t{ hasSelection && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__button\"\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t// Find the block editor wrapper for the selected block\n\t\t\t\t\t\t\tconst blockEditor = blockRef.current?.closest(\n\t\t\t\t\t\t\t\t'.editor-styles-wrapper'\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tclearSelectedBlock();\n\n\t\t\t\t\t\t\tgetEditorRegion( blockEditor )?.focus();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ rootLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\t{ ! hasSelection && rootLabel }\n\t\t\t\t{ !! clientId && (\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ chevronRightSmall }\n\t\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__separator\"\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</li>\n\n\t\t\t{ parents.map( ( parentClientId ) => (\n\t\t\t\t<li key={ parentClientId }>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__button\"\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => selectBlock( parentClientId ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockTitle\n\t\t\t\t\t\t\tclientId={ parentClientId }\n\t\t\t\t\t\t\tmaximumLength={ 35 }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ chevronRightSmall }\n\t\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__separator\"\n\t\t\t\t\t/>\n\t\t\t\t</li>\n\t\t\t) ) }\n\t\t\t{ !! clientId && (\n\t\t\t\t<li\n\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__current\"\n\t\t\t\t\taria-current=\"true\"\n\t\t\t\t>\n\t\t\t\t\t<BlockTitle clientId={ clientId } maximumLength={ 35 } />\n\t\t\t\t</li>\n\t\t\t) }\n\t\t</ul>\n\t\t/* eslint-enable jsx-a11y/no-redundant-roles */\n\t);\n}\n\nexport default BlockBreadcrumb;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,iBAAiB,EAAEC,IAAI,QAAQ,kBAAkB;AAC1D,SAASC,MAAM,QAAQ,oBAAoB;;AAE3C;AACA;AACA;AACA,OAAOC,UAAU,MAAM,gBAAgB;AACvC,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,kBAAkB,QAAQ,8CAA8C;AACjF,OAAOC,eAAe,MAAM,+BAA+B;;AAE3D;AAC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BC,OAAO,EAAGA,CAAA,KAAM;UACf;UACA,MAAMC,WAAW,GAAGP,QAAQ,CAACQ,OAAO,EAAEC,OAAO,CAC5C,wBACD,CAAC;UAEDnB,kBAAkB,CAAC,CAAC;UAEpBR,eAAe,CAAEyB,WAAY,CAAC,EAAEG,KAAK,CAAC,CAAC;QACxC,CAAG;QAAAP,QAAA,EAEDJ;MAAS,CACJ,CACR,EACC,CAAEN,YAAY,IAAIM,SAAS,EAC3B,CAAC,CAAER,QAAQ,iBACZP,IAAA,CAACT,IAAI;QACJoC,IAAI,EAAGrC,iBAAmB;QAC1B2B,SAAS,EAAC;MAA0C,CACpD,CACD;IAAA,CACE,CAAC,EAEHT,OAAO,CAACoB,GAAG,CAAIC,cAAc,iBAC9B3B,KAAA;MAAAiB,QAAA,gBACCnB,IAAA,CAACd,MAAM;QACN+B,SAAS,EAAC,uCAAuC;QACjDI,OAAO,EAAC,UAAU;QAClBC,OAAO,EAAGA,CAAA,KAAMjB,WAAW,CAAEwB,cAAe,CAAG;QAAAV,QAAA,eAE/CnB,IAAA,CAACP,UAAU;UACVc,QAAQ,EAAGsB,cAAgB;UAC3BC,aAAa,EAAG;QAAI,CACpB;MAAC,CACK,CAAC,eACT9B,IAAA,CAACT,IAAI;QACJoC,IAAI,EAAGrC,iBAAmB;QAC1B2B,SAAS,EAAC;MAA0C,CACpD,CAAC;IAAA,GAdOY,cAeN,CACH,CAAC,EACD,CAAC,CAAEtB,QAAQ,iBACZP,IAAA;MACCiB,SAAS,EAAC,wCAAwC;MAClD,gBAAa,MAAM;MAAAE,QAAA,eAEnBnB,IAAA,CAACP,UAAU;QAACc,QAAQ,EAAGA,QAAU;QAACuB,aAAa,EAAG;MAAI,CAAE;IAAC,CACtD,CACJ;EAAA,CACE;EACJ;AAEF;AAEA,eAAe3B,eAAe","ignoreList":[]}
@@ -13,7 +13,7 @@ import { throttle } from '@wordpress/compose';
13
13
  import BlockDraggableChip from './draggable-chip';
14
14
  import useScrollWhenDragging from './use-scroll-when-dragging';
15
15
  import { store as blockEditorStore } from '../../store';
16
- import { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';
16
+ import { useBlockElement } from '../block-list/use-block-props/use-block-refs';
17
17
  import { isDropTargetValid } from '../use-block-drop-zone';
18
18
  import { jsx as _jsx } from "react/jsx-runtime";
19
19
  const BlockDraggable = ({
@@ -78,8 +78,8 @@ const BlockDraggable = ({
78
78
  }, []);
79
79
 
80
80
  // Find the root of the editor iframe.
81
- const blockRef = useBlockRef(clientIds[0]);
82
- const editorRoot = blockRef.current?.closest('body');
81
+ const blockEl = useBlockElement(clientIds[0]);
82
+ const editorRoot = blockEl?.closest('body');
83
83
 
84
84
  /*
85
85
  * Add a dragover event listener to the editor root to track the blocks being dragged over.
@@ -1 +1 @@
1
- {"version":3,"names":["store","blocksStore","Draggable","useSelect","useDispatch","useEffect","useRef","throttle","BlockDraggableChip","useScrollWhenDragging","blockEditorStore","__unstableUseBlockRef","useBlockRef","isDropTargetValid","jsx","_jsx","BlockDraggable","appendToOwnerDocument","children","clientIds","cloneClassname","elementId","onDragStart","onDragEnd","fadeWhenDisabled","dragComponent","srcRootClientId","isDraggable","icon","visibleInserter","getBlockType","select","canMoveBlocks","getBlockRootClientId","getBlockName","getBlockAttributes","isBlockInsertionPointVisible","_getBlockType","getActiveBlockVariation","rootClientId","blockName","variation","isDragging","startScrolling","scrollOnDragOver","stopScrolling","getAllowedBlocks","getBlockNamesByClientId","startDraggingBlocks","stopDraggingBlocks","current","blockRef","editorRoot","closest","onDragOver","event","target","draggedBlockNames","targetClientId","getAttribute","allowedBlocks","targetBlockName","dropTargetValid","length","targetRootClientId","targetRootBlockName","rootAllowedBlocks","window","document","body","classList","add","remove","throttledOnDragOver","addEventListener","removeEventListener","draggable","transferData","type","srcClientIds","__experimentalTransferDataType","requestAnimationFrame","__experimentalDragComponent","undefined","count","onDraggableStart","onDraggableEnd"],"sources":["@wordpress/block-editor/src/components/block-draggable/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { Draggable } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\nimport { throttle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockDraggableChip from './draggable-chip';\nimport useScrollWhenDragging from './use-scroll-when-dragging';\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';\nimport { isDropTargetValid } from '../use-block-drop-zone';\n\nconst BlockDraggable = ( {\n\tappendToOwnerDocument,\n\tchildren,\n\tclientIds,\n\tcloneClassname,\n\telementId,\n\tonDragStart,\n\tonDragEnd,\n\tfadeWhenDisabled = false,\n\tdragComponent,\n} ) => {\n\tconst {\n\t\tsrcRootClientId,\n\t\tisDraggable,\n\t\ticon,\n\t\tvisibleInserter,\n\t\tgetBlockType,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanMoveBlocks,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockType: _getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\tconst blockName = getBlockName( clientIds[ 0 ] );\n\t\t\tconst variation = getActiveBlockVariation(\n\t\t\t\tblockName,\n\t\t\t\tgetBlockAttributes( clientIds[ 0 ] )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tsrcRootClientId: rootClientId,\n\t\t\t\tisDraggable: canMoveBlocks( clientIds ),\n\t\t\t\ticon: variation?.icon || _getBlockType( blockName )?.icon,\n\t\t\t\tvisibleInserter: isBlockInsertionPointVisible(),\n\t\t\t\tgetBlockType: _getBlockType,\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\n\tconst isDragging = useRef( false );\n\tconst [ startScrolling, scrollOnDragOver, stopScrolling ] =\n\t\tuseScrollWhenDragging();\n\n\tconst { getAllowedBlocks, getBlockNamesByClientId, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\n\tconst { startDraggingBlocks, stopDraggingBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Stop dragging blocks if the block draggable is unmounted.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDragging.current ) {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\t// Find the root of the editor iframe.\n\tconst blockRef = useBlockRef( clientIds[ 0 ] );\n\tconst editorRoot = blockRef.current?.closest( 'body' );\n\n\t/*\n\t * Add a dragover event listener to the editor root to track the blocks being dragged over.\n\t * The listener has to be inside the editor iframe otherwise the target isn't accessible.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! editorRoot || ! fadeWhenDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst onDragOver = ( event ) => {\n\t\t\tif ( ! event.target.closest( '[data-block]' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst draggedBlockNames = getBlockNamesByClientId( clientIds );\n\t\t\tconst targetClientId = event.target\n\t\t\t\t.closest( '[data-block]' )\n\t\t\t\t.getAttribute( 'data-block' );\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( targetClientId );\n\t\t\tconst targetBlockName = getBlockNamesByClientId( [\n\t\t\t\ttargetClientId,\n\t\t\t] )[ 0 ];\n\n\t\t\t/*\n\t\t\t * Check if the target is valid to drop in.\n\t\t\t * If the target's allowedBlocks is an empty array,\n\t\t\t * it isn't a container block, in which case we check\n\t\t\t * its parent's validity instead.\n\t\t\t */\n\t\t\tlet dropTargetValid;\n\t\t\tif ( allowedBlocks?.length === 0 ) {\n\t\t\t\tconst targetRootClientId =\n\t\t\t\t\tgetBlockRootClientId( targetClientId );\n\t\t\t\tconst targetRootBlockName = getBlockNamesByClientId( [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t] )[ 0 ];\n\t\t\t\tconst rootAllowedBlocks =\n\t\t\t\t\tgetAllowedBlocks( targetRootClientId );\n\t\t\t\tdropTargetValid = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\trootAllowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetRootBlockName\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tdropTargetValid = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\tallowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetBlockName\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Update the body class to reflect if drop target is valid.\n\t\t\t * This has to be done on the document body because the draggable\n\t\t\t * chip is rendered outside of the editor iframe.\n\t\t\t */\n\t\t\tif ( ! dropTargetValid && ! visibleInserter ) {\n\t\t\t\twindow?.document?.body?.classList?.add(\n\t\t\t\t\t'block-draggable-invalid-drag-token'\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\twindow?.document?.body?.classList?.remove(\n\t\t\t\t\t'block-draggable-invalid-drag-token'\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst throttledOnDragOver = throttle( onDragOver, 200 );\n\n\t\teditorRoot.addEventListener( 'dragover', throttledOnDragOver );\n\n\t\treturn () => {\n\t\t\teditorRoot.removeEventListener( 'dragover', throttledOnDragOver );\n\t\t};\n\t}, [\n\t\tclientIds,\n\t\teditorRoot,\n\t\tfadeWhenDisabled,\n\t\tgetAllowedBlocks,\n\t\tgetBlockNamesByClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlockType,\n\t\tvisibleInserter,\n\t] );\n\n\tif ( ! isDraggable ) {\n\t\treturn children( { draggable: false } );\n\t}\n\n\tconst transferData = {\n\t\ttype: 'block',\n\t\tsrcClientIds: clientIds,\n\t\tsrcRootClientId,\n\t};\n\n\treturn (\n\t\t<Draggable\n\t\t\tappendToOwnerDocument={ appendToOwnerDocument }\n\t\t\tcloneClassname={ cloneClassname }\n\t\t\t__experimentalTransferDataType=\"wp-blocks\"\n\t\t\ttransferData={ transferData }\n\t\t\tonDragStart={ ( event ) => {\n\t\t\t\t// Defer hiding the dragged source element to the next\n\t\t\t\t// frame to enable dragging.\n\t\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\t\tstartDraggingBlocks( clientIds );\n\t\t\t\t\tisDragging.current = true;\n\n\t\t\t\t\tstartScrolling( event );\n\n\t\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\t\tonDragStart();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tonDragOver={ scrollOnDragOver }\n\t\t\tonDragEnd={ () => {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t\tisDragging.current = false;\n\n\t\t\t\tstopScrolling();\n\n\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\tonDragEnd();\n\t\t\t\t}\n\t\t\t} }\n\t\t\t__experimentalDragComponent={\n\t\t\t\t// Check against `undefined` so that `null` can be used to disable\n\t\t\t\t// the default drag component.\n\t\t\t\tdragComponent !== undefined ? (\n\t\t\t\t\tdragComponent\n\t\t\t\t) : (\n\t\t\t\t\t<BlockDraggableChip\n\t\t\t\t\t\tcount={ clientIds.length }\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\tfadeWhenDisabled\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t\telementId={ elementId }\n\t\t>\n\t\t\t{ ( { onDraggableStart, onDraggableEnd } ) => {\n\t\t\t\treturn children( {\n\t\t\t\t\tdraggable: true,\n\t\t\t\t\tonDragStart: onDraggableStart,\n\t\t\t\t\tonDragEnd: onDraggableEnd,\n\t\t\t\t} );\n\t\t\t} }\n\t\t</Draggable>\n\t);\n};\n\nexport default BlockDraggable;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA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,SAAW;IAAAH,QAAA,EAErBA,CAAE;MAAEmE,gBAAgB;MAAEC;IAAe,CAAC,KAAM;MAC7C,OAAOpE,QAAQ,CAAE;QAChB0D,SAAS,EAAE,IAAI;QACftD,WAAW,EAAE+D,gBAAgB;QAC7B9D,SAAS,EAAE+D;MACZ,CAAE,CAAC;IACJ;EAAC,CACS,CAAC;AAEd,CAAC;AAED,eAAetE,cAAc","ignoreList":[]}
1
+ {"version":3,"names":["store","blocksStore","Draggable","useSelect","useDispatch","useEffect","useRef","throttle","BlockDraggableChip","useScrollWhenDragging","blockEditorStore","useBlockElement","isDropTargetValid","jsx","_jsx","BlockDraggable","appendToOwnerDocument","children","clientIds","cloneClassname","elementId","onDragStart","onDragEnd","fadeWhenDisabled","dragComponent","srcRootClientId","isDraggable","icon","visibleInserter","getBlockType","select","canMoveBlocks","getBlockRootClientId","getBlockName","getBlockAttributes","isBlockInsertionPointVisible","_getBlockType","getActiveBlockVariation","rootClientId","blockName","variation","isDragging","startScrolling","scrollOnDragOver","stopScrolling","getAllowedBlocks","getBlockNamesByClientId","startDraggingBlocks","stopDraggingBlocks","current","blockEl","editorRoot","closest","onDragOver","event","target","draggedBlockNames","targetClientId","getAttribute","allowedBlocks","targetBlockName","dropTargetValid","length","targetRootClientId","targetRootBlockName","rootAllowedBlocks","window","document","body","classList","add","remove","throttledOnDragOver","addEventListener","removeEventListener","draggable","transferData","type","srcClientIds","__experimentalTransferDataType","requestAnimationFrame","__experimentalDragComponent","undefined","count","onDraggableStart","onDraggableEnd"],"sources":["@wordpress/block-editor/src/components/block-draggable/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { Draggable } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\nimport { throttle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockDraggableChip from './draggable-chip';\nimport useScrollWhenDragging from './use-scroll-when-dragging';\nimport { store as blockEditorStore } from '../../store';\nimport { useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport { isDropTargetValid } from '../use-block-drop-zone';\n\nconst BlockDraggable = ( {\n\tappendToOwnerDocument,\n\tchildren,\n\tclientIds,\n\tcloneClassname,\n\telementId,\n\tonDragStart,\n\tonDragEnd,\n\tfadeWhenDisabled = false,\n\tdragComponent,\n} ) => {\n\tconst {\n\t\tsrcRootClientId,\n\t\tisDraggable,\n\t\ticon,\n\t\tvisibleInserter,\n\t\tgetBlockType,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanMoveBlocks,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockType: _getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\tconst blockName = getBlockName( clientIds[ 0 ] );\n\t\t\tconst variation = getActiveBlockVariation(\n\t\t\t\tblockName,\n\t\t\t\tgetBlockAttributes( clientIds[ 0 ] )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tsrcRootClientId: rootClientId,\n\t\t\t\tisDraggable: canMoveBlocks( clientIds ),\n\t\t\t\ticon: variation?.icon || _getBlockType( blockName )?.icon,\n\t\t\t\tvisibleInserter: isBlockInsertionPointVisible(),\n\t\t\t\tgetBlockType: _getBlockType,\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\n\tconst isDragging = useRef( false );\n\tconst [ startScrolling, scrollOnDragOver, stopScrolling ] =\n\t\tuseScrollWhenDragging();\n\n\tconst { getAllowedBlocks, getBlockNamesByClientId, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\n\tconst { startDraggingBlocks, stopDraggingBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Stop dragging blocks if the block draggable is unmounted.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDragging.current ) {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\t// Find the root of the editor iframe.\n\tconst blockEl = useBlockElement( clientIds[ 0 ] );\n\tconst editorRoot = blockEl?.closest( 'body' );\n\n\t/*\n\t * Add a dragover event listener to the editor root to track the blocks being dragged over.\n\t * The listener has to be inside the editor iframe otherwise the target isn't accessible.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! editorRoot || ! fadeWhenDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst onDragOver = ( event ) => {\n\t\t\tif ( ! event.target.closest( '[data-block]' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst draggedBlockNames = getBlockNamesByClientId( clientIds );\n\t\t\tconst targetClientId = event.target\n\t\t\t\t.closest( '[data-block]' )\n\t\t\t\t.getAttribute( 'data-block' );\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( targetClientId );\n\t\t\tconst targetBlockName = getBlockNamesByClientId( [\n\t\t\t\ttargetClientId,\n\t\t\t] )[ 0 ];\n\n\t\t\t/*\n\t\t\t * Check if the target is valid to drop in.\n\t\t\t * If the target's allowedBlocks is an empty array,\n\t\t\t * it isn't a container block, in which case we check\n\t\t\t * its parent's validity instead.\n\t\t\t */\n\t\t\tlet dropTargetValid;\n\t\t\tif ( allowedBlocks?.length === 0 ) {\n\t\t\t\tconst targetRootClientId =\n\t\t\t\t\tgetBlockRootClientId( targetClientId );\n\t\t\t\tconst targetRootBlockName = getBlockNamesByClientId( [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t] )[ 0 ];\n\t\t\t\tconst rootAllowedBlocks =\n\t\t\t\t\tgetAllowedBlocks( targetRootClientId );\n\t\t\t\tdropTargetValid = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\trootAllowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetRootBlockName\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tdropTargetValid = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\tallowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetBlockName\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Update the body class to reflect if drop target is valid.\n\t\t\t * This has to be done on the document body because the draggable\n\t\t\t * chip is rendered outside of the editor iframe.\n\t\t\t */\n\t\t\tif ( ! dropTargetValid && ! visibleInserter ) {\n\t\t\t\twindow?.document?.body?.classList?.add(\n\t\t\t\t\t'block-draggable-invalid-drag-token'\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\twindow?.document?.body?.classList?.remove(\n\t\t\t\t\t'block-draggable-invalid-drag-token'\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst throttledOnDragOver = throttle( onDragOver, 200 );\n\n\t\teditorRoot.addEventListener( 'dragover', throttledOnDragOver );\n\n\t\treturn () => {\n\t\t\teditorRoot.removeEventListener( 'dragover', throttledOnDragOver );\n\t\t};\n\t}, [\n\t\tclientIds,\n\t\teditorRoot,\n\t\tfadeWhenDisabled,\n\t\tgetAllowedBlocks,\n\t\tgetBlockNamesByClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlockType,\n\t\tvisibleInserter,\n\t] );\n\n\tif ( ! isDraggable ) {\n\t\treturn children( { draggable: false } );\n\t}\n\n\tconst transferData = {\n\t\ttype: 'block',\n\t\tsrcClientIds: clientIds,\n\t\tsrcRootClientId,\n\t};\n\n\treturn (\n\t\t<Draggable\n\t\t\tappendToOwnerDocument={ appendToOwnerDocument }\n\t\t\tcloneClassname={ cloneClassname }\n\t\t\t__experimentalTransferDataType=\"wp-blocks\"\n\t\t\ttransferData={ transferData }\n\t\t\tonDragStart={ ( event ) => {\n\t\t\t\t// Defer hiding the dragged source element to the next\n\t\t\t\t// frame to enable dragging.\n\t\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\t\tstartDraggingBlocks( clientIds );\n\t\t\t\t\tisDragging.current = true;\n\n\t\t\t\t\tstartScrolling( event );\n\n\t\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\t\tonDragStart();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tonDragOver={ scrollOnDragOver }\n\t\t\tonDragEnd={ () => {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t\tisDragging.current = false;\n\n\t\t\t\tstopScrolling();\n\n\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\tonDragEnd();\n\t\t\t\t}\n\t\t\t} }\n\t\t\t__experimentalDragComponent={\n\t\t\t\t// Check against `undefined` so that `null` can be used to disable\n\t\t\t\t// the default drag component.\n\t\t\t\tdragComponent !== undefined ? (\n\t\t\t\t\tdragComponent\n\t\t\t\t) : (\n\t\t\t\t\t<BlockDraggableChip\n\t\t\t\t\t\tcount={ clientIds.length }\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\tfadeWhenDisabled\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t\telementId={ elementId }\n\t\t>\n\t\t\t{ ( { onDraggableStart, onDraggableEnd } ) => {\n\t\t\t\treturn children( {\n\t\t\t\t\tdraggable: true,\n\t\t\t\t\tonDragStart: onDraggableStart,\n\t\t\t\t\tonDragEnd: onDraggableEnd,\n\t\t\t\t} );\n\t\t\t} }\n\t\t</Draggable>\n\t);\n};\n\nexport default BlockDraggable;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,SAAS,QAAQ,uBAAuB;AACjD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;AACtD,SAASC,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,OAAOC,kBAAkB,MAAM,kBAAkB;AACjD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@@ import { canBindBlock } from '../../../hooks/use-bindings-attributes';
46
46
  *
47
47
  * export default function Edit() {
48
48
  *
49
- * const blockProps = useBlockProps(
49
+ * const blockProps = useBlockProps( {
50
50
  * className: 'my-custom-class',
51
51
  * style: {
52
52
  * color: '#222222',
53
53
  * backgroundColor: '#eeeeee'
54
54
  * }
55
- * )
55
+ * } )
56
56
  *
57
57
  * return (
58
58
  * <div { ...blockProps }>
@@ -1 +1 @@
1
- {"version":3,"names":["clsx","useContext","__","sprintf","__unstableGetBlockProps","getBlockProps","useMergeRefs","useDisabled","warning","useMovingAnimation","PrivateBlockContext","useFocusFirstElement","useIsHovered","blockBindingsKey","useBlockEditContext","useFocusHandler","useEventHandlers","useNavModeExit","useBlockRefProvider","useIntersectionObserver","useScrollIntoView","useFlashEditableBlocks","canBindBlock","useBlockProps","props","__unstableIsHtml","clientId","className","wrapperProps","isAligned","index","mode","name","blockApiVersion","blockTitle","isSelected","isSubtreeDisabled","hasOverlay","initialPosition","blockEditingMode","isHighlighted","isMultiSelected","isPartiallySelected","isReusable","isDragging","hasChildSelected","isBlockMovingMode","canInsertMovingBlock","isEditingDisabled","hasEditableOutline","isTemporarilyEditingAsBlocks","defaultClassName","templateLock","blockLabel","htmlSuffix","mergedRefs","ref","triggerAnimationOnChange","isDisabled","isEnabled","blockEditContext","hasBlockBindings","bindingsStyle","globalThis","SCRIPT_DEBUG","hasNegativeMargin","style","marginTop","charAt","marginBottom","marginLeft","marginRight","tabIndex","id","role","inert","undefined","save"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { __unstableGetBlockProps as getBlockProps } from '@wordpress/blocks';\nimport { useMergeRefs, useDisabled } from '@wordpress/compose';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport useMovingAnimation from '../../use-moving-animation';\nimport { PrivateBlockContext } from '../private-block-context';\nimport { useFocusFirstElement } from './use-focus-first-element';\nimport { useIsHovered } from './use-is-hovered';\nimport {\n\tblockBindingsKey,\n\tuseBlockEditContext,\n} from '../../block-edit/context';\nimport { useFocusHandler } from './use-focus-handler';\nimport { useEventHandlers } from './use-selected-block-event-handlers';\nimport { useNavModeExit } from './use-nav-mode-exit';\nimport { useBlockRefProvider } from './use-block-refs';\nimport { useIntersectionObserver } from './use-intersection-observer';\nimport { useScrollIntoView } from './use-scroll-into-view';\nimport { useFlashEditableBlocks } from '../../use-flash-editable-blocks';\nimport { canBindBlock } from '../../../hooks/use-bindings-attributes';\n\n/**\n * This hook is used to lightly mark an element as a block element. The element\n * should be the outermost element of a block. Call this hook and pass the\n * returned props to the element to mark as a block. If you define a ref for the\n * element, it is important to pass the ref to this hook, which the hook in turn\n * will pass to the component through the props it returns. Optionally, you can\n * also pass any other props through this hook, and they will be merged and\n * returned.\n *\n * Use of this hook on the outermost element of a block is required if using API >= v2.\n *\n * @example\n * ```js\n * import { useBlockProps } from '@wordpress/block-editor';\n *\n * export default function Edit() {\n *\n * const blockProps = useBlockProps(\n * className: 'my-custom-class',\n * style: {\n * color: '#222222',\n * backgroundColor: '#eeeeee'\n * }\n * )\n *\n * return (\n *\t <div { ...blockProps }>\n *\n * </div>\n * )\n * }\n *\n * ```\n *\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Options for internal use only.\n * @param {boolean} options.__unstableIsHtml\n *\n * @return {Object} Props to pass to the element to mark as a block.\n */\nexport function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {\n\tconst {\n\t\tclientId,\n\t\tclassName,\n\t\twrapperProps = {},\n\t\tisAligned,\n\t\tindex,\n\t\tmode,\n\t\tname,\n\t\tblockApiVersion,\n\t\tblockTitle,\n\t\tisSelected,\n\t\tisSubtreeDisabled,\n\t\thasOverlay,\n\t\tinitialPosition,\n\t\tblockEditingMode,\n\t\tisHighlighted,\n\t\tisMultiSelected,\n\t\tisPartiallySelected,\n\t\tisReusable,\n\t\tisDragging,\n\t\thasChildSelected,\n\t\tisBlockMovingMode,\n\t\tcanInsertMovingBlock,\n\t\tisEditingDisabled,\n\t\thasEditableOutline,\n\t\tisTemporarilyEditingAsBlocks,\n\t\tdefaultClassName,\n\t\ttemplateLock,\n\t} = useContext( PrivateBlockContext );\n\n\t// translators: %s: Type of block (i.e. Text, Image etc)\n\tconst blockLabel = sprintf( __( 'Block: %s' ), blockTitle );\n\tconst htmlSuffix = mode === 'html' && ! __unstableIsHtml ? '-visual' : '';\n\tconst mergedRefs = useMergeRefs( [\n\t\tprops.ref,\n\t\tuseFocusFirstElement( { clientId, initialPosition } ),\n\t\tuseBlockRefProvider( clientId ),\n\t\tuseFocusHandler( clientId ),\n\t\tuseEventHandlers( { clientId, isSelected } ),\n\t\tuseNavModeExit( clientId ),\n\t\tuseIsHovered( { clientId } ),\n\t\tuseIntersectionObserver(),\n\t\tuseMovingAnimation( { triggerAnimationOnChange: index, clientId } ),\n\t\tuseDisabled( { isDisabled: ! hasOverlay } ),\n\t\tuseFlashEditableBlocks( {\n\t\t\tclientId,\n\t\t\tisEnabled: name === 'core/block' || templateLock === 'contentOnly',\n\t\t} ),\n\t\tuseScrollIntoView( { isSelected } ),\n\t] );\n\n\tconst blockEditContext = useBlockEditContext();\n\tconst hasBlockBindings = !! blockEditContext[ blockBindingsKey ];\n\tconst bindingsStyle =\n\t\thasBlockBindings && canBindBlock( name )\n\t\t\t? {\n\t\t\t\t\t'--wp-admin-theme-color': 'var(--wp-block-synced-color)',\n\t\t\t\t\t'--wp-admin-theme-color--rgb':\n\t\t\t\t\t\t'var(--wp-block-synced-color--rgb)',\n\t\t\t }\n\t\t\t: {};\n\n\t// Ensures it warns only inside the `edit` implementation for the block.\n\tif ( blockApiVersion < 2 && clientId === blockEditContext.clientId ) {\n\t\twarning(\n\t\t\t`Block type \"${ name }\" must support API version 2 or higher to work correctly with \"useBlockProps\" method.`\n\t\t);\n\t}\n\n\tlet hasNegativeMargin = false;\n\tif (\n\t\twrapperProps?.style?.marginTop?.charAt( 0 ) === '-' ||\n\t\twrapperProps?.style?.marginBottom?.charAt( 0 ) === '-' ||\n\t\twrapperProps?.style?.marginLeft?.charAt( 0 ) === '-' ||\n\t\twrapperProps?.style?.marginRight?.charAt( 0 ) === '-'\n\t) {\n\t\thasNegativeMargin = true;\n\t}\n\n\treturn {\n\t\ttabIndex: blockEditingMode === 'disabled' ? -1 : 0,\n\t\t...wrapperProps,\n\t\t...props,\n\t\tref: mergedRefs,\n\t\tid: `block-${ clientId }${ htmlSuffix }`,\n\t\trole: 'document',\n\t\t'aria-label': blockLabel,\n\t\t'data-block': clientId,\n\t\t'data-type': name,\n\t\t'data-title': blockTitle,\n\t\tinert: isSubtreeDisabled ? 'true' : undefined,\n\t\tclassName: clsx(\n\t\t\t'block-editor-block-list__block',\n\t\t\t{\n\t\t\t\t// The wp-block className is important for editor styles.\n\t\t\t\t'wp-block': ! isAligned,\n\t\t\t\t'has-block-overlay': hasOverlay,\n\t\t\t\t'is-selected': isSelected,\n\t\t\t\t'is-highlighted': isHighlighted,\n\t\t\t\t'is-multi-selected': isMultiSelected,\n\t\t\t\t'is-partially-selected': isPartiallySelected,\n\t\t\t\t'is-reusable': isReusable,\n\t\t\t\t'is-dragging': isDragging,\n\t\t\t\t'has-child-selected': hasChildSelected,\n\t\t\t\t'is-block-moving-mode': isBlockMovingMode,\n\t\t\t\t'can-insert-moving-block': canInsertMovingBlock,\n\t\t\t\t'is-editing-disabled': isEditingDisabled,\n\t\t\t\t'has-editable-outline': hasEditableOutline,\n\t\t\t\t'has-negative-margin': hasNegativeMargin,\n\t\t\t\t'is-content-locked-temporarily-editing-as-blocks':\n\t\t\t\t\tisTemporarilyEditingAsBlocks,\n\t\t\t},\n\t\t\tclassName,\n\t\t\tprops.className,\n\t\t\twrapperProps.className,\n\t\t\tdefaultClassName\n\t\t),\n\t\tstyle: { ...wrapperProps.style, ...props.style, ...bindingsStyle },\n\t};\n}\n\n/**\n * Call within a save function to get the props for the block wrapper.\n *\n * @param {Object} props Optional. Props to pass to the element.\n */\nuseBlockProps.save = getBlockProps;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,uBAAuB,IAAIC,aAAa,QAAQ,mBAAmB;AAC5E,SAASC,YAAY,EAAEC,WAAW,QAAQ,oBAAoB;AAC9D,OAAOC,OAAO,MAAM,oBAAoB;;AAExC;AACA;AACA;AACA,OAAOC,kBAAkB,MAAM,4BAA4B;AAC3D,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SACCC,gBAAgB,EAChBC,mBAAmB,QACb,0BAA0B;AACjC,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,gBAAgB,QAAQ,qCAAqC;AACtE,SAASC,cAAc,QAAQ,qBAAqB;AACpD,SAASC,mBAAmB,QAAQ,kBAAkB;AACtD,SAASC,uBAAuB,QAAQ,6BAA6B;AACrE,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,sBAAsB,QAAQ,iCAAiC;AACxE,SAASC,YAAY,QAAQ,wCAAwC;;AAErE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAAEC,KAAK,GAAG,CAAC,CAAC,EAAE;EAAEC;AAAiB,CAAC,GAAG,CAAC,CAAC,EAAG;EACtE,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W,EAAEM,IAAI;IACjB,YAAY,EAAEE,UAAU;IACxByC,KAAK,EAAEvC,iBAAiB,GAAG,MAAM,GAAGwC,SAAS;IAC7CjD,SAAS,EAAE3B,IAAI,CACd,gCAAgC,EAChC;MACC;MACA,UAAU,EAAE,CAAE6B,SAAS;MACvB,mBAAmB,EAAEQ,UAAU;MAC/B,aAAa,EAAEF,UAAU;MACzB,gBAAgB,EAAEK,aAAa;MAC/B,mBAAmB,EAAEC,eAAe;MACpC,uBAAuB,EAAEC,mBAAmB;MAC5C,aAAa,EAAEC,UAAU;MACzB,aAAa,EAAEC,UAAU;MACzB,oBAAoB,EAAEC,gBAAgB;MACtC,sBAAsB,EAAEC,iBAAiB;MACzC,yBAAyB,EAAEC,oBAAoB;MAC/C,qBAAqB,EAAEC,iBAAiB;MACxC,sBAAsB,EAAEC,kBAAkB;MAC1C,qBAAqB,EAAEgB,iBAAiB;MACxC,iDAAiD,EAChDf;IACF,CAAC,EACDvB,SAAS,EACTH,KAAK,CAACG,SAAS,EACfC,YAAY,CAACD,SAAS,EACtBwB,gBACD,CAAC;IACDe,KAAK,EAAE;MAAE,GAAGtC,YAAY,CAACsC,KAAK;MAAE,GAAG1C,KAAK,CAAC0C,KAAK;MAAE,GAAGJ;IAAc;EAClE,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACAvC,aAAa,CAACsD,IAAI,GAAGxE,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["clsx","useContext","__","sprintf","__unstableGetBlockProps","getBlockProps","useMergeRefs","useDisabled","warning","useMovingAnimation","PrivateBlockContext","useFocusFirstElement","useIsHovered","blockBindingsKey","useBlockEditContext","useFocusHandler","useEventHandlers","useNavModeExit","useBlockRefProvider","useIntersectionObserver","useScrollIntoView","useFlashEditableBlocks","canBindBlock","useBlockProps","props","__unstableIsHtml","clientId","className","wrapperProps","isAligned","index","mode","name","blockApiVersion","blockTitle","isSelected","isSubtreeDisabled","hasOverlay","initialPosition","blockEditingMode","isHighlighted","isMultiSelected","isPartiallySelected","isReusable","isDragging","hasChildSelected","isBlockMovingMode","canInsertMovingBlock","isEditingDisabled","hasEditableOutline","isTemporarilyEditingAsBlocks","defaultClassName","templateLock","blockLabel","htmlSuffix","mergedRefs","ref","triggerAnimationOnChange","isDisabled","isEnabled","blockEditContext","hasBlockBindings","bindingsStyle","globalThis","SCRIPT_DEBUG","hasNegativeMargin","style","marginTop","charAt","marginBottom","marginLeft","marginRight","tabIndex","id","role","inert","undefined","save"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { __unstableGetBlockProps as getBlockProps } from '@wordpress/blocks';\nimport { useMergeRefs, useDisabled } from '@wordpress/compose';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport useMovingAnimation from '../../use-moving-animation';\nimport { PrivateBlockContext } from '../private-block-context';\nimport { useFocusFirstElement } from './use-focus-first-element';\nimport { useIsHovered } from './use-is-hovered';\nimport {\n\tblockBindingsKey,\n\tuseBlockEditContext,\n} from '../../block-edit/context';\nimport { useFocusHandler } from './use-focus-handler';\nimport { useEventHandlers } from './use-selected-block-event-handlers';\nimport { useNavModeExit } from './use-nav-mode-exit';\nimport { useBlockRefProvider } from './use-block-refs';\nimport { useIntersectionObserver } from './use-intersection-observer';\nimport { useScrollIntoView } from './use-scroll-into-view';\nimport { useFlashEditableBlocks } from '../../use-flash-editable-blocks';\nimport { canBindBlock } from '../../../hooks/use-bindings-attributes';\n\n/**\n * This hook is used to lightly mark an element as a block element. The element\n * should be the outermost element of a block. Call this hook and pass the\n * returned props to the element to mark as a block. If you define a ref for the\n * element, it is important to pass the ref to this hook, which the hook in turn\n * will pass to the component through the props it returns. Optionally, you can\n * also pass any other props through this hook, and they will be merged and\n * returned.\n *\n * Use of this hook on the outermost element of a block is required if using API >= v2.\n *\n * @example\n * ```js\n * import { useBlockProps } from '@wordpress/block-editor';\n *\n * export default function Edit() {\n *\n * const blockProps = useBlockProps( {\n * className: 'my-custom-class',\n * style: {\n * color: '#222222',\n * backgroundColor: '#eeeeee'\n * }\n * } )\n *\n * return (\n *\t <div { ...blockProps }>\n *\n * </div>\n * )\n * }\n *\n * ```\n *\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Options for internal use only.\n * @param {boolean} options.__unstableIsHtml\n *\n * @return {Object} Props to pass to the element to mark as a block.\n */\nexport function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {\n\tconst {\n\t\tclientId,\n\t\tclassName,\n\t\twrapperProps = {},\n\t\tisAligned,\n\t\tindex,\n\t\tmode,\n\t\tname,\n\t\tblockApiVersion,\n\t\tblockTitle,\n\t\tisSelected,\n\t\tisSubtreeDisabled,\n\t\thasOverlay,\n\t\tinitialPosition,\n\t\tblockEditingMode,\n\t\tisHighlighted,\n\t\tisMultiSelected,\n\t\tisPartiallySelected,\n\t\tisReusable,\n\t\tisDragging,\n\t\thasChildSelected,\n\t\tisBlockMovingMode,\n\t\tcanInsertMovingBlock,\n\t\tisEditingDisabled,\n\t\thasEditableOutline,\n\t\tisTemporarilyEditingAsBlocks,\n\t\tdefaultClassName,\n\t\ttemplateLock,\n\t} = useContext( PrivateBlockContext );\n\n\t// translators: %s: Type of block (i.e. Text, Image etc)\n\tconst blockLabel = sprintf( __( 'Block: %s' ), blockTitle );\n\tconst htmlSuffix = mode === 'html' && ! __unstableIsHtml ? '-visual' : '';\n\tconst mergedRefs = useMergeRefs( [\n\t\tprops.ref,\n\t\tuseFocusFirstElement( { clientId, initialPosition } ),\n\t\tuseBlockRefProvider( clientId ),\n\t\tuseFocusHandler( clientId ),\n\t\tuseEventHandlers( { clientId, isSelected } ),\n\t\tuseNavModeExit( clientId ),\n\t\tuseIsHovered( { clientId } ),\n\t\tuseIntersectionObserver(),\n\t\tuseMovingAnimation( { triggerAnimationOnChange: index, clientId } ),\n\t\tuseDisabled( { isDisabled: ! hasOverlay } ),\n\t\tuseFlashEditableBlocks( {\n\t\t\tclientId,\n\t\t\tisEnabled: name === 'core/block' || templateLock === 'contentOnly',\n\t\t} ),\n\t\tuseScrollIntoView( { isSelected } ),\n\t] );\n\n\tconst blockEditContext = useBlockEditContext();\n\tconst hasBlockBindings = !! blockEditContext[ blockBindingsKey ];\n\tconst bindingsStyle =\n\t\thasBlockBindings && canBindBlock( name )\n\t\t\t? {\n\t\t\t\t\t'--wp-admin-theme-color': 'var(--wp-block-synced-color)',\n\t\t\t\t\t'--wp-admin-theme-color--rgb':\n\t\t\t\t\t\t'var(--wp-block-synced-color--rgb)',\n\t\t\t }\n\t\t\t: {};\n\n\t// Ensures it warns only inside the `edit` implementation for the block.\n\tif ( blockApiVersion < 2 && clientId === blockEditContext.clientId ) {\n\t\twarning(\n\t\t\t`Block type \"${ name }\" must support API version 2 or higher to work correctly with \"useBlockProps\" method.`\n\t\t);\n\t}\n\n\tlet hasNegativeMargin = false;\n\tif (\n\t\twrapperProps?.style?.marginTop?.charAt( 0 ) === '-' ||\n\t\twrapperProps?.style?.marginBottom?.charAt( 0 ) === '-' ||\n\t\twrapperProps?.style?.marginLeft?.charAt( 0 ) === '-' ||\n\t\twrapperProps?.style?.marginRight?.charAt( 0 ) === '-'\n\t) {\n\t\thasNegativeMargin = true;\n\t}\n\n\treturn {\n\t\ttabIndex: blockEditingMode === 'disabled' ? -1 : 0,\n\t\t...wrapperProps,\n\t\t...props,\n\t\tref: mergedRefs,\n\t\tid: `block-${ clientId }${ htmlSuffix }`,\n\t\trole: 'document',\n\t\t'aria-label': blockLabel,\n\t\t'data-block': clientId,\n\t\t'data-type': name,\n\t\t'data-title': blockTitle,\n\t\tinert: isSubtreeDisabled ? 'true' : undefined,\n\t\tclassName: clsx(\n\t\t\t'block-editor-block-list__block',\n\t\t\t{\n\t\t\t\t// The wp-block className is important for editor styles.\n\t\t\t\t'wp-block': ! isAligned,\n\t\t\t\t'has-block-overlay': hasOverlay,\n\t\t\t\t'is-selected': isSelected,\n\t\t\t\t'is-highlighted': isHighlighted,\n\t\t\t\t'is-multi-selected': isMultiSelected,\n\t\t\t\t'is-partially-selected': isPartiallySelected,\n\t\t\t\t'is-reusable': isReusable,\n\t\t\t\t'is-dragging': isDragging,\n\t\t\t\t'has-child-selected': hasChildSelected,\n\t\t\t\t'is-block-moving-mode': isBlockMovingMode,\n\t\t\t\t'can-insert-moving-block': canInsertMovingBlock,\n\t\t\t\t'is-editing-disabled': isEditingDisabled,\n\t\t\t\t'has-editable-outline': hasEditableOutline,\n\t\t\t\t'has-negative-margin': hasNegativeMargin,\n\t\t\t\t'is-content-locked-temporarily-editing-as-blocks':\n\t\t\t\t\tisTemporarilyEditingAsBlocks,\n\t\t\t},\n\t\t\tclassName,\n\t\t\tprops.className,\n\t\t\twrapperProps.className,\n\t\t\tdefaultClassName\n\t\t),\n\t\tstyle: { ...wrapperProps.style, ...props.style, ...bindingsStyle },\n\t};\n}\n\n/**\n * Call within a save function to get the props for the block wrapper.\n *\n * @param {Object} props Optional. Props to pass to the element.\n */\nuseBlockProps.save = getBlockProps;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,uBAAuB,IAAIC,aAAa,QAAQ,mBAAmB;AAC5E,SAASC,YAAY,EAAEC,WAAW,QAAQ,oBAAoB;AAC9D,OAAOC,OAAO,MAAM,oBAAoB;;AAExC;AACA;AACA;AACA,OAAOC,kBAAkB,MAAM,4BAA4B;AAC3D,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SACCC,gBAAgB,EAChBC,mBAAmB,QACb,0BA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S,EACfC,YAAY,CAACD,SAAS,EACtBwB,gBACD,CAAC;IACDe,KAAK,EAAE;MAAE,GAAGtC,YAAY,CAACsC,KAAK;MAAE,GAAG1C,KAAK,CAAC0C,KAAK;MAAE,GAAGJ;IAAc;EAClE,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACAvC,aAAa,CAACsD,IAAI,GAAGxE,aAAa","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { useContext, useMemo, useRef, useState, useLayoutEffect } from '@wordpress/element';
4
+ import { useContext, useState, useLayoutEffect } from '@wordpress/element';
5
5
  import { useRefEffect } from '@wordpress/compose';
6
6
 
7
7
  /**
@@ -10,7 +10,7 @@ import { useRefEffect } from '@wordpress/compose';
10
10
  import { BlockRefs } from '../../provider/block-refs-provider';
11
11
 
12
12
  /** @typedef {import('@wordpress/element').RefCallback} RefCallback */
13
- /** @typedef {import('@wordpress/element').RefObject} RefObject */
13
+ /** @typedef {import('@wordpress/element').Ref} Ref */
14
14
 
15
15
  /**
16
16
  * Provides a ref to the BlockRefs context.
@@ -28,32 +28,33 @@ export function useBlockRefProvider(clientId) {
28
28
  return () => refsMap.delete(clientId);
29
29
  }, [clientId]);
30
30
  }
31
+ function assignRef(ref, value) {
32
+ if (typeof ref === 'function') {
33
+ ref(value);
34
+ } else if (ref) {
35
+ ref.current = value;
36
+ }
37
+ }
31
38
 
32
39
  /**
33
- * Gets a ref pointing to the current block element. Continues to return the same
34
- * stable ref object even if the `clientId` argument changes. This hook is not
35
- * reactive, i.e., it won't trigger a rerender of the calling component if the
36
- * ref value changes. For reactive use cases there is the `useBlockElement` hook.
37
- *
38
- * @param {string} clientId The client ID to get a ref for.
40
+ * Tracks the DOM element for the block identified by `clientId` and assigns it to the `ref`
41
+ * whenever it changes.
39
42
  *
40
- * @return {RefObject} A ref containing the element.
43
+ * @param {string} clientId The client ID to track.
44
+ * @param {Ref} ref The ref object/callback to assign to.
41
45
  */
42
- function useBlockRef(clientId) {
46
+ export function useBlockElementRef(clientId, ref) {
43
47
  const {
44
48
  refsMap
45
49
  } = useContext(BlockRefs);
46
- const latestClientId = useRef();
47
- latestClientId.current = clientId;
48
-
49
- // Always return an object, even if no ref exists for a given client ID, so
50
- // that `current` works at a later point.
51
- return useMemo(() => ({
52
- get current() {
53
- var _refsMap$get;
54
- return (_refsMap$get = refsMap.get(latestClientId.current)) !== null && _refsMap$get !== void 0 ? _refsMap$get : null;
55
- }
56
- }), [refsMap]);
50
+ useLayoutEffect(() => {
51
+ assignRef(ref, refsMap.get(clientId));
52
+ const unsubscribe = refsMap.subscribe(clientId, () => assignRef(ref, refsMap.get(clientId)));
53
+ return () => {
54
+ unsubscribe();
55
+ assignRef(ref, null);
56
+ };
57
+ }, [refsMap, clientId, ref]);
57
58
  }
58
59
 
59
60
  /**
@@ -64,20 +65,9 @@ function useBlockRef(clientId) {
64
65
  *
65
66
  * @return {Element|null} The block's wrapper element.
66
67
  */
67
- function useBlockElement(clientId) {
68
- const {
69
- refsMap
70
- } = useContext(BlockRefs);
68
+ export function useBlockElement(clientId) {
71
69
  const [blockElement, setBlockElement] = useState(null);
72
- // Delay setting the resulting `blockElement` until an effect. If the block element
73
- // changes (i.e., the block is unmounted and re-mounted), this allows enough time
74
- // for the ref callbacks to clean up the old element and set the new one.
75
- useLayoutEffect(() => {
76
- setBlockElement(refsMap.get(clientId));
77
- return refsMap.subscribe(clientId, () => setBlockElement(refsMap.get(clientId)));
78
- }, [refsMap, clientId]);
70
+ useBlockElementRef(clientId, setBlockElement);
79
71
  return blockElement;
80
72
  }
81
- export { useBlockRef as __unstableUseBlockRef };
82
- export { useBlockElement as __unstableUseBlockElement };
83
73
  //# sourceMappingURL=use-block-refs.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useContext","useMemo","useRef","useState","useLayoutEffect","useRefEffect","BlockRefs","useBlockRefProvider","clientId","refsMap","element","set","delete","useBlockRef","latestClientId","current","_refsMap$get","get","useBlockElement","blockElement","setBlockElement","subscribe","__unstableUseBlockRef","__unstableUseBlockElement"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-block-refs.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseContext,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { BlockRefs } from '../../provider/block-refs-provider';\n\n/** @typedef {import('@wordpress/element').RefCallback} RefCallback */\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\n/**\n * Provides a ref to the BlockRefs context.\n *\n * @param {string} clientId The client ID of the element ref.\n *\n * @return {RefCallback} Ref callback.\n */\nexport function useBlockRefProvider( clientId ) {\n\tconst { refsMap } = useContext( BlockRefs );\n\treturn useRefEffect(\n\t\t( element ) => {\n\t\t\trefsMap.set( clientId, element );\n\t\t\treturn () => refsMap.delete( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n\n/**\n * Gets a ref pointing to the current block element. Continues to return the same\n * stable ref object even if the `clientId` argument changes. This hook is not\n * reactive, i.e., it won't trigger a rerender of the calling component if the\n * ref value changes. For reactive use cases there is the `useBlockElement` hook.\n *\n * @param {string} clientId The client ID to get a ref for.\n *\n * @return {RefObject} A ref containing the element.\n */\nfunction useBlockRef( clientId ) {\n\tconst { refsMap } = useContext( BlockRefs );\n\tconst latestClientId = useRef();\n\tlatestClientId.current = clientId;\n\n\t// Always return an object, even if no ref exists for a given client ID, so\n\t// that `current` works at a later point.\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tget current() {\n\t\t\t\treturn refsMap.get( latestClientId.current ) ?? null;\n\t\t\t},\n\t\t} ),\n\t\t[ refsMap ]\n\t);\n}\n\n/**\n * Return the element for a given client ID. Updates whenever the element\n * changes, becomes available, or disappears.\n *\n * @param {string} clientId The client ID to an element for.\n *\n * @return {Element|null} The block's wrapper element.\n */\nfunction useBlockElement( clientId ) {\n\tconst { refsMap } = useContext( BlockRefs );\n\tconst [ blockElement, setBlockElement ] = useState( null );\n\t// Delay setting the resulting `blockElement` until an effect. If the block element\n\t// changes (i.e., the block is unmounted and re-mounted), this allows enough time\n\t// for the ref callbacks to clean up the old element and set the new one.\n\tuseLayoutEffect( () => {\n\t\tsetBlockElement( refsMap.get( clientId ) );\n\t\treturn refsMap.subscribe( clientId, () =>\n\t\t\tsetBlockElement( refsMap.get( clientId ) )\n\t\t);\n\t}, [ refsMap, clientId ] );\n\treturn blockElement;\n}\n\nexport { useBlockRef as __unstableUseBlockRef };\nexport { useBlockElement as __unstableUseBlockElement };\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,UAAU,EACVC,OAAO,EACPC,MAAM,EACNC,QAAQ,EACRC,eAAe,QACT,oBAAoB;AAC3B,SAASC,YAAY,QAAQ,oBAAoB;;AAEjD;AACA;AACA;AACA,SAASC,SAAS,QAAQ,oCAAoC;;AAE9D;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAEC,QAAQ,EAAG;EAC/C,MAAM;IAAEC;EAAQ,CAAC,GAAGT,UAAU,CAAEM,SAAU,CAAC;EAC3C,OAAOD,YAAY,CAChBK,OAAO,IAAM;IACdD,OAAO,CAACE,GAAG,CAAEH,QAAQ,EAAEE,OAAQ,CAAC;IAChC,OAAO,MAAMD,OAAO,CAACG,MAAM,CAAEJ,QAAS,CAAC;EACxC,CAAC,EACD,CAAEA,QAAQ,CACX,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASK,WAAWA,CAAEL,QAAQ,EAAG;EAChC,MAAM;IAAEC;EAAQ,CAAC,GAAGT,UAAU,CAAEM,SAAU,CAAC;EAC3C,MAAMQ,cAAc,GAAGZ,MAAM,CAAC,CAAC;EAC/BY,cAAc,CAACC,OAAO,GAAGP,QAAQ;;EAEjC;EACA;EACA,OAAOP,OAAO,CACb,OAAQ;IACP,IAAIc,OAAOA,CAAA,EAAG;MAAA,IAAAC,YAAA;MACb,QAAAA,YAAA,GAAOP,OAAO,CAACQ,GAAG,CAAEH,cAAc,CAACC,OAAQ,CAAC,cAAAC,YAAA,cAAAA,YAAA,GAAI,IAAI;IACrD;EACD,CAAC,CAAE,EACH,CAAEP,OAAO,CACV,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASS,eAAeA,CAAEV,QAAQ,EAAG;EACpC,MAAM;IAAEC;EAAQ,CAAC,GAAGT,UAAU,CAAEM,SAAU,CAAC;EAC3C,MAAM,CAAEa,YAAY,EAAEC,eAAe,CAAE,GAAGjB,QAAQ,CAAE,IAAK,CAAC;EAC1D;EACA;EACA;EACAC,eAAe,CAAE,MAAM;IACtBgB,eAAe,CAAEX,OAAO,CAACQ,GAAG,CAAET,QAAS,CAAE,CAAC;IAC1C,OAAOC,OAAO,CAACY,SAAS,CAAEb,QAAQ,EAAE,MACnCY,eAAe,CAAEX,OAAO,CAACQ,GAAG,CAAET,QAAS,CAAE,CAC1C,CAAC;EACF,CAAC,EAAE,CAAEC,OAAO,EAAED,QAAQ,CAAG,CAAC;EAC1B,OAAOW,YAAY;AACpB;AAEA,SAASN,WAAW,IAAIS,qBAAqB;AAC7C,SAASJ,eAAe,IAAIK,yBAAyB","ignoreList":[]}
1
+ {"version":3,"names":["useContext","useState","useLayoutEffect","useRefEffect","BlockRefs","useBlockRefProvider","clientId","refsMap","element","set","delete","assignRef","ref","value","current","useBlockElementRef","get","unsubscribe","subscribe","useBlockElement","blockElement","setBlockElement"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-block-refs.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext, useState, useLayoutEffect } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { BlockRefs } from '../../provider/block-refs-provider';\n\n/** @typedef {import('@wordpress/element').RefCallback} RefCallback */\n/** @typedef {import('@wordpress/element').Ref} Ref */\n\n/**\n * Provides a ref to the BlockRefs context.\n *\n * @param {string} clientId The client ID of the element ref.\n *\n * @return {RefCallback} Ref callback.\n */\nexport function useBlockRefProvider( clientId ) {\n\tconst { refsMap } = useContext( BlockRefs );\n\treturn useRefEffect(\n\t\t( element ) => {\n\t\t\trefsMap.set( clientId, element );\n\t\t\treturn () => refsMap.delete( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n\nfunction assignRef( ref, value ) {\n\tif ( typeof ref === 'function' ) {\n\t\tref( value );\n\t} else if ( ref ) {\n\t\tref.current = value;\n\t}\n}\n\n/**\n * Tracks the DOM element for the block identified by `clientId` and assigns it to the `ref`\n * whenever it changes.\n *\n * @param {string} clientId The client ID to track.\n * @param {Ref} ref The ref object/callback to assign to.\n */\nexport function useBlockElementRef( clientId, ref ) {\n\tconst { refsMap } = useContext( BlockRefs );\n\tuseLayoutEffect( () => {\n\t\tassignRef( ref, refsMap.get( clientId ) );\n\t\tconst unsubscribe = refsMap.subscribe( clientId, () =>\n\t\t\tassignRef( ref, refsMap.get( clientId ) )\n\t\t);\n\t\treturn () => {\n\t\t\tunsubscribe();\n\t\t\tassignRef( ref, null );\n\t\t};\n\t}, [ refsMap, clientId, ref ] );\n}\n\n/**\n * Return the element for a given client ID. Updates whenever the element\n * changes, becomes available, or disappears.\n *\n * @param {string} clientId The client ID to an element for.\n *\n * @return {Element|null} The block's wrapper element.\n */\nexport function useBlockElement( clientId ) {\n\tconst [ blockElement, setBlockElement ] = useState( null );\n\tuseBlockElementRef( clientId, setBlockElement );\n\treturn blockElement;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,eAAe,QAAQ,oBAAoB;AAC1E,SAASC,YAAY,QAAQ,oBAAoB;;AAEjD;AACA;AACA;AACA,SAASC,SAAS,QAAQ,oCAAoC;;AAE9D;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;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