@wordpress/block-editor 14.1.0 → 14.2.1-next.1f6eadc42.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 (705) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +1 -10
  3. package/build/components/block-alignment-matrix-control/index.js +2 -2
  4. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  5. package/build/components/block-breadcrumb/index.js +2 -2
  6. package/build/components/block-breadcrumb/index.js.map +1 -1
  7. package/build/components/block-canvas/index.js +8 -1
  8. package/build/components/block-canvas/index.js.map +1 -1
  9. package/build/components/block-compare/block-view.js +1 -0
  10. package/build/components/block-compare/block-view.js.map +1 -1
  11. package/build/components/block-draggable/index.js +4 -4
  12. package/build/components/block-draggable/index.js.map +1 -1
  13. package/build/components/block-draggable/use-scroll-when-dragging.js +25 -25
  14. package/build/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
  15. package/build/components/block-edit/multiple-usage-warning.js +2 -0
  16. package/build/components/block-edit/multiple-usage-warning.js.map +1 -1
  17. package/build/components/block-inspector/index.js +27 -11
  18. package/build/components/block-inspector/index.js.map +1 -1
  19. package/build/components/block-list/block-invalid-warning.js +3 -2
  20. package/build/components/block-list/block-invalid-warning.js.map +1 -1
  21. package/build/components/block-list/block.js +5 -1
  22. package/build/components/block-list/block.js.map +1 -1
  23. package/build/components/block-list/index.js +14 -3
  24. package/build/components/block-list/index.js.map +1 -1
  25. package/build/components/block-list/use-block-props/index.js +5 -1
  26. package/build/components/block-list/use-block-props/index.js.map +1 -1
  27. package/build/components/block-list/use-block-props/use-focus-first-element.js +1 -0
  28. package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  29. package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js +53 -0
  30. package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -0
  31. package/build/components/block-list/zoom-out-separator.js +98 -0
  32. package/build/components/block-list/zoom-out-separator.js.map +1 -0
  33. package/build/components/block-lock/toolbar.js +3 -3
  34. package/build/components/block-lock/toolbar.js.map +1 -1
  35. package/build/components/block-mover/button.js +1 -0
  36. package/build/components/block-mover/button.js.map +1 -1
  37. package/build/components/block-mover/index.js +1 -0
  38. package/build/components/block-mover/index.js.map +1 -1
  39. package/build/components/block-navigation/dropdown.js +4 -1
  40. package/build/components/block-navigation/dropdown.js.map +1 -1
  41. package/build/components/block-pattern-setup/index.js +2 -10
  42. package/build/components/block-pattern-setup/index.js.map +1 -1
  43. package/build/components/block-pattern-setup/setup-toolbar.js +22 -7
  44. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  45. package/build/components/block-patterns-list/index.js +12 -20
  46. package/build/components/block-patterns-list/index.js.map +1 -1
  47. package/build/components/block-patterns-paging/index.js +12 -3
  48. package/build/components/block-patterns-paging/index.js.map +1 -1
  49. package/build/components/block-popover/index.js +2 -15
  50. package/build/components/block-popover/index.js.map +1 -1
  51. package/build/components/block-quick-navigation/index.js +4 -1
  52. package/build/components/block-quick-navigation/index.js.map +1 -1
  53. package/build/components/block-settings-menu-controls/index.js +4 -0
  54. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  55. package/build/components/block-switcher/index.js +30 -19
  56. package/build/components/block-switcher/index.js.map +1 -1
  57. package/build/components/block-switcher/pattern-transformations-menu.js +2 -10
  58. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  59. package/build/components/block-toolbar/index.js +19 -12
  60. package/build/components/block-toolbar/index.js.map +1 -1
  61. package/build/components/block-toolbar/shuffle.js +6 -2
  62. package/build/components/block-toolbar/shuffle.js.map +1 -1
  63. package/build/components/block-tools/block-selection-button.js +8 -2
  64. package/build/components/block-tools/block-selection-button.js.map +1 -1
  65. package/build/components/block-tools/block-toolbar-popover.js +10 -6
  66. package/build/components/block-tools/block-toolbar-popover.js.map +1 -1
  67. package/build/components/block-tools/index.js +1 -1
  68. package/build/components/block-tools/index.js.map +1 -1
  69. package/build/components/block-tools/use-block-toolbar-popover-props.js +2 -1
  70. package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  71. package/build/components/block-tools/zoom-out-mode-inserters.js +7 -21
  72. package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  73. package/build/components/block-tools/zoom-out-popover.js +3 -4
  74. package/build/components/block-tools/zoom-out-popover.js.map +1 -1
  75. package/build/components/block-tools/zoom-out-toolbar.js +26 -7
  76. package/build/components/block-tools/zoom-out-toolbar.js.map +1 -1
  77. package/build/components/block-variation-picker/index.js +4 -1
  78. package/build/components/block-variation-picker/index.js.map +1 -1
  79. package/build/components/block-variation-transforms/index.js +4 -1
  80. package/build/components/block-variation-transforms/index.js.map +1 -1
  81. package/build/components/button-block-appender/index.js +20 -23
  82. package/build/components/button-block-appender/index.js.map +1 -1
  83. package/build/components/colors-gradients/dropdown.js +4 -1
  84. package/build/components/colors-gradients/dropdown.js.map +1 -1
  85. package/build/components/content-lock/index.js +13 -0
  86. package/build/components/content-lock/index.js.map +1 -0
  87. package/build/components/content-lock/modify-content-lock-menu-item.js +64 -0
  88. package/build/components/content-lock/modify-content-lock-menu-item.js.map +1 -0
  89. package/build/components/editor-styles/index.js +4 -3
  90. package/build/components/editor-styles/index.js.map +1 -1
  91. package/build/components/global-styles/background-panel.js +8 -12
  92. package/build/components/global-styles/background-panel.js.map +1 -1
  93. package/build/components/global-styles/color-panel.js +8 -5
  94. package/build/components/global-styles/color-panel.js.map +1 -1
  95. package/build/components/global-styles/color-panel.native.js +1 -1
  96. package/build/components/global-styles/color-panel.native.js.map +1 -1
  97. package/build/components/global-styles/dimensions-panel.js +34 -37
  98. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  99. package/build/components/global-styles/filters-panel.js +4 -1
  100. package/build/components/global-styles/filters-panel.js.map +1 -1
  101. package/build/components/global-styles/shadow-panel-components.js +14 -17
  102. package/build/components/global-styles/shadow-panel-components.js.map +1 -1
  103. package/build/components/global-styles/typography-utils.js +17 -6
  104. package/build/components/global-styles/typography-utils.js.map +1 -1
  105. package/build/components/global-styles/utils.js +4 -6
  106. package/build/components/global-styles/utils.js.map +1 -1
  107. package/build/components/grid/grid-item-movers.js +2 -2
  108. package/build/components/grid/grid-item-movers.js.map +1 -1
  109. package/build/components/grid/grid-item-resizer.js +2 -2
  110. package/build/components/grid/grid-item-resizer.js.map +1 -1
  111. package/build/components/iframe/get-compatibility-styles.js +1 -1
  112. package/build/components/iframe/get-compatibility-styles.js.map +1 -1
  113. package/build/components/iframe/index.js +5 -5
  114. package/build/components/iframe/index.js.map +1 -1
  115. package/build/components/inner-blocks/index.js +2 -4
  116. package/build/components/inner-blocks/index.js.map +1 -1
  117. package/build/components/inner-blocks/use-inner-block-template-sync.js +3 -3
  118. package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  119. package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +4 -1
  120. package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -1
  121. package/build/components/inserter/block-patterns-tab/index.js +4 -1
  122. package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
  123. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +23 -13
  124. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  125. package/build/components/inserter/index.js +4 -11
  126. package/build/components/inserter/index.js.map +1 -1
  127. package/build/components/inserter/library.js +2 -4
  128. package/build/components/inserter/library.js.map +1 -1
  129. package/build/components/inserter/media-tab/hooks.js +3 -3
  130. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  131. package/build/components/inserter/media-tab/media-list.js +1 -8
  132. package/build/components/inserter/media-tab/media-list.js.map +1 -1
  133. package/build/components/inserter/media-tab/media-preview.js +9 -7
  134. package/build/components/inserter/media-tab/media-preview.js.map +1 -1
  135. package/build/components/inserter/media-tab/media-tab.js +4 -1
  136. package/build/components/inserter/media-tab/media-tab.js.map +1 -1
  137. package/build/components/inserter/menu.js +7 -24
  138. package/build/components/inserter/menu.js.map +1 -1
  139. package/build/components/inserter/quick-inserter.js +4 -5
  140. package/build/components/inserter/quick-inserter.js.map +1 -1
  141. package/build/components/inserter-list-item/index.js +4 -4
  142. package/build/components/inserter-list-item/index.js.map +1 -1
  143. package/build/components/inserter-listbox/index.js +3 -13
  144. package/build/components/inserter-listbox/index.js.map +1 -1
  145. package/build/components/inserter-listbox/item.js +6 -11
  146. package/build/components/inserter-listbox/item.js.map +1 -1
  147. package/build/components/inserter-listbox/row.js +1 -9
  148. package/build/components/inserter-listbox/row.js.map +1 -1
  149. package/build/components/inspector-controls/groups.js +2 -0
  150. package/build/components/inspector-controls/groups.js.map +1 -1
  151. package/build/components/inspector-controls-tabs/index.js +4 -1
  152. package/build/components/inspector-controls-tabs/index.js.map +1 -1
  153. package/build/components/inspector-controls-tabs/settings-tab.js +3 -1
  154. package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  155. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +2 -1
  156. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  157. package/build/components/inspector-popover-header/index.js +8 -2
  158. package/build/components/inspector-popover-header/index.js.map +1 -1
  159. package/build/components/letter-spacing-control/index.js +7 -4
  160. package/build/components/letter-spacing-control/index.js.map +1 -1
  161. package/build/components/link-control/index.js +19 -10
  162. package/build/components/link-control/index.js.map +1 -1
  163. package/build/components/link-control/settings-drawer.js +4 -1
  164. package/build/components/link-control/settings-drawer.js.map +1 -1
  165. package/build/components/list-view/block-select-button.js +4 -1
  166. package/build/components/list-view/block-select-button.js.map +1 -1
  167. package/build/components/list-view/index.js +3 -7
  168. package/build/components/list-view/index.js.map +1 -1
  169. package/build/components/media-placeholder/index.js +32 -11
  170. package/build/components/media-placeholder/index.js.map +1 -1
  171. package/build/components/media-replace-flow/index.js +8 -1
  172. package/build/components/media-replace-flow/index.js.map +1 -1
  173. package/build/components/provider/use-block-sync.js +19 -19
  174. package/build/components/provider/use-block-sync.js.map +1 -1
  175. package/build/components/rich-text/event-listeners/paste-handler.js +12 -1
  176. package/build/components/rich-text/event-listeners/paste-handler.js.map +1 -1
  177. package/build/components/rich-text/index.js +38 -30
  178. package/build/components/rich-text/index.js.map +1 -1
  179. package/build/components/rich-text/use-mark-persistent.js +5 -5
  180. package/build/components/rich-text/use-mark-persistent.js.map +1 -1
  181. package/build/components/skip-to-selected-block/index.js +4 -1
  182. package/build/components/skip-to-selected-block/index.js.map +1 -1
  183. package/build/components/spacing-sizes-control/index.js +8 -9
  184. package/build/components/spacing-sizes-control/index.js.map +1 -1
  185. package/build/components/spacing-sizes-control/linked-button.js +35 -0
  186. package/build/components/spacing-sizes-control/linked-button.js.map +1 -0
  187. package/build/components/spacing-sizes-control/utils.js +4 -15
  188. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  189. package/build/components/tool-selector/index.js +4 -1
  190. package/build/components/tool-selector/index.js.map +1 -1
  191. package/build/components/url-input/button.js +12 -3
  192. package/build/components/url-input/button.js.map +1 -1
  193. package/build/components/url-input/index.js +4 -1
  194. package/build/components/url-input/index.js.map +1 -1
  195. package/build/components/use-block-drop-zone/index.js +31 -7
  196. package/build/components/use-block-drop-zone/index.js.map +1 -1
  197. package/build/components/writing-flow/index.js +2 -1
  198. package/build/components/writing-flow/index.js.map +1 -1
  199. package/build/components/writing-flow/use-arrow-nav.js +4 -1
  200. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  201. package/build/components/writing-flow/use-event-redirect.js +66 -0
  202. package/build/components/writing-flow/use-event-redirect.js.map +1 -0
  203. package/build/components/writing-flow/use-input.js +31 -1
  204. package/build/components/writing-flow/use-input.js.map +1 -1
  205. package/build/components/writing-flow/use-select-all.js +14 -1
  206. package/build/components/writing-flow/use-select-all.js.map +1 -1
  207. package/build/components/writing-flow/use-selection-observer.js +20 -6
  208. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  209. package/build/components/writing-flow/use-tab-nav.js +4 -4
  210. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  211. package/build/components/writing-flow/utils.js +27 -0
  212. package/build/components/writing-flow/utils.js.map +1 -1
  213. package/build/hooks/block-bindings.js +33 -29
  214. package/build/hooks/block-bindings.js.map +1 -1
  215. package/build/hooks/content-lock-ui.js +8 -26
  216. package/build/hooks/content-lock-ui.js.map +1 -1
  217. package/build/hooks/duotone.js +0 -4
  218. package/build/hooks/duotone.js.map +1 -1
  219. package/build/hooks/layout.js +4 -2
  220. package/build/hooks/layout.js.map +1 -1
  221. package/build/hooks/spacing-visualizer.js +3 -3
  222. package/build/hooks/spacing-visualizer.js.map +1 -1
  223. package/build/hooks/style.js +1 -5
  224. package/build/hooks/style.js.map +1 -1
  225. package/build/hooks/use-bindings-attributes.js +19 -20
  226. package/build/hooks/use-bindings-attributes.js.map +1 -1
  227. package/build/hooks/use-zoom-out.js +7 -7
  228. package/build/hooks/use-zoom-out.js.map +1 -1
  229. package/build/layouts/constrained.js +41 -42
  230. package/build/layouts/constrained.js.map +1 -1
  231. package/build/layouts/flex.js +4 -1
  232. package/build/layouts/flex.js.map +1 -1
  233. package/build/layouts/grid.js +19 -16
  234. package/build/layouts/grid.js.map +1 -1
  235. package/build/layouts/utils.js +1 -7
  236. package/build/layouts/utils.js.map +1 -1
  237. package/build/private-apis.js +2 -3
  238. package/build/private-apis.js.map +1 -1
  239. package/build/store/actions.js +2 -7
  240. package/build/store/actions.js.map +1 -1
  241. package/build/store/private-actions.js +1 -0
  242. package/build/store/private-actions.js.map +1 -1
  243. package/build/store/private-keys.js +2 -1
  244. package/build/store/private-keys.js.map +1 -1
  245. package/build/store/private-selectors.js +16 -18
  246. package/build/store/private-selectors.js.map +1 -1
  247. package/build/store/reducer.js +1 -10
  248. package/build/store/reducer.js.map +1 -1
  249. package/build/store/selectors.js +19 -43
  250. package/build/store/selectors.js.map +1 -1
  251. package/build/store/utils.js +48 -0
  252. package/build/store/utils.js.map +1 -1
  253. package/build/utils/block-bindings.js +16 -11
  254. package/build/utils/block-bindings.js.map +1 -1
  255. package/build/utils/dom.js +101 -0
  256. package/build/utils/dom.js.map +1 -1
  257. package/build/utils/get-font-styles-and-weights.js +4 -4
  258. package/build/utils/get-font-styles-and-weights.js.map +1 -1
  259. package/build/utils/transform-styles/index.js +120 -16
  260. package/build/utils/transform-styles/index.js.map +1 -1
  261. package/build-module/components/block-alignment-matrix-control/index.js +1 -1
  262. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  263. package/build-module/components/block-breadcrumb/index.js +2 -2
  264. package/build-module/components/block-breadcrumb/index.js.map +1 -1
  265. package/build-module/components/block-canvas/index.js +9 -1
  266. package/build-module/components/block-canvas/index.js.map +1 -1
  267. package/build-module/components/block-compare/block-view.js +1 -0
  268. package/build-module/components/block-compare/block-view.js.map +1 -1
  269. package/build-module/components/block-draggable/index.js +4 -4
  270. package/build-module/components/block-draggable/index.js.map +1 -1
  271. package/build-module/components/block-draggable/use-scroll-when-dragging.js +25 -25
  272. package/build-module/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
  273. package/build-module/components/block-edit/multiple-usage-warning.js +2 -0
  274. package/build-module/components/block-edit/multiple-usage-warning.js.map +1 -1
  275. package/build-module/components/block-inspector/index.js +27 -11
  276. package/build-module/components/block-inspector/index.js.map +1 -1
  277. package/build-module/components/block-list/block-invalid-warning.js +3 -2
  278. package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
  279. package/build-module/components/block-list/block.js +5 -1
  280. package/build-module/components/block-list/block.js.map +1 -1
  281. package/build-module/components/block-list/index.js +14 -3
  282. package/build-module/components/block-list/index.js.map +1 -1
  283. package/build-module/components/block-list/use-block-props/index.js +5 -1
  284. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  285. package/build-module/components/block-list/use-block-props/use-focus-first-element.js +1 -0
  286. package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  287. package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js +47 -0
  288. package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -0
  289. package/build-module/components/block-list/zoom-out-separator.js +90 -0
  290. package/build-module/components/block-list/zoom-out-separator.js.map +1 -0
  291. package/build-module/components/block-lock/toolbar.js +3 -3
  292. package/build-module/components/block-lock/toolbar.js.map +1 -1
  293. package/build-module/components/block-mover/button.js +1 -0
  294. package/build-module/components/block-mover/button.js.map +1 -1
  295. package/build-module/components/block-mover/index.js +1 -0
  296. package/build-module/components/block-mover/index.js.map +1 -1
  297. package/build-module/components/block-navigation/dropdown.js +4 -1
  298. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  299. package/build-module/components/block-pattern-setup/index.js +2 -10
  300. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  301. package/build-module/components/block-pattern-setup/setup-toolbar.js +23 -8
  302. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  303. package/build-module/components/block-patterns-list/index.js +12 -20
  304. package/build-module/components/block-patterns-list/index.js.map +1 -1
  305. package/build-module/components/block-patterns-paging/index.js +12 -3
  306. package/build-module/components/block-patterns-paging/index.js.map +1 -1
  307. package/build-module/components/block-popover/index.js +2 -15
  308. package/build-module/components/block-popover/index.js.map +1 -1
  309. package/build-module/components/block-quick-navigation/index.js +4 -1
  310. package/build-module/components/block-quick-navigation/index.js.map +1 -1
  311. package/build-module/components/block-settings-menu-controls/index.js +4 -0
  312. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  313. package/build-module/components/block-switcher/index.js +30 -19
  314. package/build-module/components/block-switcher/index.js.map +1 -1
  315. package/build-module/components/block-switcher/pattern-transformations-menu.js +2 -10
  316. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  317. package/build-module/components/block-toolbar/index.js +19 -12
  318. package/build-module/components/block-toolbar/index.js.map +1 -1
  319. package/build-module/components/block-toolbar/shuffle.js +6 -2
  320. package/build-module/components/block-toolbar/shuffle.js.map +1 -1
  321. package/build-module/components/block-tools/block-selection-button.js +8 -2
  322. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  323. package/build-module/components/block-tools/block-toolbar-popover.js +10 -6
  324. package/build-module/components/block-tools/block-toolbar-popover.js.map +1 -1
  325. package/build-module/components/block-tools/index.js +1 -1
  326. package/build-module/components/block-tools/index.js.map +1 -1
  327. package/build-module/components/block-tools/use-block-toolbar-popover-props.js +2 -1
  328. package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  329. package/build-module/components/block-tools/zoom-out-mode-inserters.js +7 -22
  330. package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  331. package/build-module/components/block-tools/zoom-out-popover.js +3 -4
  332. package/build-module/components/block-tools/zoom-out-popover.js.map +1 -1
  333. package/build-module/components/block-tools/zoom-out-toolbar.js +27 -8
  334. package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -1
  335. package/build-module/components/block-variation-picker/index.js +4 -1
  336. package/build-module/components/block-variation-picker/index.js.map +1 -1
  337. package/build-module/components/block-variation-transforms/index.js +4 -1
  338. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  339. package/build-module/components/button-block-appender/index.js +22 -26
  340. package/build-module/components/button-block-appender/index.js.map +1 -1
  341. package/build-module/components/colors-gradients/dropdown.js +4 -1
  342. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  343. package/build-module/components/content-lock/index.js +2 -0
  344. package/build-module/components/content-lock/index.js.map +1 -0
  345. package/build-module/components/content-lock/modify-content-lock-menu-item.js +57 -0
  346. package/build-module/components/content-lock/modify-content-lock-menu-item.js.map +1 -0
  347. package/build-module/components/editor-styles/index.js +4 -3
  348. package/build-module/components/editor-styles/index.js.map +1 -1
  349. package/build-module/components/global-styles/background-panel.js +8 -12
  350. package/build-module/components/global-styles/background-panel.js.map +1 -1
  351. package/build-module/components/global-styles/color-panel.js +7 -4
  352. package/build-module/components/global-styles/color-panel.js.map +1 -1
  353. package/build-module/components/global-styles/color-panel.native.js +2 -2
  354. package/build-module/components/global-styles/color-panel.native.js.map +1 -1
  355. package/build-module/components/global-styles/dimensions-panel.js +36 -39
  356. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  357. package/build-module/components/global-styles/filters-panel.js +4 -1
  358. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  359. package/build-module/components/global-styles/shadow-panel-components.js +14 -17
  360. package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
  361. package/build-module/components/global-styles/typography-utils.js +17 -6
  362. package/build-module/components/global-styles/typography-utils.js.map +1 -1
  363. package/build-module/components/global-styles/utils.js +4 -6
  364. package/build-module/components/global-styles/utils.js.map +1 -1
  365. package/build-module/components/grid/grid-item-movers.js +3 -3
  366. package/build-module/components/grid/grid-item-movers.js.map +1 -1
  367. package/build-module/components/grid/grid-item-resizer.js +2 -2
  368. package/build-module/components/grid/grid-item-resizer.js.map +1 -1
  369. package/build-module/components/iframe/get-compatibility-styles.js +1 -1
  370. package/build-module/components/iframe/get-compatibility-styles.js.map +1 -1
  371. package/build-module/components/iframe/index.js +5 -5
  372. package/build-module/components/iframe/index.js.map +1 -1
  373. package/build-module/components/inner-blocks/index.js +2 -4
  374. package/build-module/components/inner-blocks/index.js.map +1 -1
  375. package/build-module/components/inner-blocks/use-inner-block-template-sync.js +3 -3
  376. package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  377. package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +4 -1
  378. package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -1
  379. package/build-module/components/inserter/block-patterns-tab/index.js +4 -1
  380. package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
  381. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +23 -13
  382. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  383. package/build-module/components/inserter/index.js +4 -11
  384. package/build-module/components/inserter/index.js.map +1 -1
  385. package/build-module/components/inserter/library.js +2 -4
  386. package/build-module/components/inserter/library.js.map +1 -1
  387. package/build-module/components/inserter/media-tab/hooks.js +3 -3
  388. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  389. package/build-module/components/inserter/media-tab/media-list.js +1 -8
  390. package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
  391. package/build-module/components/inserter/media-tab/media-preview.js +10 -8
  392. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
  393. package/build-module/components/inserter/media-tab/media-tab.js +4 -1
  394. package/build-module/components/inserter/media-tab/media-tab.js.map +1 -1
  395. package/build-module/components/inserter/menu.js +7 -24
  396. package/build-module/components/inserter/menu.js.map +1 -1
  397. package/build-module/components/inserter/quick-inserter.js +5 -6
  398. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  399. package/build-module/components/inserter-list-item/index.js +4 -4
  400. package/build-module/components/inserter-list-item/index.js.map +1 -1
  401. package/build-module/components/inserter-listbox/index.js +3 -11
  402. package/build-module/components/inserter-listbox/index.js.map +1 -1
  403. package/build-module/components/inserter-listbox/item.js +7 -12
  404. package/build-module/components/inserter-listbox/item.js.map +1 -1
  405. package/build-module/components/inserter-listbox/row.js +2 -10
  406. package/build-module/components/inserter-listbox/row.js.map +1 -1
  407. package/build-module/components/inspector-controls/groups.js +2 -0
  408. package/build-module/components/inspector-controls/groups.js.map +1 -1
  409. package/build-module/components/inspector-controls-tabs/index.js +4 -1
  410. package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
  411. package/build-module/components/inspector-controls-tabs/settings-tab.js +3 -1
  412. package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  413. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +2 -1
  414. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  415. package/build-module/components/inspector-popover-header/index.js +8 -2
  416. package/build-module/components/inspector-popover-header/index.js.map +1 -1
  417. package/build-module/components/letter-spacing-control/index.js +7 -4
  418. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  419. package/build-module/components/link-control/index.js +19 -10
  420. package/build-module/components/link-control/index.js.map +1 -1
  421. package/build-module/components/link-control/settings-drawer.js +4 -1
  422. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  423. package/build-module/components/list-view/block-select-button.js +4 -1
  424. package/build-module/components/list-view/block-select-button.js.map +1 -1
  425. package/build-module/components/list-view/index.js +3 -7
  426. package/build-module/components/list-view/index.js.map +1 -1
  427. package/build-module/components/media-placeholder/index.js +32 -11
  428. package/build-module/components/media-placeholder/index.js.map +1 -1
  429. package/build-module/components/media-replace-flow/index.js +8 -1
  430. package/build-module/components/media-replace-flow/index.js.map +1 -1
  431. package/build-module/components/provider/use-block-sync.js +19 -19
  432. package/build-module/components/provider/use-block-sync.js.map +1 -1
  433. package/build-module/components/rich-text/event-listeners/paste-handler.js +12 -1
  434. package/build-module/components/rich-text/event-listeners/paste-handler.js.map +1 -1
  435. package/build-module/components/rich-text/index.js +39 -31
  436. package/build-module/components/rich-text/index.js.map +1 -1
  437. package/build-module/components/rich-text/use-mark-persistent.js +5 -5
  438. package/build-module/components/rich-text/use-mark-persistent.js.map +1 -1
  439. package/build-module/components/skip-to-selected-block/index.js +4 -1
  440. package/build-module/components/skip-to-selected-block/index.js.map +1 -1
  441. package/build-module/components/spacing-sizes-control/index.js +9 -10
  442. package/build-module/components/spacing-sizes-control/index.js.map +1 -1
  443. package/build-module/components/spacing-sizes-control/linked-button.js +28 -0
  444. package/build-module/components/spacing-sizes-control/linked-button.js.map +1 -0
  445. package/build-module/components/spacing-sizes-control/utils.js +4 -15
  446. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  447. package/build-module/components/tool-selector/index.js +4 -1
  448. package/build-module/components/tool-selector/index.js.map +1 -1
  449. package/build-module/components/url-input/button.js +12 -3
  450. package/build-module/components/url-input/button.js.map +1 -1
  451. package/build-module/components/url-input/index.js +4 -1
  452. package/build-module/components/url-input/index.js.map +1 -1
  453. package/build-module/components/use-block-drop-zone/index.js +31 -7
  454. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  455. package/build-module/components/writing-flow/index.js +2 -1
  456. package/build-module/components/writing-flow/index.js.map +1 -1
  457. package/build-module/components/writing-flow/use-arrow-nav.js +4 -1
  458. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  459. package/build-module/components/writing-flow/use-event-redirect.js +60 -0
  460. package/build-module/components/writing-flow/use-event-redirect.js.map +1 -0
  461. package/build-module/components/writing-flow/use-input.js +31 -1
  462. package/build-module/components/writing-flow/use-input.js.map +1 -1
  463. package/build-module/components/writing-flow/use-select-all.js +14 -1
  464. package/build-module/components/writing-flow/use-select-all.js.map +1 -1
  465. package/build-module/components/writing-flow/use-selection-observer.js +16 -2
  466. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  467. package/build-module/components/writing-flow/use-tab-nav.js +4 -4
  468. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  469. package/build-module/components/writing-flow/utils.js +26 -0
  470. package/build-module/components/writing-flow/utils.js.map +1 -1
  471. package/build-module/hooks/block-bindings.js +35 -31
  472. package/build-module/hooks/block-bindings.js.map +1 -1
  473. package/build-module/hooks/content-lock-ui.js +10 -30
  474. package/build-module/hooks/content-lock-ui.js.map +1 -1
  475. package/build-module/hooks/duotone.js +0 -4
  476. package/build-module/hooks/duotone.js.map +1 -1
  477. package/build-module/hooks/layout.js +4 -2
  478. package/build-module/hooks/layout.js.map +1 -1
  479. package/build-module/hooks/spacing-visualizer.js +3 -3
  480. package/build-module/hooks/spacing-visualizer.js.map +1 -1
  481. package/build-module/hooks/style.js +1 -5
  482. package/build-module/hooks/style.js.map +1 -1
  483. package/build-module/hooks/use-bindings-attributes.js +19 -20
  484. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  485. package/build-module/hooks/use-zoom-out.js +7 -7
  486. package/build-module/hooks/use-zoom-out.js.map +1 -1
  487. package/build-module/layouts/constrained.js +44 -45
  488. package/build-module/layouts/constrained.js.map +1 -1
  489. package/build-module/layouts/flex.js +4 -1
  490. package/build-module/layouts/flex.js.map +1 -1
  491. package/build-module/layouts/grid.js +21 -18
  492. package/build-module/layouts/grid.js.map +1 -1
  493. package/build-module/layouts/utils.js +1 -7
  494. package/build-module/layouts/utils.js.map +1 -1
  495. package/build-module/private-apis.js +3 -4
  496. package/build-module/private-apis.js.map +1 -1
  497. package/build-module/store/actions.js +2 -7
  498. package/build-module/store/actions.js.map +1 -1
  499. package/build-module/store/private-actions.js +1 -0
  500. package/build-module/store/private-actions.js.map +1 -1
  501. package/build-module/store/private-keys.js +1 -0
  502. package/build-module/store/private-keys.js.map +1 -1
  503. package/build-module/store/private-selectors.js +15 -18
  504. package/build-module/store/private-selectors.js.map +1 -1
  505. package/build-module/store/reducer.js +1 -9
  506. package/build-module/store/reducer.js.map +1 -1
  507. package/build-module/store/selectors.js +22 -46
  508. package/build-module/store/selectors.js.map +1 -1
  509. package/build-module/store/utils.js +46 -0
  510. package/build-module/store/utils.js.map +1 -1
  511. package/build-module/utils/block-bindings.js +17 -12
  512. package/build-module/utils/block-bindings.js.map +1 -1
  513. package/build-module/utils/dom.js +99 -0
  514. package/build-module/utils/dom.js.map +1 -1
  515. package/build-module/utils/get-font-styles-and-weights.js +4 -4
  516. package/build-module/utils/get-font-styles-and-weights.js.map +1 -1
  517. package/build-module/utils/transform-styles/index.js +120 -16
  518. package/build-module/utils/transform-styles/index.js.map +1 -1
  519. package/build-style/content-rtl.css +19 -11
  520. package/build-style/content.css +19 -11
  521. package/build-style/style-rtl.css +27 -117
  522. package/build-style/style.css +27 -117
  523. package/build-types/utils/dom.d.ts +25 -0
  524. package/build-types/utils/dom.d.ts.map +1 -1
  525. package/package.json +34 -32
  526. package/src/components/block-alignment-matrix-control/index.js +1 -1
  527. package/src/components/block-breadcrumb/index.js +2 -2
  528. package/src/components/block-breadcrumb/style.scss +1 -30
  529. package/src/components/block-canvas/index.js +9 -1
  530. package/src/components/block-compare/block-view.js +6 -1
  531. package/src/components/block-compare/test/__snapshots__/block-view.js.snap +1 -1
  532. package/src/components/block-draggable/content.scss +1 -1
  533. package/src/components/block-draggable/index.js +4 -4
  534. package/src/components/block-draggable/style.scss +1 -1
  535. package/src/components/block-draggable/use-scroll-when-dragging.js +25 -25
  536. package/src/components/block-edit/multiple-usage-warning.js +2 -0
  537. package/src/components/block-inspector/index.js +22 -7
  538. package/src/components/block-inspector/style.scss +2 -4
  539. package/src/components/block-list/block-invalid-warning.js +3 -2
  540. package/src/components/block-list/block.js +6 -2
  541. package/src/components/block-list/content.scss +23 -3
  542. package/src/components/block-list/index.js +59 -38
  543. package/src/components/block-list/use-block-props/index.js +3 -0
  544. package/src/components/block-list/use-block-props/use-focus-first-element.js +1 -0
  545. package/src/components/block-list/use-block-props/use-zoom-out-mode-exit.js +56 -0
  546. package/src/components/block-list/zoom-out-separator.js +110 -0
  547. package/src/components/block-lock/style.scss +1 -1
  548. package/src/components/block-lock/toolbar.js +3 -3
  549. package/src/components/block-mover/button.js +1 -0
  550. package/src/components/block-mover/index.js +1 -0
  551. package/src/components/block-mover/style.scss +1 -1
  552. package/src/components/block-navigation/dropdown.js +2 -0
  553. package/src/components/block-pattern-setup/index.js +3 -15
  554. package/src/components/block-pattern-setup/setup-toolbar.js +17 -4
  555. package/src/components/block-pattern-setup/style.scss +2 -2
  556. package/src/components/block-patterns-list/index.js +15 -18
  557. package/src/components/block-patterns-list/style.scss +2 -2
  558. package/src/components/block-patterns-paging/index.js +6 -0
  559. package/src/components/block-popover/index.js +7 -28
  560. package/src/components/block-popover/style.scss +1 -1
  561. package/src/components/block-quick-navigation/index.js +2 -0
  562. package/src/components/block-settings-menu-controls/index.js +7 -1
  563. package/src/components/block-switcher/index.js +45 -23
  564. package/src/components/block-switcher/pattern-transformations-menu.js +3 -12
  565. package/src/components/block-switcher/style.scss +5 -30
  566. package/src/components/block-toolbar/index.js +27 -11
  567. package/src/components/block-toolbar/shuffle.js +9 -7
  568. package/src/components/block-toolbar/style.scss +4 -1
  569. package/src/components/block-tools/block-selection-button.js +4 -0
  570. package/src/components/block-tools/block-toolbar-popover.js +10 -6
  571. package/src/components/block-tools/index.js +1 -1
  572. package/src/components/block-tools/style.scss +3 -4
  573. package/src/components/block-tools/use-block-toolbar-popover-props.js +2 -1
  574. package/src/components/block-tools/zoom-out-mode-inserters.js +2 -17
  575. package/src/components/block-tools/zoom-out-popover.js +3 -7
  576. package/src/components/block-tools/zoom-out-toolbar.js +31 -6
  577. package/src/components/block-variation-picker/README.md +2 -2
  578. package/src/components/block-variation-picker/index.js +6 -1
  579. package/src/components/block-variation-transforms/index.js +2 -0
  580. package/src/components/block-variation-transforms/style.scss +1 -1
  581. package/src/components/button-block-appender/content.scss +0 -1
  582. package/src/components/button-block-appender/index.js +30 -28
  583. package/src/components/color-palette/test/control.js +15 -2
  584. package/src/components/colors-gradients/dropdown.js +5 -1
  585. package/src/components/colors-gradients/style.scss +4 -4
  586. package/src/components/content-lock/index.js +1 -0
  587. package/src/components/content-lock/modify-content-lock-menu-item.js +58 -0
  588. package/src/components/default-block-appender/content.scss +0 -1
  589. package/src/components/editor-styles/index.js +4 -3
  590. package/src/components/global-styles/background-panel.js +6 -14
  591. package/src/components/global-styles/color-panel.js +8 -4
  592. package/src/components/global-styles/color-panel.native.js +2 -2
  593. package/src/components/global-styles/dimensions-panel.js +40 -40
  594. package/src/components/global-styles/filters-panel.js +5 -1
  595. package/src/components/global-styles/shadow-panel-components.js +11 -15
  596. package/src/components/global-styles/style.scss +3 -4
  597. package/src/components/global-styles/test/typography-utils.js +96 -5
  598. package/src/components/global-styles/test/utils.js +10 -0
  599. package/src/components/global-styles/typography-utils.js +22 -6
  600. package/src/components/global-styles/utils.js +4 -6
  601. package/src/components/grid/grid-item-movers.js +3 -3
  602. package/src/components/grid/grid-item-resizer.js +2 -2
  603. package/src/components/grid/style.scss +1 -1
  604. package/src/components/iframe/get-compatibility-styles.js +6 -1
  605. package/src/components/iframe/index.js +5 -5
  606. package/src/components/inner-blocks/index.js +2 -2
  607. package/src/components/inner-blocks/use-inner-block-template-sync.js +3 -3
  608. package/src/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +2 -0
  609. package/src/components/inserter/block-patterns-tab/index.js +2 -0
  610. package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +32 -15
  611. package/src/components/inserter/index.js +4 -10
  612. package/src/components/inserter/library.js +0 -2
  613. package/src/components/inserter/media-tab/hooks.js +3 -3
  614. package/src/components/inserter/media-tab/media-list.js +1 -7
  615. package/src/components/inserter/media-tab/media-preview.js +15 -8
  616. package/src/components/inserter/media-tab/media-tab.js +2 -0
  617. package/src/components/inserter/menu.js +15 -29
  618. package/src/components/inserter/quick-inserter.js +3 -4
  619. package/src/components/inserter/style.scss +10 -17
  620. package/src/components/inserter-list-item/index.js +4 -4
  621. package/src/components/inserter-list-item/style.scss +1 -3
  622. package/src/components/inserter-listbox/index.js +2 -11
  623. package/src/components/inserter-listbox/item.js +12 -14
  624. package/src/components/inserter-listbox/row.js +2 -9
  625. package/src/components/inspector-controls/groups.js +2 -0
  626. package/src/components/inspector-controls-tabs/index.js +2 -0
  627. package/src/components/inspector-controls-tabs/settings-tab.js +1 -0
  628. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +5 -2
  629. package/src/components/inspector-popover-header/index.js +4 -0
  630. package/src/components/letter-spacing-control/README.md +8 -1
  631. package/src/components/letter-spacing-control/index.js +7 -4
  632. package/src/components/link-control/index.js +17 -8
  633. package/src/components/link-control/settings-drawer.js +2 -0
  634. package/src/components/link-control/style.scss +1 -3
  635. package/src/components/list-view/block-select-button.js +2 -0
  636. package/src/components/list-view/index.js +3 -8
  637. package/src/components/list-view/style.scss +14 -16
  638. package/src/components/media-placeholder/README.md +2 -2
  639. package/src/components/media-placeholder/index.js +21 -4
  640. package/src/components/media-replace-flow/index.js +12 -1
  641. package/src/components/provider/use-block-sync.js +20 -20
  642. package/src/components/responsive-block-control/README.md +3 -27
  643. package/src/components/rich-text/content.scss +1 -1
  644. package/src/components/rich-text/event-listeners/paste-handler.js +6 -1
  645. package/src/components/rich-text/index.js +54 -41
  646. package/src/components/rich-text/style.scss +1 -1
  647. package/src/components/rich-text/use-mark-persistent.js +5 -5
  648. package/src/components/skip-to-selected-block/index.js +2 -0
  649. package/src/components/spacing-sizes-control/index.js +10 -13
  650. package/src/components/spacing-sizes-control/linked-button.js +32 -0
  651. package/src/components/spacing-sizes-control/style.scss +1 -0
  652. package/src/components/spacing-sizes-control/test/utils.js +14 -15
  653. package/src/components/spacing-sizes-control/utils.js +5 -18
  654. package/src/components/tool-selector/index.js +2 -0
  655. package/src/components/url-input/button.js +6 -0
  656. package/src/components/url-input/index.js +2 -0
  657. package/src/components/url-popover/stories/index.story.js +7 -1
  658. package/src/components/use-block-drop-zone/index.js +37 -5
  659. package/src/components/warning/content.scss +3 -10
  660. package/src/components/writing-flow/index.js +2 -0
  661. package/src/components/writing-flow/use-arrow-nav.js +9 -2
  662. package/src/components/writing-flow/use-event-redirect.js +72 -0
  663. package/src/components/writing-flow/use-input.js +36 -1
  664. package/src/components/writing-flow/use-select-all.js +18 -1
  665. package/src/components/writing-flow/use-selection-observer.js +23 -3
  666. package/src/components/writing-flow/use-tab-nav.js +4 -4
  667. package/src/components/writing-flow/utils.js +30 -0
  668. package/src/hooks/block-bindings.js +42 -43
  669. package/src/hooks/block-bindings.scss +1 -9
  670. package/src/hooks/content-lock-ui.js +11 -36
  671. package/src/hooks/duotone.js +0 -4
  672. package/src/hooks/layout.js +2 -1
  673. package/src/hooks/layout.scss +5 -27
  674. package/src/hooks/spacing-visualizer.js +3 -3
  675. package/src/hooks/style.js +1 -4
  676. package/src/hooks/use-bindings-attributes.js +23 -24
  677. package/src/hooks/use-zoom-out.js +7 -7
  678. package/src/layouts/constrained.js +53 -48
  679. package/src/layouts/flex.js +2 -0
  680. package/src/layouts/grid.js +29 -22
  681. package/src/layouts/test/grid.js +2 -2
  682. package/src/layouts/test/utils.js +6 -8
  683. package/src/layouts/utils.js +1 -9
  684. package/src/private-apis.js +2 -2
  685. package/src/store/actions.js +4 -6
  686. package/src/store/private-actions.js +1 -0
  687. package/src/store/private-keys.js +1 -0
  688. package/src/store/private-selectors.js +18 -14
  689. package/src/store/reducer.js +0 -7
  690. package/src/store/selectors.js +32 -51
  691. package/src/store/utils.js +50 -0
  692. package/src/utils/block-bindings.js +15 -16
  693. package/src/utils/dom.js +117 -0
  694. package/src/utils/get-font-styles-and-weights.js +12 -4
  695. package/src/utils/test/get-font-styles-and-weights.js +148 -0
  696. package/src/utils/test/transform-styles.js +259 -50
  697. package/src/utils/transform-styles/index.js +132 -21
  698. package/tsconfig.json +1 -0
  699. package/tsconfig.tsbuildinfo +1 -1
  700. package/build/components/spacing-sizes-control/sides-dropdown/index.js +0 -86
  701. package/build/components/spacing-sizes-control/sides-dropdown/index.js.map +0 -1
  702. package/build-module/components/spacing-sizes-control/sides-dropdown/index.js +0 -81
  703. package/build-module/components/spacing-sizes-control/sides-dropdown/index.js.map +0 -1
  704. package/src/components/spacing-sizes-control/sides-dropdown/index.js +0 -91
  705. package/src/utils/test/__snapshots__/transform-styles.js.snap +0 -109
@@ -7,8 +7,9 @@ exports.default = useSelectionObserver;
7
7
  var _data = require("@wordpress/data");
8
8
  var _compose = require("@wordpress/compose");
9
9
  var _richText = require("@wordpress/rich-text");
10
+ var _dom = require("@wordpress/dom");
10
11
  var _store = require("../../store");
11
- var _dom = require("../../utils/dom");
12
+ var _dom2 = require("../../utils/dom");
12
13
  /**
13
14
  * WordPress dependencies
14
15
  */
@@ -59,6 +60,15 @@ function extractSelectionEndNode(selection) {
59
60
  if (focusOffset === focusNode.childNodes.length) {
60
61
  return focusNode;
61
62
  }
63
+
64
+ // When the selection is forward (the selection ends with the focus node),
65
+ // the selection may extend into the next element with an offset of 0. This
66
+ // may trigger multi selection even though the selection does not visually
67
+ // end in the next block.
68
+ if (focusOffset === 0 && (0, _dom.isSelectionForward)(selection)) {
69
+ var _focusNode$previousSi;
70
+ return (_focusNode$previousSi = focusNode.previousSibling) !== null && _focusNode$previousSi !== void 0 ? _focusNode$previousSi : focusNode.parentElement;
71
+ }
62
72
  return focusNode.childNodes[focusOffset];
63
73
  }
64
74
  function findDepth(a, b) {
@@ -105,7 +115,8 @@ function useSelectionObserver() {
105
115
  const {
106
116
  getBlockParents,
107
117
  getBlockSelectionStart,
108
- isMultiSelecting
118
+ isMultiSelecting,
119
+ getSelectedBlockClientId
109
120
  } = (0, _data.useSelect)(_store.store);
110
121
  return (0, _compose.useRefEffect)(node => {
111
122
  const {
@@ -141,15 +152,15 @@ function useSelectionObserver() {
141
152
  }
142
153
  return;
143
154
  }
144
- let startClientId = (0, _dom.getBlockClientId)(startNode);
145
- let endClientId = (0, _dom.getBlockClientId)(endNode);
155
+ let startClientId = (0, _dom2.getBlockClientId)(startNode);
156
+ let endClientId = (0, _dom2.getBlockClientId)(endNode);
146
157
 
147
158
  // If the selection has changed and we had pressed `shift+click`,
148
159
  // we need to check if in an element that doesn't support
149
160
  // text selection has been clicked.
150
161
  if (isClickShift) {
151
162
  const selectedClientId = getBlockSelectionStart();
152
- const clickedClientId = (0, _dom.getBlockClientId)(event.target);
163
+ const clickedClientId = (0, _dom2.getBlockClientId)(event.target);
153
164
  // `endClientId` is not defined if we end the selection by clicking a non-selectable block.
154
165
  // We need to check if there was already a selection with a non-selectable focusNode.
155
166
  const focusNodeIsNonSelectable = clickedClientId !== endClientId;
@@ -168,10 +179,13 @@ function useSelectionObserver() {
168
179
  setContentEditableWrapper(node, false);
169
180
  return;
170
181
  }
182
+ setContentEditableWrapper(node, !!(startClientId && endClientId));
171
183
  const isSingularSelection = startClientId === endClientId;
172
184
  if (isSingularSelection) {
173
185
  if (!isMultiSelecting()) {
174
- selectBlock(startClientId);
186
+ if (getSelectedBlockClientId() !== startClientId) {
187
+ selectBlock(startClientId);
188
+ }
175
189
  } else {
176
190
  multiSelect(startClientId, startClientId);
177
191
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_compose","_richText","_store","_dom","extractSelectionStartNode","selection","anchorNode","anchorOffset","nodeType","TEXT_NODE","childNodes","extractSelectionEndNode","focusNode","focusOffset","length","findDepth","a","b","depth","setContentEditableWrapper","node","value","contentEditable","String","focus","getRichTextElement","element","ELEMENT_NODE","parentElement","closest","useSelectionObserver","multiSelect","selectBlock","selectionChange","useDispatch","blockEditorStore","getBlockParents","getBlockSelectionStart","isMultiSelecting","useSelect","useRefEffect","ownerDocument","defaultView","onSelectionChange","event","getSelection","rangeCount","startNode","endNode","contains","isClickShift","shiftKey","type","isCollapsed","startClientId","getBlockClientId","endClientId","selectedClientId","clickedClientId","target","focusNodeIsNonSelectable","undefined","isSingularSelection","startPath","endPath","richTextElementStart","richTextElementEnd","_richTextDataStart$st","_richTextDataEnd$star","range","getRangeAt","richTextDataStart","create","__unstableIsEditableTree","richTextDataEnd","startOffset","start","end","endOffset","clientId","attributeKey","dataset","wpBlockAttributeKey","offset","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-selection-observer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { create } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getBlockClientId } from '../../utils/dom';\n\n/**\n * Extract the selection start node from the selection. When the anchor node is\n * not a text node, the selection offset is the index of a child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionStartNode( selection ) {\n\tconst { anchorNode, anchorOffset } = selection;\n\n\tif ( anchorNode.nodeType === anchorNode.TEXT_NODE ) {\n\t\treturn anchorNode;\n\t}\n\n\tif ( anchorOffset === 0 ) {\n\t\treturn anchorNode;\n\t}\n\n\treturn anchorNode.childNodes[ anchorOffset - 1 ];\n}\n\n/**\n * Extract the selection end node from the selection. When the focus node is not\n * a text node, the selection offset is the index of a child node. The selection\n * reaches up to but excluding that child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionEndNode( selection ) {\n\tconst { focusNode, focusOffset } = selection;\n\n\tif ( focusNode.nodeType === focusNode.TEXT_NODE ) {\n\t\treturn focusNode;\n\t}\n\n\tif ( focusOffset === focusNode.childNodes.length ) {\n\t\treturn focusNode;\n\t}\n\n\treturn focusNode.childNodes[ focusOffset ];\n}\n\nfunction findDepth( a, b ) {\n\tlet depth = 0;\n\n\twhile ( a[ depth ] === b[ depth ] ) {\n\t\tdepth++;\n\t}\n\n\treturn depth;\n}\n\n/**\n * Sets the `contenteditable` wrapper element to `value`.\n *\n * @param {HTMLElement} node Block element.\n * @param {boolean} value `contentEditable` value (true or false)\n */\nfunction setContentEditableWrapper( node, value ) {\n\t// Since we are calling this on every selection change, check if the value\n\t// needs to be updated first because it trigger the browser to recalculate\n\t// style.\n\tif ( node.contentEditable !== String( value ) ) {\n\t\tnode.contentEditable = value;\n\n\t\t// Firefox doesn't automatically move focus.\n\t\tif ( value ) {\n\t\t\tnode.focus();\n\t\t}\n\t}\n}\n\nfunction getRichTextElement( node ) {\n\tconst element =\n\t\tnode.nodeType === node.ELEMENT_NODE ? node : node.parentElement;\n\treturn element?.closest( '[data-wp-block-attribute-key]' );\n}\n\n/**\n * Sets a multi-selection based on the native selection across blocks.\n */\nexport default function useSelectionObserver() {\n\tconst { multiSelect, selectBlock, selectionChange } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { getBlockParents, getBlockSelectionStart, isMultiSelecting } =\n\t\tuseSelect( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tfunction onSelectionChange( event ) {\n\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\tif ( ! selection.rangeCount ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst startNode = extractSelectionStartNode( selection );\n\t\t\t\tconst endNode = extractSelectionEndNode( selection );\n\n\t\t\t\tif (\n\t\t\t\t\t! node.contains( startNode ) ||\n\t\t\t\t\t! node.contains( endNode )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If selection is collapsed and we haven't used `shift+click`,\n\t\t\t\t// end multi selection and disable the contentEditable wrapper.\n\t\t\t\t// We have to check about `shift+click` case because elements\n\t\t\t\t// that don't support text selection might be involved, and we might\n\t\t\t\t// update the clientIds to multi-select blocks.\n\t\t\t\t// For now we check if the event is a `mouse` event.\n\t\t\t\tconst isClickShift = event.shiftKey && event.type === 'mouseup';\n\t\t\t\tif ( selection.isCollapsed && ! isClickShift ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.contentEditable === 'true' &&\n\t\t\t\t\t\t! isMultiSelecting()\n\t\t\t\t\t) {\n\t\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\t\tlet element =\n\t\t\t\t\t\t\tstartNode.nodeType === startNode.ELEMENT_NODE\n\t\t\t\t\t\t\t\t? startNode\n\t\t\t\t\t\t\t\t: startNode.parentElement;\n\t\t\t\t\t\telement = element?.closest( '[contenteditable]' );\n\t\t\t\t\t\telement?.focus();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet startClientId = getBlockClientId( startNode );\n\t\t\t\tlet endClientId = getBlockClientId( endNode );\n\n\t\t\t\t// If the selection has changed and we had pressed `shift+click`,\n\t\t\t\t// we need to check if in an element that doesn't support\n\t\t\t\t// text selection has been clicked.\n\t\t\t\tif ( isClickShift ) {\n\t\t\t\t\tconst selectedClientId = getBlockSelectionStart();\n\t\t\t\t\tconst clickedClientId = getBlockClientId( event.target );\n\t\t\t\t\t// `endClientId` is not defined if we end the selection by clicking a non-selectable block.\n\t\t\t\t\t// We need to check if there was already a selection with a non-selectable focusNode.\n\t\t\t\t\tconst focusNodeIsNonSelectable =\n\t\t\t\t\t\tclickedClientId !== endClientId;\n\t\t\t\t\tif (\n\t\t\t\t\t\t( startClientId === endClientId &&\n\t\t\t\t\t\t\tselection.isCollapsed ) ||\n\t\t\t\t\t\t! endClientId ||\n\t\t\t\t\t\tfocusNodeIsNonSelectable\n\t\t\t\t\t) {\n\t\t\t\t\t\tendClientId = clickedClientId;\n\t\t\t\t\t}\n\t\t\t\t\t// Handle the case when we have a non-selectable block\n\t\t\t\t\t// selected and click another one.\n\t\t\t\t\tif ( startClientId !== selectedClientId ) {\n\t\t\t\t\t\tstartClientId = selectedClientId;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If the selection did not involve a block, return.\n\t\t\t\tif (\n\t\t\t\t\tstartClientId === undefined &&\n\t\t\t\t\tendClientId === undefined\n\t\t\t\t) {\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst isSingularSelection = startClientId === endClientId;\n\t\t\t\tif ( isSingularSelection ) {\n\t\t\t\t\tif ( ! isMultiSelecting() ) {\n\t\t\t\t\t\tselectBlock( startClientId );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmultiSelect( startClientId, startClientId );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst startPath = [\n\t\t\t\t\t\t...getBlockParents( startClientId ),\n\t\t\t\t\t\tstartClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst endPath = [\n\t\t\t\t\t\t...getBlockParents( endClientId ),\n\t\t\t\t\t\tendClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst depth = findDepth( startPath, endPath );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tstartPath[ depth ] !== startClientId ||\n\t\t\t\t\t\tendPath[ depth ] !== endClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\tmultiSelect( startPath[ depth ], endPath[ depth ] );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst richTextElementStart =\n\t\t\t\t\t\tgetRichTextElement( startNode );\n\t\t\t\t\tconst richTextElementEnd = getRichTextElement( endNode );\n\n\t\t\t\t\tif ( richTextElementStart && richTextElementEnd ) {\n\t\t\t\t\t\tconst range = selection.getRangeAt( 0 );\n\t\t\t\t\t\tconst richTextDataStart = create( {\n\t\t\t\t\t\t\telement: richTextElementStart,\n\t\t\t\t\t\t\trange,\n\t\t\t\t\t\t\t__unstableIsEditableTree: true,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tconst richTextDataEnd = create( {\n\t\t\t\t\t\t\telement: richTextElementEnd,\n\t\t\t\t\t\t\trange,\n\t\t\t\t\t\t\t__unstableIsEditableTree: true,\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\tconst startOffset =\n\t\t\t\t\t\t\trichTextDataStart.start ?? richTextDataStart.end;\n\t\t\t\t\t\tconst endOffset =\n\t\t\t\t\t\t\trichTextDataEnd.start ?? richTextDataEnd.end;\n\t\t\t\t\t\tselectionChange( {\n\t\t\t\t\t\t\tstart: {\n\t\t\t\t\t\t\t\tclientId: startClientId,\n\t\t\t\t\t\t\t\tattributeKey:\n\t\t\t\t\t\t\t\t\trichTextElementStart.dataset\n\t\t\t\t\t\t\t\t\t\t.wpBlockAttributeKey,\n\t\t\t\t\t\t\t\toffset: startOffset,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tend: {\n\t\t\t\t\t\t\t\tclientId: endClientId,\n\t\t\t\t\t\t\t\tattributeKey:\n\t\t\t\t\t\t\t\t\trichTextElementEnd.dataset\n\t\t\t\t\t\t\t\t\t\t.wpBlockAttributeKey,\n\t\t\t\t\t\t\t\toffset: endOffset,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmultiSelect( startClientId, endClientId );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\townerDocument.addEventListener(\n\t\t\t\t'selectionchange',\n\t\t\t\tonSelectionChange\n\t\t\t);\n\t\t\tdefaultView.addEventListener( 'mouseup', onSelectionChange );\n\t\t\treturn () => {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tonSelectionChange\n\t\t\t\t);\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onSelectionChange );\n\t\t\t};\n\t\t},\n\t\t[ multiSelect, selectBlock, selectionChange, getBlockParents ]\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AAXA;AACA;AACA;;AAKA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASK,yBAAyBA,CAAEC,SAAS,EAAG;EAC/C,MAAM;IAAEC,UAAU;IAAEC;EAAa,CAAC,GAAGF,SAAS;EAE9C,IAAKC,UAAU,CAACE,QAAQ,KAAKF,UAAU,CAACG,SAAS,EAAG;IACnD,OAAOH,UAAU;EAClB;EAEA,IAAKC,YAAY,KAAK,CAAC,EAAG;IACzB,OAAOD,UAAU;EAClB;EAEA,OAAOA,UAAU,CAACI,UAAU,CAAEH,YAAY,GAAG,CAAC,CAAE;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASI,uBAAuBA,CAAEN,SAAS,EAAG;EAC7C,MAAM;IAAEO,SAAS;IAAEC;EAAY,CAAC,GAAGR,SAAS;EAE5C,IAAKO,SAAS,CAACJ,QAAQ,KAAKI,SAAS,CAACH,SAAS,EAAG;IACjD,OAAOG,SAAS;EACjB;EAEA,IAAKC,WAAW,KAAKD,SAAS,CAACF,UAAU,CAACI,MAAM,EAAG;IAClD,OAAOF,SAAS;EACjB;EAEA,OAAOA,SAAS,CAACF,UAAU,CAAEG,WAAW,CAAE;AAC3C;AAEA,SAASE,SAASA,CAAEC,CAAC,EAAEC,CAAC,EAAG;EAC1B,IAAIC,KAAK,GAAG,CAAC;EAEb,OAAQF,CAAC,CAAEE,KAAK,CAAE,KAAKD,CAAC,CAAEC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,MAAMC,eAAe,GAAG,IAAAF,gBAAM,EAAE;YAC/B9C,OAAO,EAAEwC,kBAAkB;YAC3BG,KAAK;YACLI,wBAAwB,EAAE;UAC3B,CAAE,CAAC;UAEH,MAAME,WAAW,IAAAR,qBAAA,GAChBI,iBAAiB,CAACK,KAAK,cAAAT,qBAAA,cAAAA,qBAAA,GAAII,iBAAiB,CAACM,GAAG;UACjD,MAAMC,SAAS,IAAAV,qBAAA,GACdM,eAAe,CAACE,KAAK,cAAAR,qBAAA,cAAAA,qBAAA,GAAIM,eAAe,CAACG,GAAG;UAC7C5C,eAAe,CAAE;YAChB2C,KAAK,EAAE;cACNG,QAAQ,EAAEzB,aAAa;cACvB0B,YAAY,EACXf,oBAAoB,CAACgB,OAAO,CAC1BC,mBAAmB;cACtBC,MAAM,EAAER;YACT,CAAC;YACDE,GAAG,EAAE;cACJE,QAAQ,EAAEvB,WAAW;cACrBwB,YAAY,EACXd,kBAAkB,CAACe,OAAO,CACxBC,mBAAmB;cACtBC,MAAM,EAAEL;YACT;UACD,CAAE,CAAC;QACJ,CAAC,MAAM;UACN/C,WAAW,CAAEuB,aAAa,EAAEE,WAAY,CAAC;QAC1C;MACD;IACD;IAEAf,aAAa,CAAC2C,gBAAgB,CAC7B,iBAAiB,EACjBzC,iBACD,CAAC;IACDD,WAAW,CAAC0C,gBAAgB,CAAE,SAAS,EAAEzC,iBAAkB,CAAC;IAC5D,OAAO,MAAM;MACZF,aAAa,CAAC4C,mBAAmB,CAChC,iBAAiB,EACjB1C,iBACD,CAAC;MACDD,WAAW,CAAC2C,mBAAmB,CAAE,SAAS,EAAE1C,iBAAkB,CAAC;IAChE,CAAC;EACF,CAAC,EACD,CAAEZ,WAAW,EAAEC,WAAW,EAAEC,eAAe,EAAEG,eAAe,CAC7D,CAAC;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_compose","_richText","_dom","_store","_dom2","extractSelectionStartNode","selection","anchorNode","anchorOffset","nodeType","TEXT_NODE","childNodes","extractSelectionEndNode","focusNode","focusOffset","length","isSelectionForward","_focusNode$previousSi","previousSibling","parentElement","findDepth","a","b","depth","setContentEditableWrapper","node","value","contentEditable","String","focus","getRichTextElement","element","ELEMENT_NODE","closest","useSelectionObserver","multiSelect","selectBlock","selectionChange","useDispatch","blockEditorStore","getBlockParents","getBlockSelectionStart","isMultiSelecting","getSelectedBlockClientId","useSelect","useRefEffect","ownerDocument","defaultView","onSelectionChange","event","getSelection","rangeCount","startNode","endNode","contains","isClickShift","shiftKey","type","isCollapsed","startClientId","getBlockClientId","endClientId","selectedClientId","clickedClientId","target","focusNodeIsNonSelectable","undefined","isSingularSelection","startPath","endPath","richTextElementStart","richTextElementEnd","_richTextDataStart$st","_richTextDataEnd$star","range","getRangeAt","richTextDataStart","create","__unstableIsEditableTree","richTextDataEnd","startOffset","start","end","endOffset","clientId","attributeKey","dataset","wpBlockAttributeKey","offset","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-selection-observer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { create } from '@wordpress/rich-text';\nimport { isSelectionForward } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getBlockClientId } from '../../utils/dom';\n\n/**\n * Extract the selection start node from the selection. When the anchor node is\n * not a text node, the selection offset is the index of a child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionStartNode( selection ) {\n\tconst { anchorNode, anchorOffset } = selection;\n\n\tif ( anchorNode.nodeType === anchorNode.TEXT_NODE ) {\n\t\treturn anchorNode;\n\t}\n\n\tif ( anchorOffset === 0 ) {\n\t\treturn anchorNode;\n\t}\n\n\treturn anchorNode.childNodes[ anchorOffset - 1 ];\n}\n\n/**\n * Extract the selection end node from the selection. When the focus node is not\n * a text node, the selection offset is the index of a child node. The selection\n * reaches up to but excluding that child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionEndNode( selection ) {\n\tconst { focusNode, focusOffset } = selection;\n\n\tif ( focusNode.nodeType === focusNode.TEXT_NODE ) {\n\t\treturn focusNode;\n\t}\n\n\tif ( focusOffset === focusNode.childNodes.length ) {\n\t\treturn focusNode;\n\t}\n\n\t// When the selection is forward (the selection ends with the focus node),\n\t// the selection may extend into the next element with an offset of 0. This\n\t// may trigger multi selection even though the selection does not visually\n\t// end in the next block.\n\tif ( focusOffset === 0 && isSelectionForward( selection ) ) {\n\t\treturn focusNode.previousSibling ?? focusNode.parentElement;\n\t}\n\n\treturn focusNode.childNodes[ focusOffset ];\n}\n\nfunction findDepth( a, b ) {\n\tlet depth = 0;\n\n\twhile ( a[ depth ] === b[ depth ] ) {\n\t\tdepth++;\n\t}\n\n\treturn depth;\n}\n\n/**\n * Sets the `contenteditable` wrapper element to `value`.\n *\n * @param {HTMLElement} node Block element.\n * @param {boolean} value `contentEditable` value (true or false)\n */\nfunction setContentEditableWrapper( node, value ) {\n\t// Since we are calling this on every selection change, check if the value\n\t// needs to be updated first because it trigger the browser to recalculate\n\t// style.\n\tif ( node.contentEditable !== String( value ) ) {\n\t\tnode.contentEditable = value;\n\n\t\t// Firefox doesn't automatically move focus.\n\t\tif ( value ) {\n\t\t\tnode.focus();\n\t\t}\n\t}\n}\n\nfunction getRichTextElement( node ) {\n\tconst element =\n\t\tnode.nodeType === node.ELEMENT_NODE ? node : node.parentElement;\n\treturn element?.closest( '[data-wp-block-attribute-key]' );\n}\n\n/**\n * Sets a multi-selection based on the native selection across blocks.\n */\nexport default function useSelectionObserver() {\n\tconst { multiSelect, selectBlock, selectionChange } =\n\t\tuseDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlockParents,\n\t\tgetBlockSelectionStart,\n\t\tisMultiSelecting,\n\t\tgetSelectedBlockClientId,\n\t} = useSelect( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tfunction onSelectionChange( event ) {\n\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\tif ( ! selection.rangeCount ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst startNode = extractSelectionStartNode( selection );\n\t\t\t\tconst endNode = extractSelectionEndNode( selection );\n\n\t\t\t\tif (\n\t\t\t\t\t! node.contains( startNode ) ||\n\t\t\t\t\t! node.contains( endNode )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If selection is collapsed and we haven't used `shift+click`,\n\t\t\t\t// end multi selection and disable the contentEditable wrapper.\n\t\t\t\t// We have to check about `shift+click` case because elements\n\t\t\t\t// that don't support text selection might be involved, and we might\n\t\t\t\t// update the clientIds to multi-select blocks.\n\t\t\t\t// For now we check if the event is a `mouse` event.\n\t\t\t\tconst isClickShift = event.shiftKey && event.type === 'mouseup';\n\t\t\t\tif ( selection.isCollapsed && ! isClickShift ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.contentEditable === 'true' &&\n\t\t\t\t\t\t! isMultiSelecting()\n\t\t\t\t\t) {\n\t\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\t\tlet element =\n\t\t\t\t\t\t\tstartNode.nodeType === startNode.ELEMENT_NODE\n\t\t\t\t\t\t\t\t? startNode\n\t\t\t\t\t\t\t\t: startNode.parentElement;\n\t\t\t\t\t\telement = element?.closest( '[contenteditable]' );\n\t\t\t\t\t\telement?.focus();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet startClientId = getBlockClientId( startNode );\n\t\t\t\tlet endClientId = getBlockClientId( endNode );\n\n\t\t\t\t// If the selection has changed and we had pressed `shift+click`,\n\t\t\t\t// we need to check if in an element that doesn't support\n\t\t\t\t// text selection has been clicked.\n\t\t\t\tif ( isClickShift ) {\n\t\t\t\t\tconst selectedClientId = getBlockSelectionStart();\n\t\t\t\t\tconst clickedClientId = getBlockClientId( event.target );\n\t\t\t\t\t// `endClientId` is not defined if we end the selection by clicking a non-selectable block.\n\t\t\t\t\t// We need to check if there was already a selection with a non-selectable focusNode.\n\t\t\t\t\tconst focusNodeIsNonSelectable =\n\t\t\t\t\t\tclickedClientId !== endClientId;\n\t\t\t\t\tif (\n\t\t\t\t\t\t( startClientId === endClientId &&\n\t\t\t\t\t\t\tselection.isCollapsed ) ||\n\t\t\t\t\t\t! endClientId ||\n\t\t\t\t\t\tfocusNodeIsNonSelectable\n\t\t\t\t\t) {\n\t\t\t\t\t\tendClientId = clickedClientId;\n\t\t\t\t\t}\n\t\t\t\t\t// Handle the case when we have a non-selectable block\n\t\t\t\t\t// selected and click another one.\n\t\t\t\t\tif ( startClientId !== selectedClientId ) {\n\t\t\t\t\t\tstartClientId = selectedClientId;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If the selection did not involve a block, return.\n\t\t\t\tif (\n\t\t\t\t\tstartClientId === undefined &&\n\t\t\t\t\tendClientId === undefined\n\t\t\t\t) {\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetContentEditableWrapper(\n\t\t\t\t\tnode,\n\t\t\t\t\t!! ( startClientId && endClientId )\n\t\t\t\t);\n\n\t\t\t\tconst isSingularSelection = startClientId === endClientId;\n\t\t\t\tif ( isSingularSelection ) {\n\t\t\t\t\tif ( ! isMultiSelecting() ) {\n\t\t\t\t\t\tif ( getSelectedBlockClientId() !== startClientId ) {\n\t\t\t\t\t\t\tselectBlock( startClientId );\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmultiSelect( startClientId, startClientId );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst startPath = [\n\t\t\t\t\t\t...getBlockParents( startClientId ),\n\t\t\t\t\t\tstartClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst endPath = [\n\t\t\t\t\t\t...getBlockParents( endClientId ),\n\t\t\t\t\t\tendClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst depth = findDepth( startPath, endPath );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tstartPath[ depth ] !== startClientId ||\n\t\t\t\t\t\tendPath[ depth ] !== endClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\tmultiSelect( startPath[ depth ], endPath[ depth ] );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst richTextElementStart =\n\t\t\t\t\t\tgetRichTextElement( startNode );\n\t\t\t\t\tconst richTextElementEnd = getRichTextElement( endNode );\n\n\t\t\t\t\tif ( richTextElementStart && richTextElementEnd ) {\n\t\t\t\t\t\tconst range = selection.getRangeAt( 0 );\n\t\t\t\t\t\tconst richTextDataStart = create( {\n\t\t\t\t\t\t\telement: richTextElementStart,\n\t\t\t\t\t\t\trange,\n\t\t\t\t\t\t\t__unstableIsEditableTree: true,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tconst richTextDataEnd = create( {\n\t\t\t\t\t\t\telement: richTextElementEnd,\n\t\t\t\t\t\t\trange,\n\t\t\t\t\t\t\t__unstableIsEditableTree: true,\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\tconst startOffset =\n\t\t\t\t\t\t\trichTextDataStart.start ?? richTextDataStart.end;\n\t\t\t\t\t\tconst endOffset =\n\t\t\t\t\t\t\trichTextDataEnd.start ?? richTextDataEnd.end;\n\t\t\t\t\t\tselectionChange( {\n\t\t\t\t\t\t\tstart: {\n\t\t\t\t\t\t\t\tclientId: startClientId,\n\t\t\t\t\t\t\t\tattributeKey:\n\t\t\t\t\t\t\t\t\trichTextElementStart.dataset\n\t\t\t\t\t\t\t\t\t\t.wpBlockAttributeKey,\n\t\t\t\t\t\t\t\toffset: startOffset,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tend: {\n\t\t\t\t\t\t\t\tclientId: endClientId,\n\t\t\t\t\t\t\t\tattributeKey:\n\t\t\t\t\t\t\t\t\trichTextElementEnd.dataset\n\t\t\t\t\t\t\t\t\t\t.wpBlockAttributeKey,\n\t\t\t\t\t\t\t\toffset: endOffset,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmultiSelect( startClientId, endClientId );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\townerDocument.addEventListener(\n\t\t\t\t'selectionchange',\n\t\t\t\tonSelectionChange\n\t\t\t);\n\t\t\tdefaultView.addEventListener( 'mouseup', onSelectionChange );\n\t\t\treturn () => {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tonSelectionChange\n\t\t\t\t);\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onSelectionChange );\n\t\t\t};\n\t\t},\n\t\t[ multiSelect, selectBlock, selectionChange, getBlockParents ]\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAZA;AACA;AACA;;AAMA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASM,yBAAyBA,CAAEC,SAAS,EAAG;EAC/C,MAAM;IAAEC,UAAU;IAAEC;EAAa,CAAC,GAAGF,SAAS;EAE9C,IAAKC,UAAU,CAACE,QAAQ,KAAKF,UAAU,CAACG,SAAS,EAAG;IACnD,OAAOH,UAAU;EAClB;EAEA,IAAKC,YAAY,KAAK,CAAC,EAAG;IACzB,OAAOD,UAAU;EAClB;EAEA,OAAOA,UAAU,CAACI,UAAU,CAAEH,YAAY,GAAG,CAAC,CAAE;AACjD;;A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AIM,eAAe,CAACG,GAAG;UAC7C7C,eAAe,CAAE;YAChB4C,KAAK,EAAE;cACNG,QAAQ,EAAEzB,aAAa;cACvB0B,YAAY,EACXf,oBAAoB,CAACgB,OAAO,CAC1BC,mBAAmB;cACtBC,MAAM,EAAER;YACT,CAAC;YACDE,GAAG,EAAE;cACJE,QAAQ,EAAEvB,WAAW;cACrBwB,YAAY,EACXd,kBAAkB,CAACe,OAAO,CACxBC,mBAAmB;cACtBC,MAAM,EAAEL;YACT;UACD,CAAE,CAAC;QACJ,CAAC,MAAM;UACNhD,WAAW,CAAEwB,aAAa,EAAEE,WAAY,CAAC;QAC1C;MACD;IACD;IAEAf,aAAa,CAAC2C,gBAAgB,CAC7B,iBAAiB,EACjBzC,iBACD,CAAC;IACDD,WAAW,CAAC0C,gBAAgB,CAAE,SAAS,EAAEzC,iBAAkB,CAAC;IAC5D,OAAO,MAAM;MACZF,aAAa,CAAC4C,mBAAmB,CAChC,iBAAiB,EACjB1C,iBACD,CAAC;MACDD,WAAW,CAAC2C,mBAAmB,CAAE,SAAS,EAAE1C,iBAAkB,CAAC;IAChE,CAAC;EACF,CAAC,EACD,CAAEb,WAAW,EAAEC,WAAW,EAAEC,eAAe,EAAEG,eAAe,CAC7D,CAAC;AACF","ignoreList":[]}
@@ -44,11 +44,11 @@ function useTabNav() {
44
44
 
45
45
  // Reference that holds the a flag for enabling or disabling
46
46
  // capturing on the focus capture elements.
47
- const noCapture = (0, _element.useRef)();
47
+ const noCaptureRef = (0, _element.useRef)();
48
48
  function onFocusCapture(event) {
49
49
  // Do not capture incoming focus if set by us in WritingFlow.
50
- if (noCapture.current) {
51
- noCapture.current = null;
50
+ if (noCaptureRef.current) {
51
+ noCaptureRef.current = null;
52
52
  } else if (hasMultiSelection()) {
53
53
  container.current.focus();
54
54
  } else if (getSelectedBlockClientId()) {
@@ -139,7 +139,7 @@ function useTabNav() {
139
139
  // Disable focus capturing on the focus capture element, so it
140
140
  // doesn't refocus this block and so it allows default behaviour
141
141
  // (moving focus to the next tabbable element).
142
- noCapture.current = true;
142
+ noCaptureRef.current = true;
143
143
 
144
144
  // Focusing the focus capture element, which is located above and
145
145
  // below the editor, should not scroll the page all the way up or
@@ -1 +1 @@
1
- {"version":3,"names":["_dom","require","_keycodes","_data","_compose","_element","_store","_dom2","_lockUnlock","_jsxRuntime","useTabNav","container","useRef","focusCaptureBeforeRef","focusCaptureAfterRef","hasMultiSelection","getSelectedBlockClientId","getBlockCount","useSelect","blockEditorStore","setNavigationMode","setLastFocus","unlock","useDispatch","isNavigationMode","select","getLastFocus","focusCaptureTabIndex","undefined","noCapture","onFocusCapture","event","current","focus","querySelector","canvasElement","ownerDocument","target","defaultView","frameElement","isBefore","compareDocumentPosition","DOCUMENT_POSITION_FOLLOWING","tabbables","tabbable","find","length","next","before","jsx","ref","tabIndex","onFocus","after","useRefEffect","node","onKeyDown","defaultPrevented","keyCode","ESCAPE","preventDefault","TAB","isShift","shiftKey","direction","nextTabbable","currentBlock","closest","isElementPartOfSelectedBlock","isInSameBlock","isInsideRootBlock","isFormElement","preventScroll","onFocusOut","relatedTarget","activeElement","body","preventScrollOnTab","getAttribute","addEventListener","removeEventListener","mergedRefs","useMergeRefs"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-tab-nav.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { focus, isFormElement } from '@wordpress/dom';\nimport { TAB, ESCAPE } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { isInSameBlock, isInsideRootBlock } from '../../utils/dom';\nimport { unlock } from '../../lock-unlock';\n\nexport default function useTabNav() {\n\tconst container = useRef();\n\tconst focusCaptureBeforeRef = useRef();\n\tconst focusCaptureAfterRef = useRef();\n\n\tconst { hasMultiSelection, getSelectedBlockClientId, getBlockCount } =\n\t\tuseSelect( blockEditorStore );\n\tconst { setNavigationMode, setLastFocus } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\tconst isNavigationMode = useSelect(\n\t\t( select ) => select( blockEditorStore ).isNavigationMode(),\n\t\t[]\n\t);\n\n\tconst { getLastFocus } = unlock( useSelect( blockEditorStore ) );\n\n\t// Don't allow tabbing to this element in Navigation mode.\n\tconst focusCaptureTabIndex = ! isNavigationMode ? '0' : undefined;\n\n\t// Reference that holds the a flag for enabling or disabling\n\t// capturing on the focus capture elements.\n\tconst noCapture = useRef();\n\n\tfunction onFocusCapture( event ) {\n\t\t// Do not capture incoming focus if set by us in WritingFlow.\n\t\tif ( noCapture.current ) {\n\t\t\tnoCapture.current = null;\n\t\t} else if ( hasMultiSelection() ) {\n\t\t\tcontainer.current.focus();\n\t\t} else if ( getSelectedBlockClientId() ) {\n\t\t\tif ( getLastFocus()?.current ) {\n\t\t\t\tgetLastFocus().current.focus();\n\t\t\t} else {\n\t\t\t\t// Handles when the last focus has not been set yet, or has been cleared by new blocks being added via the inserter.\n\t\t\t\tcontainer.current\n\t\t\t\t\t.querySelector(\n\t\t\t\t\t\t`[data-block=\"${ getSelectedBlockClientId() }\"]`\n\t\t\t\t\t)\n\t\t\t\t\t.focus();\n\t\t\t}\n\t\t} else {\n\t\t\tsetNavigationMode( true );\n\n\t\t\tconst canvasElement =\n\t\t\t\tcontainer.current.ownerDocument === event.target.ownerDocument\n\t\t\t\t\t? container.current\n\t\t\t\t\t: container.current.ownerDocument.defaultView.frameElement;\n\n\t\t\tconst isBefore =\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tevent.target.compareDocumentPosition( canvasElement ) &\n\t\t\t\tevent.target.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tconst tabbables = focus.tabbable.find( container.current );\n\n\t\t\tif ( tabbables.length ) {\n\t\t\t\tconst next = isBefore\n\t\t\t\t\t? tabbables[ 0 ]\n\t\t\t\t\t: tabbables[ tabbables.length - 1 ];\n\n\t\t\t\tnext.focus();\n\t\t\t}\n\t\t}\n\t}\n\n\tconst before = (\n\t\t<div\n\t\t\tref={ focusCaptureBeforeRef }\n\t\t\ttabIndex={ focusCaptureTabIndex }\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst after = (\n\t\t<div\n\t\t\tref={ focusCaptureAfterRef }\n\t\t\ttabIndex={ focusCaptureTabIndex }\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst ref = useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ESCAPE && ! hasMultiSelection() ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetNavigationMode( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// In Edit mode, Tab should focus the first tabbable element after\n\t\t\t// the content, which is normally the sidebar (with block controls)\n\t\t\t// and Shift+Tab should focus the first tabbable element before the\n\t\t\t// content, which is normally the block toolbar.\n\t\t\t// Arrow keys can be used, and Tab and arrow keys can be used in\n\t\t\t// Navigation mode (press Esc), to navigate through blocks.\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\n\t\t\tif ( ! hasMultiSelection() && ! getSelectedBlockClientId() ) {\n\t\t\t\t// Preserve the behaviour of entering navigation mode when\n\t\t\t\t// tabbing into the content without a block selection.\n\t\t\t\t// `onFocusCapture` already did this previously, but we need to\n\t\t\t\t// do it again here because after clearing block selection,\n\t\t\t\t// focus land on the writing flow container and pressing Tab\n\t\t\t\t// will no longer send focus through the focus capture element.\n\t\t\t\tif ( event.target === node ) {\n\t\t\t\t\tsetNavigationMode( true );\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nextTabbable = focus.tabbable[ direction ]( event.target );\n\n\t\t\t// We want to constrain the tabbing to the block and its child blocks.\n\t\t\t// If the preceding form element is within a different block,\n\t\t\t// such as two sibling image blocks in the placeholder state,\n\t\t\t// we want shift + tab from the first form element to move to the image\n\t\t\t// block toolbar and not the previous image block's form element.\n\t\t\tconst currentBlock = event.target.closest( '[data-block]' );\n\t\t\tconst isElementPartOfSelectedBlock =\n\t\t\t\tcurrentBlock &&\n\t\t\t\tnextTabbable &&\n\t\t\t\t( isInSameBlock( currentBlock, nextTabbable ) ||\n\t\t\t\t\tisInsideRootBlock( currentBlock, nextTabbable ) );\n\n\t\t\t// Allow tabbing from the block wrapper to a form element,\n\t\t\t// and between form elements rendered in a block and its child blocks,\n\t\t\t// such as inside a placeholder. Form elements are generally\n\t\t\t// meant to be UI rather than part of the content. Ideally\n\t\t\t// these are not rendered in the content and perhaps in the\n\t\t\t// future they can be rendered in an iframe or shadow DOM.\n\t\t\tif (\n\t\t\t\tisFormElement( nextTabbable ) &&\n\t\t\t\tisElementPartOfSelectedBlock\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef;\n\n\t\t\t// Disable focus capturing on the focus capture element, so it\n\t\t\t// doesn't refocus this block and so it allows default behaviour\n\t\t\t// (moving focus to the next tabbable element).\n\t\t\tnoCapture.current = true;\n\n\t\t\t// Focusing the focus capture element, which is located above and\n\t\t\t// below the editor, should not scroll the page all the way up or\n\t\t\t// down.\n\t\t\tnext.current.focus( { preventScroll: true } );\n\t\t}\n\n\t\tfunction onFocusOut( event ) {\n\t\t\tsetLastFocus( { ...getLastFocus(), current: event.target } );\n\n\t\t\tconst { ownerDocument } = node;\n\n\t\t\t// If focus disappears due to there being no blocks, move focus to\n\t\t\t// the writing flow wrapper.\n\t\t\tif (\n\t\t\t\t! event.relatedTarget &&\n\t\t\t\townerDocument.activeElement === ownerDocument.body &&\n\t\t\t\tgetBlockCount() === 0\n\t\t\t) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t}\n\n\t\t// When tabbing back to an element in block list, this event handler prevents scrolling if the\n\t\t// focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph\n\t\t// when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the\n\t\t// top or bottom of the document.\n\t\t//\n\t\t// Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this\n\t\t// earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters\n\t\tfunction preventScrollOnTab( event ) {\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.target?.getAttribute( 'role' ) === 'region' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( container.current === event.target ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst target = focus.tabbable[ direction ]( event.target );\n\t\t\t// Only do something when the next tabbable is a focus capture div (before/after)\n\t\t\tif (\n\t\t\t\ttarget === focusCaptureBeforeRef.current ||\n\t\t\t\ttarget === focusCaptureAfterRef.current\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\ttarget.focus( { preventScroll: true } );\n\t\t\t}\n\t\t}\n\n\t\tconst { ownerDocument } = node;\n\t\tconst { defaultView } = ownerDocument;\n\t\tdefaultView.addEventListener( 'keydown', preventScrollOnTab );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'focusout', onFocusOut );\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'keydown', preventScrollOnTab );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'focusout', onFocusOut );\n\t\t};\n\t}, [] );\n\n\tconst mergedRefs = useMergeRefs( [ container, ref ] );\n\n\treturn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MAAMzB,MAAM,GAAGJ,UAAK,CAACW,QAAQ,CAAEoB,SAAS,CAAE,CAAEjC,KAAK,CAACM,MAAO,CAAC;MAC1D;MACA,IACCA,MAAM,KAAKxB,qBAAqB,CAACmB,OAAO,IACxCK,MAAM,KAAKvB,oBAAoB,CAACkB,OAAO,EACtC;QACDD,KAAK,CAAC6B,cAAc,CAAC,CAAC;QACtBvB,MAAM,CAACJ,KAAK,CAAE;UAAEuC,aAAa,EAAE;QAAK,CAAE,CAAC;MACxC;IACD;IAEA,MAAM;MAAEpC;IAAc,CAAC,GAAGmB,IAAI;IAC9B,MAAM;MAAEjB;IAAY,CAAC,GAAGF,aAAa;IACrCE,WAAW,CAACyC,gBAAgB,CAAE,SAAS,EAAEF,kBAAmB,CAAC;IAC7DtB,IAAI,CAACwB,gBAAgB,CAAE,SAAS,EAAEvB,SAAU,CAAC;IAC7CD,IAAI,CAACwB,gBAAgB,CAAE,UAAU,EAAEN,UAAW,CAAC;IAC/C,OAAO,MAAM;MACZnC,WAAW,CAAC0C,mBAAmB,CAAE,SAAS,EAAEH,kBAAmB,CAAC;MAChEtB,IAAI,CAACyB,mBAAmB,CAAE,SAAS,EAAExB,SAAU,CAAC;MAChDD,IAAI,CAACyB,mBAAmB,CAAE,UAAU,EAAEP,UAAW,CAAC;IACnD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMQ,UAAU,GAAG,IAAAC,qBAAY,EAAE,CAAEvE,SAAS,EAAEuC,GAAG,CAAG,CAAC;EAErD,OAAO,CAAEF,MAAM,EAAEiC,UAAU,EAAE5B,KAAK,CAAE;AACrC","ignoreList":[]}
1
+ {"version":3,"names":["_dom","require","_keycodes","_data","_compose","_element","_store","_dom2","_lockUnlock","_jsxRuntime","useTabNav","container","useRef","focusCaptureBeforeRef","focusCaptureAfterRef","hasMultiSelection","getSelectedBlockClientId","getBlockCount","useSelect","blockEditorStore","setNavigationMode","setLastFocus","unlock","useDispatch","isNavigationMode","select","getLastFocus","focusCaptureTabIndex","undefined","noCaptureRef","onFocusCapture","event","current","focus","querySelector","canvasElement","ownerDocument","target","defaultView","frameElement","isBefore","compareDocumentPosition","DOCUMENT_POSITION_FOLLOWING","tabbables","tabbable","find","length","next","before","jsx","ref","tabIndex","onFocus","after","useRefEffect","node","onKeyDown","defaultPrevented","keyCode","ESCAPE","preventDefault","TAB","isShift","shiftKey","direction","nextTabbable","currentBlock","closest","isElementPartOfSelectedBlock","isInSameBlock","isInsideRootBlock","isFormElement","preventScroll","onFocusOut","relatedTarget","activeElement","body","preventScrollOnTab","getAttribute","addEventListener","removeEventListener","mergedRefs","useMergeRefs"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-tab-nav.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { focus, isFormElement } from '@wordpress/dom';\nimport { TAB, ESCAPE } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { isInSameBlock, isInsideRootBlock } from '../../utils/dom';\nimport { unlock } from '../../lock-unlock';\n\nexport default function useTabNav() {\n\tconst container = useRef();\n\tconst focusCaptureBeforeRef = useRef();\n\tconst focusCaptureAfterRef = useRef();\n\n\tconst { hasMultiSelection, getSelectedBlockClientId, getBlockCount } =\n\t\tuseSelect( blockEditorStore );\n\tconst { setNavigationMode, setLastFocus } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\tconst isNavigationMode = useSelect(\n\t\t( select ) => select( blockEditorStore ).isNavigationMode(),\n\t\t[]\n\t);\n\n\tconst { getLastFocus } = unlock( useSelect( blockEditorStore ) );\n\n\t// Don't allow tabbing to this element in Navigation mode.\n\tconst focusCaptureTabIndex = ! isNavigationMode ? '0' : undefined;\n\n\t// Reference that holds the a flag for enabling or disabling\n\t// capturing on the focus capture elements.\n\tconst noCaptureRef = useRef();\n\n\tfunction onFocusCapture( event ) {\n\t\t// Do not capture incoming focus if set by us in WritingFlow.\n\t\tif ( noCaptureRef.current ) {\n\t\t\tnoCaptureRef.current = null;\n\t\t} else if ( hasMultiSelection() ) {\n\t\t\tcontainer.current.focus();\n\t\t} else if ( getSelectedBlockClientId() ) {\n\t\t\tif ( getLastFocus()?.current ) {\n\t\t\t\tgetLastFocus().current.focus();\n\t\t\t} else {\n\t\t\t\t// Handles when the last focus has not been set yet, or has been cleared by new blocks being added via the inserter.\n\t\t\t\tcontainer.current\n\t\t\t\t\t.querySelector(\n\t\t\t\t\t\t`[data-block=\"${ getSelectedBlockClientId() }\"]`\n\t\t\t\t\t)\n\t\t\t\t\t.focus();\n\t\t\t}\n\t\t} else {\n\t\t\tsetNavigationMode( true );\n\n\t\t\tconst canvasElement =\n\t\t\t\tcontainer.current.ownerDocument === event.target.ownerDocument\n\t\t\t\t\t? container.current\n\t\t\t\t\t: container.current.ownerDocument.defaultView.frameElement;\n\n\t\t\tconst isBefore =\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tevent.target.compareDocumentPosition( canvasElement ) &\n\t\t\t\tevent.target.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tconst tabbables = focus.tabbable.find( container.current );\n\n\t\t\tif ( tabbables.length ) {\n\t\t\t\tconst next = isBefore\n\t\t\t\t\t? tabbables[ 0 ]\n\t\t\t\t\t: tabbables[ tabbables.length - 1 ];\n\n\t\t\t\tnext.focus();\n\t\t\t}\n\t\t}\n\t}\n\n\tconst before = (\n\t\t<div\n\t\t\tref={ focusCaptureBeforeRef }\n\t\t\ttabIndex={ focusCaptureTabIndex }\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst after = (\n\t\t<div\n\t\t\tref={ focusCaptureAfterRef }\n\t\t\ttabIndex={ focusCaptureTabIndex }\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst ref = useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ESCAPE && ! hasMultiSelection() ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetNavigationMode( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// In Edit mode, Tab should focus the first tabbable element after\n\t\t\t// the content, which is normally the sidebar (with block controls)\n\t\t\t// and Shift+Tab should focus the first tabbable element before the\n\t\t\t// content, which is normally the block toolbar.\n\t\t\t// Arrow keys can be used, and Tab and arrow keys can be used in\n\t\t\t// Navigation mode (press Esc), to navigate through blocks.\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\n\t\t\tif ( ! hasMultiSelection() && ! getSelectedBlockClientId() ) {\n\t\t\t\t// Preserve the behaviour of entering navigation mode when\n\t\t\t\t// tabbing into the content without a block selection.\n\t\t\t\t// `onFocusCapture` already did this previously, but we need to\n\t\t\t\t// do it again here because after clearing block selection,\n\t\t\t\t// focus land on the writing flow container and pressing Tab\n\t\t\t\t// will no longer send focus through the focus capture element.\n\t\t\t\tif ( event.target === node ) {\n\t\t\t\t\tsetNavigationMode( true );\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nextTabbable = focus.tabbable[ direction ]( event.target );\n\n\t\t\t// We want to constrain the tabbing to the block and its child blocks.\n\t\t\t// If the preceding form element is within a different block,\n\t\t\t// such as two sibling image blocks in the placeholder state,\n\t\t\t// we want shift + tab from the first form element to move to the image\n\t\t\t// block toolbar and not the previous image block's form element.\n\t\t\tconst currentBlock = event.target.closest( '[data-block]' );\n\t\t\tconst isElementPartOfSelectedBlock =\n\t\t\t\tcurrentBlock &&\n\t\t\t\tnextTabbable &&\n\t\t\t\t( isInSameBlock( currentBlock, nextTabbable ) ||\n\t\t\t\t\tisInsideRootBlock( currentBlock, nextTabbable ) );\n\n\t\t\t// Allow tabbing from the block wrapper to a form element,\n\t\t\t// and between form elements rendered in a block and its child blocks,\n\t\t\t// such as inside a placeholder. Form elements are generally\n\t\t\t// meant to be UI rather than part of the content. Ideally\n\t\t\t// these are not rendered in the content and perhaps in the\n\t\t\t// future they can be rendered in an iframe or shadow DOM.\n\t\t\tif (\n\t\t\t\tisFormElement( nextTabbable ) &&\n\t\t\t\tisElementPartOfSelectedBlock\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef;\n\n\t\t\t// Disable focus capturing on the focus capture element, so it\n\t\t\t// doesn't refocus this block and so it allows default behaviour\n\t\t\t// (moving focus to the next tabbable element).\n\t\t\tnoCaptureRef.current = true;\n\n\t\t\t// Focusing the focus capture element, which is located above and\n\t\t\t// below the editor, should not scroll the page all the way up or\n\t\t\t// down.\n\t\t\tnext.current.focus( { preventScroll: true } );\n\t\t}\n\n\t\tfunction onFocusOut( event ) {\n\t\t\tsetLastFocus( { ...getLastFocus(), current: event.target } );\n\n\t\t\tconst { ownerDocument } = node;\n\n\t\t\t// If focus disappears due to there being no blocks, move focus to\n\t\t\t// the writing flow wrapper.\n\t\t\tif (\n\t\t\t\t! event.relatedTarget &&\n\t\t\t\townerDocument.activeElement === ownerDocument.body &&\n\t\t\t\tgetBlockCount() === 0\n\t\t\t) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t}\n\n\t\t// When tabbing back to an element in block list, this event handler prevents scrolling if the\n\t\t// focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph\n\t\t// when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the\n\t\t// top or bottom of the document.\n\t\t//\n\t\t// Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this\n\t\t// earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters\n\t\tfunction preventScrollOnTab( event ) {\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.target?.getAttribute( 'role' ) === 'region' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( container.current === event.target ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst target = focus.tabbable[ direction ]( event.target );\n\t\t\t// Only do something when the next tabbable is a focus capture div (before/after)\n\t\t\tif (\n\t\t\t\ttarget === focusCaptureBeforeRef.current ||\n\t\t\t\ttarget === focusCaptureAfterRef.current\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\ttarget.focus( { preventScroll: true } );\n\t\t\t}\n\t\t}\n\n\t\tconst { ownerDocument } = node;\n\t\tconst { defaultView } = ownerDocument;\n\t\tdefaultView.addEventListener( 'keydown', preventScrollOnTab );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'focusout', onFocusOut );\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'keydown', preventScrollOnTab );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'focusout', onFocusOut );\n\t\t};\n\t}, [] );\n\n\tconst mergedRefs = useMergeRefs( [ container, ref ] );\n\n\treturn [ before, mergedRefs, after ];\n}\n"],"mappings":";;;;;;AAGA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAA2C,IAAAQ,WAAA,GAAAR,OAAA;AAd3C;AACA;A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pC;IAAc,CAAC,GAAGmB,IAAI;IAC9B,MAAM;MAAEjB;IAAY,CAAC,GAAGF,aAAa;IACrCE,WAAW,CAACyC,gBAAgB,CAAE,SAAS,EAAEF,kBAAmB,CAAC;IAC7DtB,IAAI,CAACwB,gBAAgB,CAAE,SAAS,EAAEvB,SAAU,CAAC;IAC7CD,IAAI,CAACwB,gBAAgB,CAAE,UAAU,EAAEN,UAAW,CAAC;IAC/C,OAAO,MAAM;MACZnC,WAAW,CAAC0C,mBAAmB,CAAE,SAAS,EAAEH,kBAAmB,CAAC;MAChEtB,IAAI,CAACyB,mBAAmB,CAAE,SAAS,EAAExB,SAAU,CAAC;MAChDD,IAAI,CAACyB,mBAAmB,CAAE,UAAU,EAAEP,UAAW,CAAC;IACnD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMQ,UAAU,GAAG,IAAAC,qBAAY,EAAE,CAAEvE,SAAS,EAAEuC,GAAG,CAAG,CAAC;EAErD,OAAO,CAAEF,MAAM,EAAEiC,UAAU,EAAE5B,KAAK,CAAE;AACrC","ignoreList":[]}
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getPasteBlocks = getPasteBlocks;
7
+ exports.getSelectionRoot = getSelectionRoot;
7
8
  exports.requiresWrapperOnCopy = void 0;
8
9
  exports.setClipboardBlocks = setClipboardBlocks;
9
10
  var _dom = require("@wordpress/dom");
@@ -100,4 +101,30 @@ function toPlainText(html) {
100
101
  // Merge any consecutive line breaks
101
102
  return plainText.replace(/\n\n+/g, '\n\n');
102
103
  }
104
+
105
+ /**
106
+ * Gets the current content editable root element based on the selection.
107
+ * @param {Document} ownerDocument
108
+ * @return {Element|undefined} The content editable root element.
109
+ */
110
+ function getSelectionRoot(ownerDocument) {
111
+ const {
112
+ defaultView
113
+ } = ownerDocument;
114
+ const {
115
+ anchorNode,
116
+ focusNode
117
+ } = defaultView.getSelection();
118
+ if (!anchorNode || !focusNode) {
119
+ return;
120
+ }
121
+ const anchorElement = (anchorNode.nodeType === anchorNode.ELEMENT_NODE ? anchorNode : anchorNode.parentElement).closest('[contenteditable]');
122
+ if (!anchorElement) {
123
+ return;
124
+ }
125
+ if (!anchorElement.contains(focusNode)) {
126
+ return;
127
+ }
128
+ return anchorElement;
129
+ }
103
130
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_dom","require","_blocks2","_pasting","_store","requiresWrapperOnCopy","exports","Symbol","setClipboardBlocks","event","blocks","registry","_blocks","firstBlock","firstBlockType","select","blocksStore","getBlockType","name","getBlockRootClientId","getBlockName","getBlockAttributes","blockEditorStore","wrapperBlockClientId","clientId","wrapperBlockName","createBlock","serialized","serialize","clipboardData","setData","toPlainText","getPasteBlocks","canUserUseUnfilteredHTML","plainText","html","files","getPasteEventData","length","fromTransforms","getBlockTransforms","reduce","accumulator","file","transformation","findTransform","transform","type","isMatch","push","flat","pasteHandler","HTML","mode","replace","stripHTML","trim"],"sources":["@wordpress/block-editor/src/components/writing-flow/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport {\n\tserialize,\n\tcreateBlock,\n\tpasteHandler,\n\tfindTransform,\n\tgetBlockTransforms,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { getPasteEventData } from '../../utils/pasting';\nimport { store as blockEditorStore } from '../../store';\n\nexport const requiresWrapperOnCopy = Symbol( 'requiresWrapperOnCopy' );\n\n/**\n * Sets the clipboard data for the provided blocks, with both HTML and plain\n * text representations.\n *\n * @param {ClipboardEvent} event Clipboard event.\n * @param {WPBlock[]} blocks Blocks to set as clipboard data.\n * @param {Object} registry The registry to select from.\n */\nexport function setClipboardBlocks( event, blocks, registry ) {\n\tlet _blocks = blocks;\n\n\tconst [ firstBlock ] = blocks;\n\n\tif ( firstBlock ) {\n\t\tconst firstBlockType = registry\n\t\t\t.select( blocksStore )\n\t\t\t.getBlockType( firstBlock.name );\n\n\t\tif ( firstBlockType[ requiresWrapperOnCopy ] ) {\n\t\t\tconst { getBlockRootClientId, getBlockName, getBlockAttributes } =\n\t\t\t\tregistry.select( blockEditorStore );\n\t\t\tconst wrapperBlockClientId = getBlockRootClientId(\n\t\t\t\tfirstBlock.clientId\n\t\t\t);\n\t\t\tconst wrapperBlockName = getBlockName( wrapperBlockClientId );\n\n\t\t\tif ( wrapperBlockName ) {\n\t\t\t\t_blocks = createBlock(\n\t\t\t\t\twrapperBlockName,\n\t\t\t\t\tgetBlockAttributes( wrapperBlockClientId ),\n\t\t\t\t\t_blocks\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst serialized = serialize( _blocks );\n\n\tevent.clipboardData.setData( 'text/plain', toPlainText( serialized ) );\n\tevent.clipboardData.setData( 'text/html', serialized );\n}\n\n/**\n * Returns the blocks to be pasted from the clipboard event.\n *\n * @param {ClipboardEvent} event The clipboard event.\n * @param {boolean} canUserUseUnfilteredHTML Whether the user can or can't post unfiltered HTML.\n * @return {Array|string} A list of blocks or a string, depending on `handlerMode`.\n */\nexport function getPasteBlocks( event, canUserUseUnfilteredHTML ) {\n\tconst { plainText, html, files } = getPasteEventData( event );\n\tlet blocks = [];\n\n\tif ( files.length ) {\n\t\tconst fromTransforms = getBlockTransforms( 'from' );\n\t\tblocks = files\n\t\t\t.reduce( ( accumulator, file ) => {\n\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\tfromTransforms,\n\t\t\t\t\t( transform ) =>\n\t\t\t\t\t\ttransform.type === 'files' &&\n\t\t\t\t\t\ttransform.isMatch( [ file ] )\n\t\t\t\t);\n\t\t\t\tif ( transformation ) {\n\t\t\t\t\taccumulator.push( transformation.transform( [ file ] ) );\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t}, [] )\n\t\t\t.flat();\n\t} else {\n\t\tblocks = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t\tmode: 'BLOCKS',\n\t\t\tcanUserUseUnfilteredHTML,\n\t\t} );\n\t}\n\n\treturn blocks;\n}\n\n/**\n * Given a string of HTML representing serialized blocks, returns the plain\n * text extracted after stripping the HTML of any tags and fixing line breaks.\n *\n * @param {string} html Serialized blocks.\n * @return {string} The plain-text content with any html removed.\n */\nfunction toPlainText( html ) {\n\t// Manually handle BR tags as line breaks prior to `stripHTML` call\n\thtml = html.replace( /<br>/g, '\\n' );\n\n\tconst plainText = stripHTML( html ).trim();\n\n\t// Merge any consecutive line breaks\n\treturn plainText.replace( /\\n\\n+/g, '\\n\\n' );\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAYA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAjBA;AACA;AACA;;AAWA;AACA;AACA;;AAIO,MAAMI,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,GAAGE,MAAM,CAAE,uBAAwB,CAAC;;AAEtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,kBAAkBA,CAAEC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,EAAG;EAC7D,IAAIC,OAAO,GAAGF,MAAM;EAEpB,MAAM,CAAEG,UAAU,CAAE,GAAGH,MAAM;EAE7B,IAAKG,UAAU,EAAG;IACjB,MAAMC,cAAc,GAAGH,QAAQ,CAC7BI,MAAM,CAAEC,cAAY,CAAC,CACrBC,YAAY,CAAEJ,UAAU,CAACK,IAAK,CAAC;IAEjC,IAAKJ,cAAc,CAAET,qBAAqB,CAAE,EAAG;MAC9C,MAAM;QAAEc,oBAAoB;QAAEC,YAAY;QAAEC;MAAmB,CAAC,GAC/DV,QAAQ,CAACI,MAAM,CAAEO,YAAiB,CAAC;MACpC,MAAMC,oBAAoB,GAAGJ,oBAAoB,CAChDN,UAAU,CAACW,QACZ,CAAC;MACD,MAAMC,gBAAgB,GAAGL,Y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I,EAAEjB,IAAI;MACVD,SAAS;MACTmB,IAAI,EAAE,QAAQ;MACdpB;IACD,CAAE,CAAC;EACJ;EAEA,OAAOvB,MAAM;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASqB,WAAWA,CAAEI,IAAI,EAAG;EAC5B;EACAA,IAAI,GAAGA,IAAI,CAACmB,OAAO,CAAE,OAAO,EAAE,IAAK,CAAC;EAEpC,MAAMpB,SAAS,GAAG,IAAAqB,wBAAS,EAAEpB,IAAK,CAAC,CAACqB,IAAI,CAAC,CAAC;;EAE1C;EACA,OAAOtB,SAAS,CAACoB,OAAO,CAAE,QAAQ,EAAE,MAAO,CAAC;AAC7C","ignoreList":[]}
1
+ {"version":3,"names":["_dom","require","_blocks2","_pasting","_store","requiresWrapperOnCopy","exports","Symbol","setClipboardBlocks","event","blocks","registry","_blocks","firstBlock","firstBlockType","select","blocksStore","getBlockType","name","getBlockRootClientId","getBlockName","getBlockAttributes","blockEditorStore","wrapperBlockClientId","clientId","wrapperBlockName","createBlock","serialized","serialize","clipboardData","setData","toPlainText","getPasteBlocks","canUserUseUnfilteredHTML","plainText","html","files","getPasteEventData","length","fromTransforms","getBlockTransforms","reduce","accumulator","file","transformation","findTransform","transform","type","isMatch","push","flat","pasteHandler","HTML","mode","replace","stripHTML","trim","getSelectionRoot","ownerDocument","defaultView","anchorNode","focusNode","getSelection","anchorElement","nodeType","ELEMENT_NODE","parentElement","closest","contains"],"sources":["@wordpress/block-editor/src/components/writing-flow/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport {\n\tserialize,\n\tcreateBlock,\n\tpasteHandler,\n\tfindTransform,\n\tgetBlockTransforms,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { getPasteEventData } from '../../utils/pasting';\nimport { store as blockEditorStore } from '../../store';\n\nexport const requiresWrapperOnCopy = Symbol( 'requiresWrapperOnCopy' );\n\n/**\n * Sets the clipboard data for the provided blocks, with both HTML and plain\n * text representations.\n *\n * @param {ClipboardEvent} event Clipboard event.\n * @param {WPBlock[]} blocks Blocks to set as clipboard data.\n * @param {Object} registry The registry to select from.\n */\nexport function setClipboardBlocks( event, blocks, registry ) {\n\tlet _blocks = blocks;\n\n\tconst [ firstBlock ] = blocks;\n\n\tif ( firstBlock ) {\n\t\tconst firstBlockType = registry\n\t\t\t.select( blocksStore )\n\t\t\t.getBlockType( firstBlock.name );\n\n\t\tif ( firstBlockType[ requiresWrapperOnCopy ] ) {\n\t\t\tconst { getBlockRootClientId, getBlockName, getBlockAttributes } =\n\t\t\t\tregistry.select( blockEditorStore );\n\t\t\tconst wrapperBlockClientId = getBlockRootClientId(\n\t\t\t\tfirstBlock.clientId\n\t\t\t);\n\t\t\tconst wrapperBlockName = getBlockName( wrapperBlockClientId );\n\n\t\t\tif ( wrapperBlockName ) {\n\t\t\t\t_blocks = createBlock(\n\t\t\t\t\twrapperBlockName,\n\t\t\t\t\tgetBlockAttributes( wrapperBlockClientId ),\n\t\t\t\t\t_blocks\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst serialized = serialize( _blocks );\n\n\tevent.clipboardData.setData( 'text/plain', toPlainText( serialized ) );\n\tevent.clipboardData.setData( 'text/html', serialized );\n}\n\n/**\n * Returns the blocks to be pasted from the clipboard event.\n *\n * @param {ClipboardEvent} event The clipboard event.\n * @param {boolean} canUserUseUnfilteredHTML Whether the user can or can't post unfiltered HTML.\n * @return {Array|string} A list of blocks or a string, depending on `handlerMode`.\n */\nexport function getPasteBlocks( event, canUserUseUnfilteredHTML ) {\n\tconst { plainText, html, files } = getPasteEventData( event );\n\tlet blocks = [];\n\n\tif ( files.length ) {\n\t\tconst fromTransforms = getBlockTransforms( 'from' );\n\t\tblocks = files\n\t\t\t.reduce( ( accumulator, file ) => {\n\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\tfromTransforms,\n\t\t\t\t\t( transform ) =>\n\t\t\t\t\t\ttransform.type === 'files' &&\n\t\t\t\t\t\ttransform.isMatch( [ file ] )\n\t\t\t\t);\n\t\t\t\tif ( transformation ) {\n\t\t\t\t\taccumulator.push( transformation.transform( [ file ] ) );\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t}, [] )\n\t\t\t.flat();\n\t} else {\n\t\tblocks = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t\tmode: 'BLOCKS',\n\t\t\tcanUserUseUnfilteredHTML,\n\t\t} );\n\t}\n\n\treturn blocks;\n}\n\n/**\n * Given a string of HTML representing serialized blocks, returns the plain\n * text extracted after stripping the HTML of any tags and fixing line breaks.\n *\n * @param {string} html Serialized blocks.\n * @return {string} The plain-text content with any html removed.\n */\nfunction toPlainText( html ) {\n\t// Manually handle BR tags as line breaks prior to `stripHTML` call\n\thtml = html.replace( /<br>/g, '\\n' );\n\n\tconst plainText = stripHTML( html ).trim();\n\n\t// Merge any consecutive line breaks\n\treturn plainText.replace( /\\n\\n+/g, '\\n\\n' );\n}\n\n/**\n * Gets the current content editable root element based on the selection.\n * @param {Document} ownerDocument\n * @return {Element|undefined} The content editable root element.\n */\nexport function getSelectionRoot( ownerDocument ) {\n\tconst { defaultView } = ownerDocument;\n\tconst { anchorNode, focusNode } = defaultView.getSelection();\n\n\tif ( ! anchorNode || ! focusNode ) {\n\t\treturn;\n\t}\n\n\tconst anchorElement = (\n\t\tanchorNode.nodeType === anchorNode.ELEMENT_NODE\n\t\t\t? anchorNode\n\t\t\t: anchorNode.parentElement\n\t).closest( '[contenteditable]' );\n\n\tif ( ! anchorElement ) {\n\t\treturn;\n\t}\n\n\tif ( ! anchorElement.contains( focusNode ) ) {\n\t\treturn;\n\t}\n\n\treturn anchorElement;\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAYA,IAAAE,QAAA,GAAAF,OAAA;AACA,IA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AM;IAAEC;EAAY,CAAC,GAAGD,aAAa;EACrC,MAAM;IAAEE,UAAU;IAAEC;EAAU,CAAC,GAAGF,WAAW,CAACG,YAAY,CAAC,CAAC;EAE5D,IAAK,CAAEF,UAAU,IAAI,CAAEC,SAAS,EAAG;IAClC;EACD;EAEA,MAAME,aAAa,GAAG,CACrBH,UAAU,CAACI,QAAQ,KAAKJ,UAAU,CAACK,YAAY,GAC5CL,UAAU,GACVA,UAAU,CAACM,aAAa,EAC1BC,OAAO,CAAE,mBAAoB,CAAC;EAEhC,IAAK,CAAEJ,aAAa,EAAG;IACtB;EACD;EAEA,IAAK,CAAEA,aAAa,CAACK,QAAQ,CAAEP,SAAU,CAAC,EAAG;IAC5C;EACD;EAEA,OAAOE,aAAa;AACrB","ignoreList":[]}
@@ -16,6 +16,7 @@ var _lockUnlock = require("../lock-unlock");
16
16
  var _inspectorControls = _interopRequireDefault(require("../components/inspector-controls"));
17
17
  var _blockContext = _interopRequireDefault(require("../components/block-context"));
18
18
  var _blockBindings = require("../utils/block-bindings");
19
+ var _store = require("../store");
19
20
  var _jsxRuntime = require("react/jsx-runtime");
20
21
  /**
21
22
  * WordPress dependencies
@@ -26,12 +27,7 @@ var _jsxRuntime = require("react/jsx-runtime");
26
27
  */
27
28
 
28
29
  const {
29
- DropdownMenuV2: DropdownMenu,
30
- DropdownMenuGroupV2: DropdownMenuGroup,
31
- DropdownMenuRadioItemV2: DropdownMenuRadioItem,
32
- DropdownMenuItemLabelV2: DropdownMenuItemLabel,
33
- DropdownMenuItemHelpTextV2: DropdownMenuItemHelpText,
34
- DropdownMenuSeparatorV2: DropdownMenuSeparator
30
+ DropdownMenuV2
35
31
  } = (0, _lockUnlock.unlock)(_components.privateApis);
36
32
  const useToolsPanelDropdownMenuProps = () => {
37
33
  const isMobile = (0, _compose.useViewportMatch)('medium', '<');
@@ -58,14 +54,10 @@ function BlockBindingsPanelDropdown({
58
54
  const currentKey = binding?.args?.key;
59
55
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
60
56
  children: Object.entries(fieldsList).map(([name, fields], i) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_element.Fragment, {
61
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(DropdownMenuGroup, {
62
- children: [Object.keys(fieldsList).length > 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalText, {
63
- className: "block-editor-bindings__source-label",
64
- upperCase: true,
65
- variant: "muted",
66
- "aria-hidden": true,
57
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(DropdownMenuV2.Group, {
58
+ children: [Object.keys(fieldsList).length > 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(DropdownMenuV2.GroupLabel, {
67
59
  children: registeredSources[name].label
68
- }), Object.entries(fields).map(([key, value]) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(DropdownMenuRadioItem, {
60
+ }), Object.entries(fields).map(([key, value]) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(DropdownMenuV2.RadioItem, {
69
61
  onChange: () => updateBlockBindings({
70
62
  [attribute]: {
71
63
  source: name,
@@ -77,13 +69,13 @@ function BlockBindingsPanelDropdown({
77
69
  name: attribute + '-binding',
78
70
  value: key,
79
71
  checked: key === currentKey,
80
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(DropdownMenuItemLabel, {
72
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(DropdownMenuV2.ItemLabel, {
81
73
  children: key
82
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(DropdownMenuItemHelpText, {
74
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(DropdownMenuV2.ItemHelpText, {
83
75
  children: value
84
76
  })]
85
77
  }, key))]
86
- }), i !== Object.keys(fieldsList).length - 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(DropdownMenuSeparator, {})]
78
+ }), i !== Object.keys(fieldsList).length - 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(DropdownMenuV2.Separator, {})]
87
79
  }, name))
88
80
  });
89
81
  }
@@ -96,15 +88,18 @@ function BlockBindingsAttribute({
96
88
  args
97
89
  } = binding || {};
98
90
  const sourceProps = (0, _lockUnlock.unlock)(_blocks.privateApis).getBlockBindingsSource(sourceName);
91
+ const isSourceInvalid = !sourceProps;
99
92
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
100
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalTruncate, {
93
+ className: "block-editor-bindings__item",
94
+ spacing: 0,
95
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalText, {
96
+ truncate: true,
101
97
  children: attribute
102
98
  }), !!binding && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalText, {
103
- variant: "muted",
104
- className: "block-editor-bindings__item-explanation",
105
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalTruncate, {
106
- children: args?.key || sourceProps?.label || sourceName
107
- })
99
+ truncate: true,
100
+ variant: !isSourceInvalid && 'muted',
101
+ isDestructive: isSourceInvalid,
102
+ children: isSourceInvalid ? (0, _i18n.__)('Invalid source') : args?.key || sourceProps?.label || sourceName
108
103
  })]
109
104
  });
110
105
  }
@@ -140,10 +135,9 @@ function EditableBlockBindingsPanelItems({
140
135
  [attribute]: undefined
141
136
  });
142
137
  },
143
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(DropdownMenu, {
138
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(DropdownMenuV2, {
144
139
  placement: isMobile ? 'bottom-start' : 'left-start',
145
140
  gutter: isMobile ? 8 : 36,
146
- className: "block-editor-bindings__popover",
147
141
  trigger: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalItem, {
148
142
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(BlockBindingsAttribute, {
149
143
  attribute: attribute,
@@ -182,6 +176,13 @@ const BlockBindingsPanel = ({
182
176
  delete filteredBindings[key];
183
177
  }
184
178
  });
179
+ const {
180
+ canUpdateBlockBindings
181
+ } = (0, _data.useSelect)(select => {
182
+ return {
183
+ canUpdateBlockBindings: select(_store.store).getSettings().canUpdateBlockBindings
184
+ };
185
+ }, []);
185
186
  if (!bindableAttributes || bindableAttributes.length === 0) {
186
187
  return null;
187
188
  }
@@ -221,12 +222,13 @@ const BlockBindingsPanel = ({
221
222
  }
222
223
  });
223
224
 
224
- // Lock the UI when the experiment is not enabled or there are no fields to connect to.
225
- const readOnly = !window.__experimentalBlockBindingsUI || !Object.keys(fieldsList).length;
225
+ // Lock the UI when the user can't update bindings or there are no fields to connect to.
226
+ const readOnly = !canUpdateBlockBindings || !Object.keys(fieldsList).length;
226
227
  if (readOnly && Object.keys(filteredBindings).length === 0) {
227
228
  return null;
228
229
  }
229
230
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_inspectorControls.default, {
231
+ group: "bindings",
230
232
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalToolsPanel, {
231
233
  label: (0, _i18n.__)('Attributes'),
232
234
  resetAll: () => {
@@ -244,9 +246,11 @@ const BlockBindingsPanel = ({
244
246
  bindings: filteredBindings,
245
247
  fieldsList: fieldsList
246
248
  })
247
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalText, {
248
- variant: "muted",
249
- children: (0, _i18n.__)('Attributes connected to various sources.')
249
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalItemGroup, {
250
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalText, {
251
+ variant: "muted",
252
+ children: (0, _i18n.__)('Attributes connected to custom fields or other dynamic data.')
253
+ })
250
254
  })]
251
255
  })
252
256
  });
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_blocks","_components","_data","_element","_compose","_useBindingsAttributes","_lockUnlock","_inspectorControls","_interopRequireDefault","_blockContext","_blockBindings","_jsxRuntime","DropdownMenuV2","DropdownMenu","DropdownMenuGroupV2","DropdownMenuGroup","DropdownMenuRadioItemV2","DropdownMenuRadioItem","DropdownMenuItemLabelV2","DropdownMenuItemLabel","DropdownMenuItemHelpTextV2","DropdownMenuItemHelpText","DropdownMenuSeparatorV2","DropdownMenuSeparator","unlock","componentsPrivateApis","useToolsPanelDropdownMenuProps","isMobile","useViewportMatch","popoverProps","placement","offset","BlockBindingsPanelDropdown","fieldsList","attribute","binding","getBlockBindingsSources","blocksPrivateApis","registeredSources","updateBlockBindings","useBlockBindingsUtils","currentKey","args","key","jsx","Fragment","children","Object","entries","map","name","fields","i","jsxs","keys","length","__experimentalText","className","upperCase","variant","label","value","onChange","source","checked","BlockBindingsAttribute","sourceName","sourceProps","getBlockBindingsSource","__experimentalVStack","__experimentalTruncate","ReadOnlyBlockBindingsPanelItems","bindings","__experimentalItem","EditableBlockBindingsPanelItems","attributes","__experimentalToolsPanelItem","hasValue","onDeselect","undefined","gutter","trigger","BlockBindingsPanel","blockName","metadata","registry","useRegistry","blockContext","useContext","BlockContext","removeAllBlockBindings","bindableAttributes","getBindableAttributes","dropdownMenuProps","filteredBindings","forEach","canBindAttribute","getFieldsList","usesContext","context","sourceList","readOnly","window","__experimentalBlockBindingsUI","default","__experimentalToolsPanel","__","resetAll","__experimentalItemGroup","isBordered","isSeparated","exports","_default","edit","attributeKeys","hasSupport"],"sources":["@wordpress/block-editor/src/hooks/block-bindings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { privateApis as blocksPrivateApis } from '@wordpress/blocks';\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n\t__experimentalText as Text,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalTruncate as Truncate,\n\t__experimentalVStack as VStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useRegistry } from '@wordpress/data';\nimport { useContext, Fragment } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tcanBindAttribute,\n\tgetBindableAttributes,\n} from '../hooks/use-bindings-attributes';\nimport { unlock } from '../lock-unlock';\nimport InspectorControls from '../components/inspector-controls';\nimport BlockContext from '../components/block-context';\nimport { useBlockBindingsUtils } from '../utils/block-bindings';\n\nconst {\n\tDropdownMenuV2: DropdownMenu,\n\tDropdownMenuGroupV2: DropdownMenuGroup,\n\tDropdownMenuRadioItemV2: DropdownMenuRadioItem,\n\tDropdownMenuItemLabelV2: DropdownMenuItemLabel,\n\tDropdownMenuItemHelpTextV2: DropdownMenuItemHelpText,\n\tDropdownMenuSeparatorV2: DropdownMenuSeparator,\n} = unlock( componentsPrivateApis );\n\nconst useToolsPanelDropdownMenuProps = () => {\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\treturn ! isMobile\n\t\t? {\n\t\t\t\tpopoverProps: {\n\t\t\t\t\tplacement: 'left-start',\n\t\t\t\t\t// For non-mobile, inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px)\n\t\t\t\t\toffset: 259,\n\t\t\t\t},\n\t\t }\n\t\t: {};\n};\n\nfunction BlockBindingsPanelDropdown( { fieldsList, attribute, binding } ) {\n\tconst { getBlockBindingsSources } = unlock( blocksPrivateApis );\n\tconst registeredSources = getBlockBindingsSources();\n\tconst { updateBlockBindings } = useBlockBindingsUtils();\n\tconst currentKey = binding?.args?.key;\n\treturn (\n\t\t<>\n\t\t\t{ Object.entries( fieldsList ).map( ( [ name, fields ], i ) => (\n\t\t\t\t<Fragment key={ name }>\n\t\t\t\t\t<DropdownMenuGroup>\n\t\t\t\t\t\t{ Object.keys( fieldsList ).length > 1 && (\n\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\tclassName=\"block-editor-bindings__source-label\"\n\t\t\t\t\t\t\t\tupperCase\n\t\t\t\t\t\t\t\tvariant=\"muted\"\n\t\t\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ registeredSources[ name ].label }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ Object.entries( fields ).map( ( [ key, value ] ) => (\n\t\t\t\t\t\t\t<DropdownMenuRadioItem\n\t\t\t\t\t\t\t\tkey={ key }\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tupdateBlockBindings( {\n\t\t\t\t\t\t\t\t\t\t[ attribute ]: {\n\t\t\t\t\t\t\t\t\t\t\tsource: name,\n\t\t\t\t\t\t\t\t\t\t\targs: { key },\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tname={ attribute + '-binding' }\n\t\t\t\t\t\t\t\tvalue={ key }\n\t\t\t\t\t\t\t\tchecked={ key === currentKey }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<DropdownMenuItemLabel>\n\t\t\t\t\t\t\t\t\t{ key }\n\t\t\t\t\t\t\t\t</DropdownMenuItemLabel>\n\t\t\t\t\t\t\t\t<DropdownMenuItemHelpText>\n\t\t\t\t\t\t\t\t\t{ value }\n\t\t\t\t\t\t\t\t</DropdownMenuItemHelpText>\n\t\t\t\t\t\t\t</DropdownMenuRadioItem>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</DropdownMenuGroup>\n\t\t\t\t\t{ i !== Object.keys( fieldsList ).length - 1 && (\n\t\t\t\t\t\t<DropdownMenuSeparator />\n\t\t\t\t\t) }\n\t\t\t\t</Fragment>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nfunction BlockBindingsAttribute( { attribute, binding } ) {\n\tconst { source: sourceName, args } = binding || {};\n\tconst sourceProps =\n\t\tunlock( blocksPrivateApis ).getBlockBindingsSource( sourceName );\n\treturn (\n\t\t<VStack>\n\t\t\t<Truncate>{ attribute }</Truncate>\n\t\t\t{ !! binding && (\n\t\t\t\t<Text\n\t\t\t\t\tvariant=\"muted\"\n\t\t\t\t\tclassName=\"block-editor-bindings__item-explanation\"\n\t\t\t\t>\n\t\t\t\t\t<Truncate>\n\t\t\t\t\t\t{ args?.key || sourceProps?.label || sourceName }\n\t\t\t\t\t</Truncate>\n\t\t\t\t</Text>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nfunction ReadOnlyBlockBindingsPanelItems( { bindings } ) {\n\treturn (\n\t\t<>\n\t\t\t{ Object.entries( bindings ).map( ( [ attribute, binding ] ) => (\n\t\t\t\t<Item key={ attribute }>\n\t\t\t\t\t<BlockBindingsAttribute\n\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t/>\n\t\t\t\t</Item>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nfunction EditableBlockBindingsPanelItems( {\n\tattributes,\n\tbindings,\n\tfieldsList,\n} ) {\n\tconst { updateBlockBindings } = useBlockBindingsUtils();\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\treturn (\n\t\t<>\n\t\t\t{ attributes.map( ( attribute ) => {\n\t\t\t\tconst binding = bindings[ attribute ];\n\t\t\t\treturn (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tkey={ attribute }\n\t\t\t\t\t\thasValue={ () => !! binding }\n\t\t\t\t\t\tlabel={ attribute }\n\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\tupdateBlockBindings( {\n\t\t\t\t\t\t\t\t[ attribute ]: undefined,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\tplacement={\n\t\t\t\t\t\t\t\tisMobile ? 'bottom-start' : 'left-start'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tgutter={ isMobile ? 8 : 36 }\n\t\t\t\t\t\t\tclassName=\"block-editor-bindings__popover\"\n\t\t\t\t\t\t\ttrigger={\n\t\t\t\t\t\t\t\t<Item>\n\t\t\t\t\t\t\t\t\t<BlockBindingsAttribute\n\t\t\t\t\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</Item>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockBindingsPanelDropdown\n\t\t\t\t\t\t\t\tfieldsList={ fieldsList }\n\t\t\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</DropdownMenu>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\nexport const BlockBindingsPanel = ( { name: blockName, metadata } ) => {\n\tconst registry = useRegistry();\n\tconst blockContext = useContext( BlockContext );\n\tconst { bindings } = metadata || {};\n\tconst { removeAllBlockBindings } = useBlockBindingsUtils();\n\tconst bindableAttributes = getBindableAttributes( blockName );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tconst filteredBindings = { ...bindings };\n\tObject.keys( filteredBindings ).forEach( ( key ) => {\n\t\tif (\n\t\t\t! canBindAttribute( blockName, key ) ||\n\t\t\tfilteredBindings[ key ].source === 'core/pattern-overrides'\n\t\t) {\n\t\t\tdelete filteredBindings[ key ];\n\t\t}\n\t} );\n\n\tif ( ! bindableAttributes || bindableAttributes.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst fieldsList = {};\n\tconst { getBlockBindingsSources } = unlock( blocksPrivateApis );\n\tconst registeredSources = getBlockBindingsSources();\n\tObject.entries( registeredSources ).forEach(\n\t\t( [ sourceName, { getFieldsList, usesContext } ] ) => {\n\t\t\tif ( getFieldsList ) {\n\t\t\t\t// Populate context.\n\t\t\t\tconst context = {};\n\t\t\t\tif ( usesContext?.length ) {\n\t\t\t\t\tfor ( const key of usesContext ) {\n\t\t\t\t\t\tcontext[ key ] = blockContext[ key ];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst sourceList = getFieldsList( {\n\t\t\t\t\tregistry,\n\t\t\t\t\tcontext,\n\t\t\t\t} );\n\t\t\t\t// Only add source if the list is not empty.\n\t\t\t\tif ( sourceList ) {\n\t\t\t\t\tfieldsList[ sourceName ] = { ...sourceList };\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t);\n\t// Remove empty sources.\n\tObject.entries( fieldsList ).forEach( ( [ key, value ] ) => {\n\t\tif ( ! Object.keys( value ).length ) {\n\t\t\tdelete fieldsList[ key ];\n\t\t}\n\t} );\n\n\t// Lock the UI when the experiment is not enabled or there are no fields to connect to.\n\tconst readOnly =\n\t\t! window.__experimentalBlockBindingsUI ||\n\t\t! Object.keys( fieldsList ).length;\n\n\tif ( readOnly && Object.keys( filteredBindings ).length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorControls>\n\t\t\t<ToolsPanel\n\t\t\t\tlabel={ __( 'Attributes' ) }\n\t\t\t\tresetAll={ () => {\n\t\t\t\t\tremoveAllBlockBindings();\n\t\t\t\t} }\n\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\tclassName=\"block-editor-bindings__panel\"\n\t\t\t>\n\t\t\t\t<ItemGroup isBordered isSeparated>\n\t\t\t\t\t{ readOnly ? (\n\t\t\t\t\t\t<ReadOnlyBlockBindingsPanelItems\n\t\t\t\t\t\t\tbindings={ filteredBindings }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<EditableBlockBindingsPanelItems\n\t\t\t\t\t\t\tattributes={ bindableAttributes }\n\t\t\t\t\t\t\tbindings={ filteredBindings }\n\t\t\t\t\t\t\tfieldsList={ fieldsList }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</ItemGroup>\n\t\t\t\t<Text variant=\"muted\">\n\t\t\t\t\t{ __( 'Attributes connected to various sources.' ) }\n\t\t\t\t</Text>\n\t\t\t</ToolsPanel>\n\t\t</InspectorControls>\n\t);\n};\n\nexport default {\n\tedit: BlockBindingsPanel,\n\tattributeKeys: [ 'metadata' ],\n\thasSupport() {\n\t\treturn true;\n\t},\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAUA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAKA,IAAAM,sBAAA,GAAAN,OAAA;AAIA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAC,sBAAA,CAAAT,OAAA;AACA,IAAAU,aAAA,GAAAD,sBAAA,CAAAT,OAAA;AACA,IAAAW,cAAA,GAAAX,OAAA;AAAgE,IAAAY,WAAA,GAAAZ,OAAA;AA7BhE;AACA;AACA;;AAiBA;AACA;AACA;;AAUA,MAAM;EACLa,cAAc,EAAEC,YAAY;EAC5BC,mBAAmB,EAAEC,iBAAiB;EACtCC,uBAAuB,EAAEC,qBAAqB;EAC9CC,uBAAuB,EAAEC,qBAAqB;EAC9CC,0BAA0B,EAAEC,wBAAwB;EACpDC,uBAAuB,EAAEC;AAC1B,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;AAEnC,MAAMC,8BAA8B,GAAGA,CAAA,KAAM;EAC5C,MAAMC,QAAQ,GAAG,IAAAC,yBAAgB,EAAE,QAAQ,EAAE,GAAI,CAAC;EAClD,OAAO,CAAED,QAAQ,GACd;IACAE,YAAY,EAAE;MACbC,SAAS,EAAE,YAAY;MACvB;MACAC,MAAM,EAAE;IACT;EACA,CAAC,GACD,CAAC,CAAC;AACN,CAAC;AAED,SAASC,0BAA0BA,CAAE;EAAEC,UAAU;EAAEC,SAAS;EAAEC;AAAQ,CAAC,EAAG;EACzE,MAAM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AAACK,OAAA,CAAA7B,kBAAA,GAAAA,kBAAA;AAAA,IAAA8B,QAAA,GAAAD,OAAA,CAAAP,OAAA,GAEa;EACdS,IAAI,EAAE/B,kBAAkB;EACxBgC,aAAa,EAAE,CAAE,UAAU,CAAE;EAC7BC,UAAUA,CAAA,EAAG;IACZ,OAAO,IAAI;EACZ;AACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","_blocks","_components","_data","_element","_compose","_useBindingsAttributes","_lockUnlock","_inspectorControls","_interopRequireDefault","_blockContext","_blockBindings","_store","_jsxRuntime","DropdownMenuV2","unlock","componentsPrivateApis","useToolsPanelDropdownMenuProps","isMobile","useViewportMatch","popoverProps","placement","offset","BlockBindingsPanelDropdown","fieldsList","attribute","binding","getBlockBindingsSources","blocksPrivateApis","registeredSources","updateBlockBindings","useBlockBindingsUtils","currentKey","args","key","jsx","Fragment","children","Object","entries","map","name","fields","i","jsxs","Group","keys","length","GroupLabel","label","value","RadioItem","onChange","source","checked","ItemLabel","ItemHelpText","Separator","BlockBindingsAttribute","sourceName","sourceProps","getBlockBindingsSource","isSourceInvalid","__experimentalVStack","className","spacing","__experimentalText","truncate","variant","isDestructive","__","ReadOnlyBlockBindingsPanelItems","bindings","__experimentalItem","EditableBlockBindingsPanelItems","attributes","__experimentalToolsPanelItem","hasValue","onDeselect","undefined","gutter","trigger","BlockBindingsPanel","blockName","metadata","registry","useRegistry","blockContext","useContext","BlockContext","removeAllBlockBindings","bindableAttributes","getBindableAttributes","dropdownMenuProps","filteredBindings","forEach","canBindAttribute","canUpdateBlockBindings","useSelect","select","blockEditorStore","getSettings","getFieldsList","usesContext","context","sourceList","readOnly","default","group","__experimentalToolsPanel","resetAll","__experimentalItemGroup","isBordered","isSeparated","exports","_default","edit","attributeKeys","hasSupport"],"sources":["@wordpress/block-editor/src/hooks/block-bindings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { privateApis as blocksPrivateApis } from '@wordpress/blocks';\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n\t__experimentalText as Text,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalVStack as VStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useContext, Fragment } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tcanBindAttribute,\n\tgetBindableAttributes,\n} from '../hooks/use-bindings-attributes';\nimport { unlock } from '../lock-unlock';\nimport InspectorControls from '../components/inspector-controls';\nimport BlockContext from '../components/block-context';\nimport { useBlockBindingsUtils } from '../utils/block-bindings';\nimport { store as blockEditorStore } from '../store';\n\nconst { DropdownMenuV2 } = unlock( componentsPrivateApis );\n\nconst useToolsPanelDropdownMenuProps = () => {\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\treturn ! isMobile\n\t\t? {\n\t\t\t\tpopoverProps: {\n\t\t\t\t\tplacement: 'left-start',\n\t\t\t\t\t// For non-mobile, inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px)\n\t\t\t\t\toffset: 259,\n\t\t\t\t},\n\t\t }\n\t\t: {};\n};\n\nfunction BlockBindingsPanelDropdown( { fieldsList, attribute, binding } ) {\n\tconst { getBlockBindingsSources } = unlock( blocksPrivateApis );\n\tconst registeredSources = getBlockBindingsSources();\n\tconst { updateBlockBindings } = useBlockBindingsUtils();\n\tconst currentKey = binding?.args?.key;\n\treturn (\n\t\t<>\n\t\t\t{ Object.entries( fieldsList ).map( ( [ name, fields ], i ) => (\n\t\t\t\t<Fragment key={ name }>\n\t\t\t\t\t<DropdownMenuV2.Group>\n\t\t\t\t\t\t{ Object.keys( fieldsList ).length > 1 && (\n\t\t\t\t\t\t\t<DropdownMenuV2.GroupLabel>\n\t\t\t\t\t\t\t\t{ registeredSources[ name ].label }\n\t\t\t\t\t\t\t</DropdownMenuV2.GroupLabel>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ Object.entries( fields ).map( ( [ key, value ] ) => (\n\t\t\t\t\t\t\t<DropdownMenuV2.RadioItem\n\t\t\t\t\t\t\t\tkey={ key }\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tupdateBlockBindings( {\n\t\t\t\t\t\t\t\t\t\t[ attribute ]: {\n\t\t\t\t\t\t\t\t\t\t\tsource: name,\n\t\t\t\t\t\t\t\t\t\t\targs: { key },\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tname={ attribute + '-binding' }\n\t\t\t\t\t\t\t\tvalue={ key }\n\t\t\t\t\t\t\t\tchecked={ key === currentKey }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<DropdownMenuV2.ItemLabel>\n\t\t\t\t\t\t\t\t\t{ key }\n\t\t\t\t\t\t\t\t</DropdownMenuV2.ItemLabel>\n\t\t\t\t\t\t\t\t<DropdownMenuV2.ItemHelpText>\n\t\t\t\t\t\t\t\t\t{ value }\n\t\t\t\t\t\t\t\t</DropdownMenuV2.ItemHelpText>\n\t\t\t\t\t\t\t</DropdownMenuV2.RadioItem>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</DropdownMenuV2.Group>\n\t\t\t\t\t{ i !== Object.keys( fieldsList ).length - 1 && (\n\t\t\t\t\t\t<DropdownMenuV2.Separator />\n\t\t\t\t\t) }\n\t\t\t\t</Fragment>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nfunction BlockBindingsAttribute( { attribute, binding } ) {\n\tconst { source: sourceName, args } = binding || {};\n\tconst sourceProps =\n\t\tunlock( blocksPrivateApis ).getBlockBindingsSource( sourceName );\n\tconst isSourceInvalid = ! sourceProps;\n\treturn (\n\t\t<VStack className=\"block-editor-bindings__item\" spacing={ 0 }>\n\t\t\t<Text truncate>{ attribute }</Text>\n\t\t\t{ !! binding && (\n\t\t\t\t<Text\n\t\t\t\t\ttruncate\n\t\t\t\t\tvariant={ ! isSourceInvalid && 'muted' }\n\t\t\t\t\tisDestructive={ isSourceInvalid }\n\t\t\t\t>\n\t\t\t\t\t{ isSourceInvalid\n\t\t\t\t\t\t? __( 'Invalid source' )\n\t\t\t\t\t\t: args?.key || sourceProps?.label || sourceName }\n\t\t\t\t</Text>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nfunction ReadOnlyBlockBindingsPanelItems( { bindings } ) {\n\treturn (\n\t\t<>\n\t\t\t{ Object.entries( bindings ).map( ( [ attribute, binding ] ) => (\n\t\t\t\t<Item key={ attribute }>\n\t\t\t\t\t<BlockBindingsAttribute\n\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t/>\n\t\t\t\t</Item>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nfunction EditableBlockBindingsPanelItems( {\n\tattributes,\n\tbindings,\n\tfieldsList,\n} ) {\n\tconst { updateBlockBindings } = useBlockBindingsUtils();\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\treturn (\n\t\t<>\n\t\t\t{ attributes.map( ( attribute ) => {\n\t\t\t\tconst binding = bindings[ attribute ];\n\t\t\t\treturn (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tkey={ attribute }\n\t\t\t\t\t\thasValue={ () => !! binding }\n\t\t\t\t\t\tlabel={ attribute }\n\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\tupdateBlockBindings( {\n\t\t\t\t\t\t\t\t[ attribute ]: undefined,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<DropdownMenuV2\n\t\t\t\t\t\t\tplacement={\n\t\t\t\t\t\t\t\tisMobile ? 'bottom-start' : 'left-start'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tgutter={ isMobile ? 8 : 36 }\n\t\t\t\t\t\t\ttrigger={\n\t\t\t\t\t\t\t\t<Item>\n\t\t\t\t\t\t\t\t\t<BlockBindingsAttribute\n\t\t\t\t\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</Item>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockBindingsPanelDropdown\n\t\t\t\t\t\t\t\tfieldsList={ fieldsList }\n\t\t\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</DropdownMenuV2>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\nexport const BlockBindingsPanel = ( { name: blockName, metadata } ) => {\n\tconst registry = useRegistry();\n\tconst blockContext = useContext( BlockContext );\n\tconst { bindings } = metadata || {};\n\tconst { removeAllBlockBindings } = useBlockBindingsUtils();\n\tconst bindableAttributes = getBindableAttributes( blockName );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tconst filteredBindings = { ...bindings };\n\tObject.keys( filteredBindings ).forEach( ( key ) => {\n\t\tif (\n\t\t\t! canBindAttribute( blockName, key ) ||\n\t\t\tfilteredBindings[ key ].source === 'core/pattern-overrides'\n\t\t) {\n\t\t\tdelete filteredBindings[ key ];\n\t\t}\n\t} );\n\n\tconst { canUpdateBlockBindings } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tcanUpdateBlockBindings:\n\t\t\t\tselect( blockEditorStore ).getSettings().canUpdateBlockBindings,\n\t\t};\n\t}, [] );\n\n\tif ( ! bindableAttributes || bindableAttributes.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst fieldsList = {};\n\tconst { getBlockBindingsSources } = unlock( blocksPrivateApis );\n\tconst registeredSources = getBlockBindingsSources();\n\tObject.entries( registeredSources ).forEach(\n\t\t( [ sourceName, { getFieldsList, usesContext } ] ) => {\n\t\t\tif ( getFieldsList ) {\n\t\t\t\t// Populate context.\n\t\t\t\tconst context = {};\n\t\t\t\tif ( usesContext?.length ) {\n\t\t\t\t\tfor ( const key of usesContext ) {\n\t\t\t\t\t\tcontext[ key ] = blockContext[ key ];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst sourceList = getFieldsList( {\n\t\t\t\t\tregistry,\n\t\t\t\t\tcontext,\n\t\t\t\t} );\n\t\t\t\t// Only add source if the list is not empty.\n\t\t\t\tif ( sourceList ) {\n\t\t\t\t\tfieldsList[ sourceName ] = { ...sourceList };\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t);\n\t// Remove empty sources.\n\tObject.entries( fieldsList ).forEach( ( [ key, value ] ) => {\n\t\tif ( ! Object.keys( value ).length ) {\n\t\t\tdelete fieldsList[ key ];\n\t\t}\n\t} );\n\n\t// Lock the UI when the user can't update bindings or there are no fields to connect to.\n\tconst readOnly =\n\t\t! canUpdateBlockBindings || ! Object.keys( fieldsList ).length;\n\n\tif ( readOnly && Object.keys( filteredBindings ).length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"bindings\">\n\t\t\t<ToolsPanel\n\t\t\t\tlabel={ __( 'Attributes' ) }\n\t\t\t\tresetAll={ () => {\n\t\t\t\t\tremoveAllBlockBindings();\n\t\t\t\t} }\n\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\tclassName=\"block-editor-bindings__panel\"\n\t\t\t>\n\t\t\t\t<ItemGroup isBordered isSeparated>\n\t\t\t\t\t{ readOnly ? (\n\t\t\t\t\t\t<ReadOnlyBlockBindingsPanelItems\n\t\t\t\t\t\t\tbindings={ filteredBindings }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<EditableBlockBindingsPanelItems\n\t\t\t\t\t\t\tattributes={ bindableAttributes }\n\t\t\t\t\t\t\tbindings={ filteredBindings }\n\t\t\t\t\t\t\tfieldsList={ fieldsList }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</ItemGroup>\n\t\t\t\t<ItemGroup>\n\t\t\t\t\t<Text variant=\"muted\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Attributes connected to custom fields or other dynamic data.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Text>\n\t\t\t\t</ItemGroup>\n\t\t\t</ToolsPanel>\n\t\t</InspectorControls>\n\t);\n};\n\nexport default {\n\tedit: BlockBindingsPanel,\n\tattributeKeys: [ 'metadata' ],\n\thasSupport() {\n\t\treturn true;\n\t},\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AASA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAKA,IAAAM,sBAAA,GAAAN,OAAA;AAIA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAC,sBAAA,CAAAT,OAAA;AACA,IAAAU,aAAA,GAAAD,sBAAA,CAAAT,OAAA;AACA,IAAAW,cAAA,GAAAX,OAAA;AACA,IAAAY,MAAA,GAAAZ,OAAA;AAAqD,IAAAa,WAAA,GAAAb,OAAA;AA7BrD;AACA;AACA;;AAgBA;AACA;AACA;;AAWA,MAAM;EAAEc;AAAe,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;AAE1D,MAAMC,8BAA8B,GAAGA,CAAA,KAAM;EAC5C,MAAMC,QAAQ,GAAG,IAAAC,yBAAgB,EAAE,QAAQ,EAAE,GAAI,CAAC;EAClD,OAAO,CAAED,QAAQ,GACd;IACAE,YAAY,EAAE;MACbC,SAAS,EAAE,YAAY;MACvB;MACAC,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