@wordpress/block-editor 12.16.0 → 12.16.1-next.79a6196f.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 (650) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +3 -6
  3. package/build/components/block-canvas/index.js +0 -2
  4. package/build/components/block-canvas/index.js.map +1 -1
  5. package/build/components/block-card/index.js +1 -1
  6. package/build/components/block-card/index.js.map +1 -1
  7. package/build/components/block-draggable/draggable-chip.js +6 -1
  8. package/build/components/block-draggable/draggable-chip.js.map +1 -1
  9. package/build/components/block-draggable/index.js +76 -6
  10. package/build/components/block-draggable/index.js.map +1 -1
  11. package/build/components/block-draggable/index.native.js +0 -6
  12. package/build/components/block-draggable/index.native.js.map +1 -1
  13. package/build/components/block-draggable/use-scroll-when-dragging.native.js +1 -1
  14. package/build/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -1
  15. package/build/components/block-editing-mode/index.js +2 -3
  16. package/build/components/block-editing-mode/index.js.map +1 -1
  17. package/build/components/block-inspector/index.js +1 -1
  18. package/build/components/block-inspector/index.js.map +1 -1
  19. package/build/components/block-list/block-list-item-cell.native.js +1 -0
  20. package/build/components/block-list/block-list-item-cell.native.js.map +1 -1
  21. package/build/components/block-list/block.js +245 -102
  22. package/build/components/block-list/block.js.map +1 -1
  23. package/build/components/block-list/block.native.js +46 -20
  24. package/build/components/block-list/block.native.js.map +1 -1
  25. package/build/components/block-list/index.native.js +3 -5
  26. package/build/components/block-list/index.native.js.map +1 -1
  27. package/build/components/block-list/private-block-context.js +14 -0
  28. package/build/components/block-list/private-block-context.js.map +1 -0
  29. package/build/components/block-list/use-block-props/index.js +33 -96
  30. package/build/components/block-list/use-block-props/index.js.map +1 -1
  31. package/build/components/block-list/use-in-between-inserter.js +3 -2
  32. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  33. package/build/components/block-list/use-scroll-upon-insertion.native.js +41 -0
  34. package/build/components/block-list/use-scroll-upon-insertion.native.js.map +1 -0
  35. package/build/components/block-lock/toolbar.js +21 -27
  36. package/build/components/block-lock/toolbar.js.map +1 -1
  37. package/build/components/block-mover/index.js +2 -1
  38. package/build/components/block-mover/index.js.map +1 -1
  39. package/build/components/block-patterns-list/index.js +4 -4
  40. package/build/components/block-patterns-list/index.js.map +1 -1
  41. package/build/components/block-switcher/index.js +4 -4
  42. package/build/components/block-switcher/index.js.map +1 -1
  43. package/build/components/block-toolbar/index.js +1 -2
  44. package/build/components/block-toolbar/index.js.map +1 -1
  45. package/build/components/block-tools/block-toolbar-popover.js +0 -2
  46. package/build/components/block-tools/block-toolbar-popover.js.map +1 -1
  47. package/build/components/block-variation-transforms/index.js +29 -2
  48. package/build/components/block-variation-transforms/index.js.map +1 -1
  49. package/build/components/border-radius-control/linked-button.js +1 -1
  50. package/build/components/border-radius-control/linked-button.js.map +1 -1
  51. package/build/components/colors/utils.js +10 -2
  52. package/build/components/colors/utils.js.map +1 -1
  53. package/build/components/colors/with-colors.js +6 -2
  54. package/build/components/colors/with-colors.js.map +1 -1
  55. package/build/components/font-sizes/utils.js +10 -2
  56. package/build/components/font-sizes/utils.js.map +1 -1
  57. package/build/components/global-styles/border-panel.js +2 -1
  58. package/build/components/global-styles/border-panel.js.map +1 -1
  59. package/build/components/global-styles/color-panel.js +2 -1
  60. package/build/components/global-styles/color-panel.js.map +1 -1
  61. package/build/components/global-styles/dimensions-panel.js +4 -3
  62. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  63. package/build/components/global-styles/effects-panel.js +2 -1
  64. package/build/components/global-styles/effects-panel.js.map +1 -1
  65. package/build/components/global-styles/filters-panel.js +1 -4
  66. package/build/components/global-styles/filters-panel.js.map +1 -1
  67. package/build/components/global-styles/get-global-styles-changes.js +192 -0
  68. package/build/components/global-styles/get-global-styles-changes.js.map +1 -0
  69. package/build/components/global-styles/hooks.js +3 -2
  70. package/build/components/global-styles/hooks.js.map +1 -1
  71. package/build/components/global-styles/image-settings-panel.js +7 -1
  72. package/build/components/global-styles/image-settings-panel.js.map +1 -1
  73. package/build/components/global-styles/index.js +7 -0
  74. package/build/components/global-styles/index.js.map +1 -1
  75. package/build/components/global-styles/typography-panel.js +33 -15
  76. package/build/components/global-styles/typography-panel.js.map +1 -1
  77. package/build/components/global-styles/use-global-styles-output.js +22 -8
  78. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  79. package/build/components/global-styles/utils.js +8 -1
  80. package/build/components/global-styles/utils.js.map +1 -1
  81. package/build/components/height-control/index.js +6 -2
  82. package/build/components/height-control/index.js.map +1 -1
  83. package/build/components/image-size-control/index.js +2 -2
  84. package/build/components/image-size-control/index.js.map +1 -1
  85. package/build/components/index.native.js +6 -5
  86. package/build/components/index.native.js.map +1 -1
  87. package/build/components/inner-blocks/index.js +61 -22
  88. package/build/components/inner-blocks/index.js.map +1 -1
  89. package/build/components/inner-blocks/index.native.js +18 -4
  90. package/build/components/inner-blocks/index.native.js.map +1 -1
  91. package/build/components/inner-blocks/use-inner-block-template-sync.js +5 -6
  92. package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  93. package/build/components/inner-blocks/use-nested-settings-update.js +5 -9
  94. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  95. package/build/components/inserter/block-patterns-explorer/pattern-list.js +1 -1
  96. package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  97. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +10 -9
  98. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  99. package/build/components/inserter/block-patterns-tab/patterns-filter.js +10 -10
  100. package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  101. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +9 -9
  102. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
  103. package/build/components/inserter/block-patterns-tab/utils.js +10 -14
  104. package/build/components/inserter/block-patterns-tab/utils.js.map +1 -1
  105. package/build/components/inserter/hooks/use-block-types-state.js +4 -14
  106. package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
  107. package/build/components/inserter/hooks/use-patterns-state.js +1 -1
  108. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  109. package/build/components/inserter/index.js +1 -2
  110. package/build/components/inserter/index.js.map +1 -1
  111. package/build/components/inserter/library.js +3 -7
  112. package/build/components/inserter/library.js.map +1 -1
  113. package/build/components/inserter/menu.js +14 -28
  114. package/build/components/inserter/menu.js.map +1 -1
  115. package/build/components/inserter/tabs.js +21 -21
  116. package/build/components/inserter/tabs.js.map +1 -1
  117. package/build/components/inserter-draggable-blocks/index.js +1 -1
  118. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  119. package/build/components/inserter-list-item/index.js +2 -4
  120. package/build/components/inserter-list-item/index.js.map +1 -1
  121. package/build/components/inspector-controls/block-support-tools-panel.js +3 -1
  122. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  123. package/build/components/inspector-controls-tabs/index.js +34 -23
  124. package/build/components/inspector-controls-tabs/index.js.map +1 -1
  125. package/build/components/list-view/block-select-button.js +4 -0
  126. package/build/components/list-view/block-select-button.js.map +1 -1
  127. package/build/components/list-view/block.js +57 -3
  128. package/build/components/list-view/block.js.map +1 -1
  129. package/build/components/media-upload-progress/constants.js +19 -0
  130. package/build/components/media-upload-progress/constants.js.map +1 -0
  131. package/build/components/media-upload-progress/index.native.js +42 -17
  132. package/build/components/media-upload-progress/index.native.js.map +1 -1
  133. package/build/components/navigable-toolbar/index.js +9 -14
  134. package/build/components/navigable-toolbar/index.js.map +1 -1
  135. package/build/components/plain-text/index.native.js +8 -3
  136. package/build/components/plain-text/index.native.js.map +1 -1
  137. package/build/components/provider/index.js +3 -1
  138. package/build/components/provider/index.js.map +1 -1
  139. package/build/components/provider/use-block-sync.js +7 -1
  140. package/build/components/provider/use-block-sync.js.map +1 -1
  141. package/build/components/rich-text/index.js +17 -7
  142. package/build/components/rich-text/index.js.map +1 -1
  143. package/build/components/rich-text/native/index.native.js +16 -24
  144. package/build/components/rich-text/native/index.native.js.map +1 -1
  145. package/build/components/rich-text/use-input-rules.js +2 -2
  146. package/build/components/rich-text/use-input-rules.js.map +1 -1
  147. package/build/components/rich-text/use-mark-persistent.js +1 -1
  148. package/build/components/rich-text/use-mark-persistent.js.map +1 -1
  149. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
  150. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  151. package/build/components/url-input/index.js +9 -6
  152. package/build/components/url-input/index.js.map +1 -1
  153. package/build/components/use-block-commands/index.js +14 -18
  154. package/build/components/use-block-commands/index.js.map +1 -1
  155. package/build/components/use-block-drop-zone/index.js +51 -22
  156. package/build/components/use-block-drop-zone/index.js.map +1 -1
  157. package/build/components/use-moving-animation/index.js +100 -92
  158. package/build/components/use-moving-animation/index.js.map +1 -1
  159. package/build/components/use-on-block-drop/index.js +8 -11
  160. package/build/components/use-on-block-drop/index.js.map +1 -1
  161. package/build/components/writing-flow/index.js +0 -1
  162. package/build/components/writing-flow/index.js.map +1 -1
  163. package/build/components/writing-flow/use-drag-selection.js +15 -4
  164. package/build/components/writing-flow/use-drag-selection.js.map +1 -1
  165. package/build/components/writing-flow/use-selection-observer.js +73 -27
  166. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  167. package/build/components/writing-flow/use-tab-nav.js +7 -4
  168. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  169. package/build/hooks/align.js +1 -1
  170. package/build/hooks/align.js.map +1 -1
  171. package/build/hooks/anchor.js +1 -1
  172. package/build/hooks/anchor.js.map +1 -1
  173. package/build/hooks/aria-label.js +9 -1
  174. package/build/hooks/aria-label.js.map +1 -1
  175. package/build/hooks/background.js +185 -20
  176. package/build/hooks/background.js.map +1 -1
  177. package/build/hooks/border.js +5 -10
  178. package/build/hooks/border.js.map +1 -1
  179. package/build/hooks/color.js +13 -11
  180. package/build/hooks/color.js.map +1 -1
  181. package/build/hooks/custom-class-name.js +1 -1
  182. package/build/hooks/custom-class-name.js.map +1 -1
  183. package/build/hooks/custom-class-name.native.js +9 -1
  184. package/build/hooks/custom-class-name.native.js.map +1 -1
  185. package/build/hooks/dimensions.js +4 -9
  186. package/build/hooks/dimensions.js.map +1 -1
  187. package/build/hooks/font-family.js +7 -3
  188. package/build/hooks/font-family.js.map +1 -1
  189. package/build/hooks/font-size.js +1 -1
  190. package/build/hooks/font-size.js.map +1 -1
  191. package/build/hooks/index.js +4 -4
  192. package/build/hooks/index.js.map +1 -1
  193. package/build/hooks/index.native.js +5 -3
  194. package/build/hooks/index.native.js.map +1 -1
  195. package/build/hooks/layout.js +10 -4
  196. package/build/hooks/layout.js.map +1 -1
  197. package/build/hooks/style.js +1 -1
  198. package/build/hooks/style.js.map +1 -1
  199. package/build/hooks/typography.js +4 -9
  200. package/build/hooks/typography.js.map +1 -1
  201. package/build/hooks/typography.native.js +43 -18
  202. package/build/hooks/typography.native.js.map +1 -1
  203. package/build/hooks/use-typography-props.js +10 -2
  204. package/build/hooks/use-typography-props.js.map +1 -1
  205. package/build/hooks/utils.js +48 -5
  206. package/build/hooks/utils.js.map +1 -1
  207. package/build/private-apis.js +2 -4
  208. package/build/private-apis.js.map +1 -1
  209. package/build/private-apis.native.js +0 -2
  210. package/build/private-apis.native.js.map +1 -1
  211. package/build/store/actions.js +0 -16
  212. package/build/store/actions.js.map +1 -1
  213. package/build/store/private-actions.js +51 -5
  214. package/build/store/private-actions.js.map +1 -1
  215. package/build/store/private-selectors.js +12 -0
  216. package/build/store/private-selectors.js.map +1 -1
  217. package/build/store/reducer.js +14 -6
  218. package/build/store/reducer.js.map +1 -1
  219. package/build/store/selectors.js +1 -13
  220. package/build/store/selectors.js.map +1 -1
  221. package/build/store/undo-ignore.js +12 -0
  222. package/build/store/undo-ignore.js.map +1 -0
  223. package/build/store/utils.js +1 -1
  224. package/build/store/utils.js.map +1 -1
  225. package/build/utils/get-px-from-css-unit.js +16 -0
  226. package/build/utils/get-px-from-css-unit.js.map +1 -0
  227. package/build/utils/index.js +2 -2
  228. package/build/utils/index.js.map +1 -1
  229. package/build/utils/object.js +17 -38
  230. package/build/utils/object.js.map +1 -1
  231. package/build/utils/use-can-block-toolbar-be-focused.js +46 -0
  232. package/build/utils/use-can-block-toolbar-be-focused.js.map +1 -0
  233. package/build-module/components/block-canvas/index.js +0 -2
  234. package/build-module/components/block-canvas/index.js.map +1 -1
  235. package/build-module/components/block-card/index.js +1 -1
  236. package/build-module/components/block-card/index.js.map +1 -1
  237. package/build-module/components/block-draggable/draggable-chip.js +6 -1
  238. package/build-module/components/block-draggable/draggable-chip.js.map +1 -1
  239. package/build-module/components/block-draggable/index.js +76 -6
  240. package/build-module/components/block-draggable/index.js.map +1 -1
  241. package/build-module/components/block-draggable/index.native.js +1 -7
  242. package/build-module/components/block-draggable/index.native.js.map +1 -1
  243. package/build-module/components/block-draggable/use-scroll-when-dragging.native.js +1 -1
  244. package/build-module/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -1
  245. package/build-module/components/block-editing-mode/index.js +3 -4
  246. package/build-module/components/block-editing-mode/index.js.map +1 -1
  247. package/build-module/components/block-inspector/index.js +1 -1
  248. package/build-module/components/block-inspector/index.js.map +1 -1
  249. package/build-module/components/block-list/block-list-item-cell.native.js +1 -0
  250. package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -1
  251. package/build-module/components/block-list/block.js +249 -106
  252. package/build-module/components/block-list/block.js.map +1 -1
  253. package/build-module/components/block-list/block.native.js +48 -22
  254. package/build-module/components/block-list/block.native.js.map +1 -1
  255. package/build-module/components/block-list/index.native.js +3 -5
  256. package/build-module/components/block-list/index.native.js.map +1 -1
  257. package/build-module/components/block-list/private-block-context.js +6 -0
  258. package/build-module/components/block-list/private-block-context.js.map +1 -0
  259. package/build-module/components/block-list/use-block-props/index.js +34 -97
  260. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  261. package/build-module/components/block-list/use-in-between-inserter.js +3 -2
  262. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  263. package/build-module/components/block-list/use-scroll-upon-insertion.native.js +33 -0
  264. package/build-module/components/block-list/use-scroll-upon-insertion.native.js.map +1 -0
  265. package/build-module/components/block-lock/toolbar.js +22 -28
  266. package/build-module/components/block-lock/toolbar.js.map +1 -1
  267. package/build-module/components/block-mover/index.js +2 -1
  268. package/build-module/components/block-mover/index.js.map +1 -1
  269. package/build-module/components/block-patterns-list/index.js +5 -5
  270. package/build-module/components/block-patterns-list/index.js.map +1 -1
  271. package/build-module/components/block-switcher/index.js +4 -4
  272. package/build-module/components/block-switcher/index.js.map +1 -1
  273. package/build-module/components/block-toolbar/index.js +1 -2
  274. package/build-module/components/block-toolbar/index.js.map +1 -1
  275. package/build-module/components/block-tools/block-toolbar-popover.js +0 -2
  276. package/build-module/components/block-tools/block-toolbar-popover.js.map +1 -1
  277. package/build-module/components/block-variation-transforms/index.js +30 -3
  278. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  279. package/build-module/components/border-radius-control/linked-button.js +1 -1
  280. package/build-module/components/border-radius-control/linked-button.js.map +1 -1
  281. package/build-module/components/colors/utils.js +9 -1
  282. package/build-module/components/colors/utils.js.map +1 -1
  283. package/build-module/components/colors/with-colors.js +5 -1
  284. package/build-module/components/colors/with-colors.js.map +1 -1
  285. package/build-module/components/font-sizes/utils.js +9 -1
  286. package/build-module/components/font-sizes/utils.js.map +1 -1
  287. package/build-module/components/global-styles/border-panel.js +3 -2
  288. package/build-module/components/global-styles/border-panel.js.map +1 -1
  289. package/build-module/components/global-styles/color-panel.js +3 -2
  290. package/build-module/components/global-styles/color-panel.js.map +1 -1
  291. package/build-module/components/global-styles/dimensions-panel.js +5 -4
  292. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  293. package/build-module/components/global-styles/effects-panel.js +3 -2
  294. package/build-module/components/global-styles/effects-panel.js.map +1 -1
  295. package/build-module/components/global-styles/filters-panel.js +2 -5
  296. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  297. package/build-module/components/global-styles/get-global-styles-changes.js +184 -0
  298. package/build-module/components/global-styles/get-global-styles-changes.js.map +1 -0
  299. package/build-module/components/global-styles/hooks.js +3 -2
  300. package/build-module/components/global-styles/hooks.js.map +1 -1
  301. package/build-module/components/global-styles/image-settings-panel.js +7 -1
  302. package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
  303. package/build-module/components/global-styles/index.js +1 -0
  304. package/build-module/components/global-styles/index.js.map +1 -1
  305. package/build-module/components/global-styles/typography-panel.js +35 -17
  306. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  307. package/build-module/components/global-styles/use-global-styles-output.js +15 -1
  308. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  309. package/build-module/components/global-styles/utils.js +7 -0
  310. package/build-module/components/global-styles/utils.js.map +1 -1
  311. package/build-module/components/height-control/index.js +6 -2
  312. package/build-module/components/height-control/index.js.map +1 -1
  313. package/build-module/components/image-size-control/index.js +2 -2
  314. package/build-module/components/image-size-control/index.js.map +1 -1
  315. package/build-module/components/index.native.js +2 -1
  316. package/build-module/components/index.native.js.map +1 -1
  317. package/build-module/components/inner-blocks/index.js +62 -23
  318. package/build-module/components/inner-blocks/index.js.map +1 -1
  319. package/build-module/components/inner-blocks/index.native.js +18 -4
  320. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  321. package/build-module/components/inner-blocks/use-inner-block-template-sync.js +5 -6
  322. package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  323. package/build-module/components/inner-blocks/use-nested-settings-update.js +6 -10
  324. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  325. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
  326. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  327. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +11 -10
  328. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  329. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js +11 -11
  330. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  331. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +11 -11
  332. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
  333. package/build-module/components/inserter/block-patterns-tab/utils.js +7 -11
  334. package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -1
  335. package/build-module/components/inserter/hooks/use-block-types-state.js +4 -14
  336. package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
  337. package/build-module/components/inserter/hooks/use-patterns-state.js +2 -2
  338. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  339. package/build-module/components/inserter/index.js +1 -2
  340. package/build-module/components/inserter/index.js.map +1 -1
  341. package/build-module/components/inserter/library.js +3 -7
  342. package/build-module/components/inserter/library.js.map +1 -1
  343. package/build-module/components/inserter/menu.js +14 -28
  344. package/build-module/components/inserter/menu.js.map +1 -1
  345. package/build-module/components/inserter/tabs.js +22 -22
  346. package/build-module/components/inserter/tabs.js.map +1 -1
  347. package/build-module/components/inserter-draggable-blocks/index.js +2 -2
  348. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  349. package/build-module/components/inserter-list-item/index.js +2 -4
  350. package/build-module/components/inserter-list-item/index.js.map +1 -1
  351. package/build-module/components/inspector-controls/block-support-tools-panel.js +3 -1
  352. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  353. package/build-module/components/inspector-controls-tabs/index.js +35 -24
  354. package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
  355. package/build-module/components/list-view/block-select-button.js +4 -0
  356. package/build-module/components/list-view/block-select-button.js.map +1 -1
  357. package/build-module/components/list-view/block.js +58 -4
  358. package/build-module/components/list-view/block.js.map +1 -1
  359. package/build-module/components/media-upload-progress/constants.js +7 -0
  360. package/build-module/components/media-upload-progress/constants.js.map +1 -0
  361. package/build-module/components/media-upload-progress/index.native.js +37 -8
  362. package/build-module/components/media-upload-progress/index.native.js.map +1 -1
  363. package/build-module/components/navigable-toolbar/index.js +9 -14
  364. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  365. package/build-module/components/plain-text/index.native.js +6 -1
  366. package/build-module/components/plain-text/index.native.js.map +1 -1
  367. package/build-module/components/provider/index.js +3 -1
  368. package/build-module/components/provider/index.js.map +1 -1
  369. package/build-module/components/provider/use-block-sync.js +7 -1
  370. package/build-module/components/provider/use-block-sync.js.map +1 -1
  371. package/build-module/components/rich-text/index.js +17 -7
  372. package/build-module/components/rich-text/index.js.map +1 -1
  373. package/build-module/components/rich-text/native/index.native.js +16 -23
  374. package/build-module/components/rich-text/native/index.native.js.map +1 -1
  375. package/build-module/components/rich-text/use-input-rules.js +2 -2
  376. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  377. package/build-module/components/rich-text/use-mark-persistent.js +1 -1
  378. package/build-module/components/rich-text/use-mark-persistent.js.map +1 -1
  379. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
  380. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  381. package/build-module/components/url-input/index.js +9 -6
  382. package/build-module/components/url-input/index.js.map +1 -1
  383. package/build-module/components/use-block-commands/index.js +14 -18
  384. package/build-module/components/use-block-commands/index.js.map +1 -1
  385. package/build-module/components/use-block-drop-zone/index.js +51 -23
  386. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  387. package/build-module/components/use-moving-animation/index.js +102 -94
  388. package/build-module/components/use-moving-animation/index.js.map +1 -1
  389. package/build-module/components/use-on-block-drop/index.js +8 -11
  390. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  391. package/build-module/components/writing-flow/index.js +0 -1
  392. package/build-module/components/writing-flow/index.js.map +1 -1
  393. package/build-module/components/writing-flow/use-drag-selection.js +15 -4
  394. package/build-module/components/writing-flow/use-drag-selection.js.map +1 -1
  395. package/build-module/components/writing-flow/use-selection-observer.js +73 -27
  396. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  397. package/build-module/components/writing-flow/use-tab-nav.js +7 -4
  398. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  399. package/build-module/hooks/align.js +1 -1
  400. package/build-module/hooks/align.js.map +1 -1
  401. package/build-module/hooks/anchor.js +1 -1
  402. package/build-module/hooks/anchor.js.map +1 -1
  403. package/build-module/hooks/aria-label.js +7 -1
  404. package/build-module/hooks/aria-label.js.map +1 -1
  405. package/build-module/hooks/background.js +181 -19
  406. package/build-module/hooks/background.js.map +1 -1
  407. package/build-module/hooks/border.js +2 -8
  408. package/build-module/hooks/border.js.map +1 -1
  409. package/build-module/hooks/color.js +11 -9
  410. package/build-module/hooks/color.js.map +1 -1
  411. package/build-module/hooks/custom-class-name.js +1 -1
  412. package/build-module/hooks/custom-class-name.js.map +1 -1
  413. package/build-module/hooks/custom-class-name.native.js +7 -1
  414. package/build-module/hooks/custom-class-name.native.js.map +1 -1
  415. package/build-module/hooks/dimensions.js +1 -7
  416. package/build-module/hooks/dimensions.js.map +1 -1
  417. package/build-module/hooks/font-family.js +6 -2
  418. package/build-module/hooks/font-family.js.map +1 -1
  419. package/build-module/hooks/font-size.js +1 -1
  420. package/build-module/hooks/font-size.js.map +1 -1
  421. package/build-module/hooks/index.js +5 -5
  422. package/build-module/hooks/index.js.map +1 -1
  423. package/build-module/hooks/index.native.js +6 -4
  424. package/build-module/hooks/index.native.js.map +1 -1
  425. package/build-module/hooks/layout.js +9 -3
  426. package/build-module/hooks/layout.js.map +1 -1
  427. package/build-module/hooks/style.js +1 -1
  428. package/build-module/hooks/style.js.map +1 -1
  429. package/build-module/hooks/typography.js +1 -7
  430. package/build-module/hooks/typography.js.map +1 -1
  431. package/build-module/hooks/typography.native.js +43 -17
  432. package/build-module/hooks/typography.native.js.map +1 -1
  433. package/build-module/hooks/use-typography-props.js +9 -1
  434. package/build-module/hooks/use-typography-props.js.map +1 -1
  435. package/build-module/hooks/utils.js +47 -5
  436. package/build-module/hooks/utils.js.map +1 -1
  437. package/build-module/private-apis.js +2 -4
  438. package/build-module/private-apis.js.map +1 -1
  439. package/build-module/private-apis.native.js +0 -2
  440. package/build-module/private-apis.native.js.map +1 -1
  441. package/build-module/store/actions.js +0 -15
  442. package/build-module/store/actions.js.map +1 -1
  443. package/build-module/store/private-actions.js +49 -4
  444. package/build-module/store/private-actions.js.map +1 -1
  445. package/build-module/store/private-selectors.js +11 -0
  446. package/build-module/store/private-selectors.js.map +1 -1
  447. package/build-module/store/reducer.js +14 -6
  448. package/build-module/store/reducer.js.map +1 -1
  449. package/build-module/store/selectors.js +1 -12
  450. package/build-module/store/selectors.js.map +1 -1
  451. package/build-module/store/undo-ignore.js +5 -0
  452. package/build-module/store/undo-ignore.js.map +1 -0
  453. package/build-module/store/utils.js +2 -2
  454. package/build-module/store/utils.js.map +1 -1
  455. package/build-module/utils/get-px-from-css-unit.js +9 -0
  456. package/build-module/utils/get-px-from-css-unit.js.map +1 -0
  457. package/build-module/utils/index.js +1 -1
  458. package/build-module/utils/index.js.map +1 -1
  459. package/build-module/utils/object.js +16 -37
  460. package/build-module/utils/object.js.map +1 -1
  461. package/build-module/utils/use-can-block-toolbar-be-focused.js +40 -0
  462. package/build-module/utils/use-can-block-toolbar-be-focused.js.map +1 -0
  463. package/build-style/content-rtl.css +7 -6
  464. package/build-style/content.css +7 -6
  465. package/build-style/style-rtl.css +51 -8
  466. package/build-style/style.css +51 -8
  467. package/package.json +31 -31
  468. package/src/components/alignment-control/README.md +0 -5
  469. package/src/components/block-alignment-control/README.md +0 -5
  470. package/src/components/block-alignment-matrix-control/README.md +0 -10
  471. package/src/components/block-breadcrumb/README.md +0 -5
  472. package/src/components/block-canvas/index.js +0 -2
  473. package/src/components/block-canvas/style.scss +6 -0
  474. package/src/components/block-caption/README.md +0 -5
  475. package/src/components/block-card/README.md +0 -5
  476. package/src/components/block-card/index.js +1 -1
  477. package/src/components/block-draggable/draggable-chip.js +11 -1
  478. package/src/components/block-draggable/index.js +116 -4
  479. package/src/components/block-draggable/index.native.js +0 -5
  480. package/src/components/block-draggable/style.scss +35 -0
  481. package/src/components/block-draggable/test/helpers.native.js +8 -7
  482. package/src/components/block-draggable/use-scroll-when-dragging.native.js +1 -1
  483. package/src/components/block-editing-mode/index.js +3 -3
  484. package/src/components/block-icon/README.md +0 -5
  485. package/src/components/block-inspector/README.md +0 -5
  486. package/src/components/block-inspector/index.js +3 -1
  487. package/src/components/block-list/block-list-item-cell.native.js +5 -1
  488. package/src/components/block-list/block.js +290 -119
  489. package/src/components/block-list/block.native.js +55 -21
  490. package/src/components/block-list/content.scss +14 -10
  491. package/src/components/block-list/index.native.js +3 -5
  492. package/src/components/block-list/{block-list-block-context.js → private-block-context.js} +1 -1
  493. package/src/components/block-list/use-block-props/index.js +32 -128
  494. package/src/components/block-list/use-in-between-inserter.js +4 -1
  495. package/src/components/block-list/use-scroll-upon-insertion.native.js +52 -0
  496. package/src/components/block-lock/toolbar.js +23 -34
  497. package/src/components/block-mover/README.md +0 -5
  498. package/src/components/block-mover/index.js +1 -1
  499. package/src/components/block-parent-selector/README.md +0 -5
  500. package/src/components/block-patterns-list/README.md +0 -5
  501. package/src/components/block-patterns-list/index.js +8 -5
  502. package/src/components/block-switcher/index.js +49 -59
  503. package/src/components/block-toolbar/README.md +0 -5
  504. package/src/components/block-toolbar/index.js +1 -2
  505. package/src/components/block-tools/block-toolbar-popover.js +4 -10
  506. package/src/components/block-types-list/README.md +0 -5
  507. package/src/components/block-variation-picker/README.md +0 -5
  508. package/src/components/block-variation-transforms/README.md +0 -5
  509. package/src/components/block-variation-transforms/index.js +49 -3
  510. package/src/components/border-radius-control/linked-button.js +1 -1
  511. package/src/components/caption/README.md +0 -5
  512. package/src/components/color-palette/test/__snapshots__/control.js.snap +0 -1
  513. package/src/components/colors/utils.js +8 -1
  514. package/src/components/colors/with-colors.js +3 -1
  515. package/src/components/contrast-checker/README.md +0 -4
  516. package/src/components/copy-handler/README.md +0 -10
  517. package/src/components/font-sizes/utils.js +7 -1
  518. package/src/components/global-styles/border-panel.js +2 -1
  519. package/src/components/global-styles/color-panel.js +2 -1
  520. package/src/components/global-styles/dimensions-panel.js +4 -3
  521. package/src/components/global-styles/effects-panel.js +2 -1
  522. package/src/components/global-styles/filters-panel.js +2 -5
  523. package/src/components/global-styles/get-global-styles-changes.js +210 -0
  524. package/src/components/global-styles/hooks.js +5 -0
  525. package/src/components/global-styles/image-settings-panel.js +6 -0
  526. package/src/components/global-styles/index.js +1 -0
  527. package/src/components/global-styles/test/get-global-styles-changes.js +234 -0
  528. package/src/components/global-styles/typography-panel.js +47 -14
  529. package/src/components/global-styles/use-global-styles-output.js +9 -5
  530. package/src/components/global-styles/utils.js +7 -0
  531. package/src/components/height-control/README.md +2 -7
  532. package/src/components/height-control/index.js +4 -0
  533. package/src/components/image-size-control/index.js +5 -2
  534. package/src/components/index.native.js +2 -2
  535. package/src/components/inner-blocks/index.js +68 -29
  536. package/src/components/inner-blocks/index.native.js +19 -7
  537. package/src/components/inner-blocks/use-inner-block-template-sync.js +5 -7
  538. package/src/components/inner-blocks/use-nested-settings-update.js +6 -13
  539. package/src/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
  540. package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +15 -15
  541. package/src/components/inserter/block-patterns-tab/patterns-filter.js +15 -13
  542. package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +15 -18
  543. package/src/components/inserter/block-patterns-tab/utils.js +11 -12
  544. package/src/components/inserter/hooks/use-block-types-state.js +9 -11
  545. package/src/components/inserter/hooks/use-patterns-state.js +2 -2
  546. package/src/components/inserter/index.js +0 -1
  547. package/src/components/inserter/library.js +2 -8
  548. package/src/components/inserter/menu.js +13 -31
  549. package/src/components/inserter/style.scss +6 -4
  550. package/src/components/inserter/tabs.js +34 -25
  551. package/src/components/inserter-draggable-blocks/index.js +2 -2
  552. package/src/components/inserter-list-item/index.js +6 -6
  553. package/src/components/inspector-controls/block-support-tools-panel.js +2 -0
  554. package/src/components/inspector-controls-tabs/index.js +39 -28
  555. package/src/components/inspector-controls-tabs/style.scss +3 -2
  556. package/src/components/letter-spacing-control/README.md +0 -5
  557. package/src/components/line-height-control/README.md +0 -5
  558. package/src/components/list-view/README.md +0 -5
  559. package/src/components/list-view/block-select-button.js +4 -0
  560. package/src/components/list-view/block.js +73 -2
  561. package/src/components/list-view/style.scss +6 -0
  562. package/src/components/media-upload-progress/constants.js +6 -0
  563. package/src/components/media-upload-progress/index.native.js +66 -14
  564. package/src/components/media-upload-progress/test/index.native.js +2 -2
  565. package/src/components/multi-selection-inspector/README.md +0 -5
  566. package/src/components/navigable-toolbar/index.js +13 -11
  567. package/src/components/plain-text/index.native.js +6 -1
  568. package/src/components/provider/index.js +1 -1
  569. package/src/components/provider/test/use-block-sync.js +20 -17
  570. package/src/components/provider/use-block-sync.js +6 -0
  571. package/src/components/rich-text/index.js +18 -6
  572. package/src/components/rich-text/native/index.native.js +16 -24
  573. package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +3 -3
  574. package/src/components/rich-text/native/test/index.native.js +72 -5
  575. package/src/components/rich-text/use-input-rules.js +2 -2
  576. package/src/components/rich-text/use-mark-persistent.js +1 -2
  577. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
  578. package/src/components/text-decoration-control/README.md +40 -0
  579. package/src/components/text-transform-control/README.md +0 -4
  580. package/src/components/ungroup-button/README.md +0 -5
  581. package/src/components/unit-control/README.md +0 -4
  582. package/src/components/url-input/index.js +11 -11
  583. package/src/components/use-block-commands/index.js +18 -21
  584. package/src/components/use-block-drop-zone/index.js +85 -34
  585. package/src/components/use-moving-animation/index.js +107 -103
  586. package/src/components/use-on-block-drop/index.js +7 -23
  587. package/src/components/use-on-block-drop/test/index.js +12 -26
  588. package/src/components/use-resize-canvas/README.md +0 -4
  589. package/src/components/use-settings/README.md +0 -4
  590. package/src/components/writing-flow/index.js +0 -1
  591. package/src/components/writing-flow/use-drag-selection.js +18 -4
  592. package/src/components/writing-flow/use-selection-observer.js +99 -37
  593. package/src/components/writing-flow/use-tab-nav.js +7 -7
  594. package/src/hooks/align.js +1 -5
  595. package/src/hooks/anchor.js +1 -5
  596. package/src/hooks/aria-label.js +8 -5
  597. package/src/hooks/background.js +253 -21
  598. package/src/hooks/border.js +2 -13
  599. package/src/hooks/color.js +19 -14
  600. package/src/hooks/custom-class-name.js +1 -5
  601. package/src/hooks/custom-class-name.native.js +8 -5
  602. package/src/hooks/dimensions.js +1 -7
  603. package/src/hooks/font-family.js +4 -7
  604. package/src/hooks/font-size.js +1 -6
  605. package/src/hooks/index.js +19 -5
  606. package/src/hooks/index.native.js +17 -4
  607. package/src/hooks/layout.js +5 -2
  608. package/src/hooks/style.js +1 -6
  609. package/src/hooks/test/anchor.js +4 -9
  610. package/src/hooks/test/custom-class-name.js +3 -8
  611. package/src/hooks/test/style.js +4 -14
  612. package/src/hooks/typography.js +1 -7
  613. package/src/hooks/typography.native.js +31 -33
  614. package/src/hooks/use-typography-props.js +7 -1
  615. package/src/hooks/utils.js +76 -6
  616. package/src/private-apis.js +2 -4
  617. package/src/private-apis.native.js +0 -2
  618. package/src/store/actions.js +0 -15
  619. package/src/store/private-actions.js +44 -4
  620. package/src/store/private-selectors.js +11 -0
  621. package/src/store/reducer.js +16 -5
  622. package/src/store/selectors.js +5 -13
  623. package/src/store/undo-ignore.js +4 -0
  624. package/src/store/utils.js +2 -2
  625. package/src/style.scss +1 -0
  626. package/src/utils/get-px-from-css-unit.js +8 -0
  627. package/src/utils/index.js +1 -1
  628. package/src/utils/object.js +16 -35
  629. package/src/utils/test/object.js +1 -96
  630. package/src/utils/use-can-block-toolbar-be-focused.js +48 -0
  631. package/build/components/block-list/block-list-block-context.js +0 -14
  632. package/build/components/block-list/block-list-block-context.js.map +0 -1
  633. package/build/hooks/custom-fields.js +0 -106
  634. package/build/hooks/custom-fields.js.map +0 -1
  635. package/build/utils/parse-css-unit-to-px.js +0 -302
  636. package/build/utils/parse-css-unit-to-px.js.map +0 -1
  637. package/build/utils/use-should-contextual-toolbar-show.js +0 -63
  638. package/build/utils/use-should-contextual-toolbar-show.js.map +0 -1
  639. package/build-module/components/block-list/block-list-block-context.js +0 -6
  640. package/build-module/components/block-list/block-list-block-context.js.map +0 -1
  641. package/build-module/hooks/custom-fields.js +0 -99
  642. package/build-module/hooks/custom-fields.js.map +0 -1
  643. package/build-module/utils/parse-css-unit-to-px.js +0 -294
  644. package/build-module/utils/parse-css-unit-to-px.js.map +0 -1
  645. package/build-module/utils/use-should-contextual-toolbar-show.js +0 -57
  646. package/build-module/utils/use-should-contextual-toolbar-show.js.map +0 -1
  647. package/src/hooks/custom-fields.js +0 -115
  648. package/src/utils/parse-css-unit-to-px.js +0 -329
  649. package/src/utils/test/parse-css-unit-to-px.js +0 -172
  650. package/src/utils/use-should-contextual-toolbar-show.js +0 -85
@@ -37,8 +37,9 @@ function useDragSelection() {
37
37
  } = (0, _data.useDispatch)(_store.store);
38
38
  const {
39
39
  isSelectionEnabled,
40
- hasMultiSelection,
41
- isDraggingBlocks
40
+ hasSelectedBlock,
41
+ isDraggingBlocks,
42
+ isMultiSelecting
42
43
  } = (0, _data.useSelect)(_store.store);
43
44
  return (0, _compose.useRefEffect)(node => {
44
45
  const {
@@ -57,7 +58,7 @@ function useDragSelection() {
57
58
  // so wait until the next animation frame to get the browser
58
59
  // selection.
59
60
  rafId = defaultView.requestAnimationFrame(() => {
60
- if (hasMultiSelection()) {
61
+ if (!hasSelectedBlock()) {
61
62
  return;
62
63
  }
63
64
 
@@ -94,6 +95,16 @@ function useDragSelection() {
94
95
  return;
95
96
  }
96
97
 
98
+ // Abort if we are already multi-selecting.
99
+ if (isMultiSelecting()) {
100
+ return;
101
+ }
102
+
103
+ // Abort if selection is leaving writing flow.
104
+ if (node === target) {
105
+ return;
106
+ }
107
+
97
108
  // Check the attribute, not the contentEditable attribute. All
98
109
  // child elements of the content editable wrapper are editable
99
110
  // and return true for this property. We only want to start
@@ -128,6 +139,6 @@ function useDragSelection() {
128
139
  defaultView.removeEventListener('mouseup', onMouseUp);
129
140
  defaultView.cancelAnimationFrame(rafId);
130
141
  };
131
- }, [startMultiSelect, stopMultiSelect, isSelectionEnabled, hasMultiSelection]);
142
+ }, [startMultiSelect, stopMultiSelect, isSelectionEnabled, hasSelectedBlock]);
132
143
  }
133
144
  //# sourceMappingURL=use-drag-selection.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_compose","_store","setContentEditableWrapper","node","value","contentEditable","focus","useDragSelection","startMultiSelect","stopMultiSelect","useDispatch","blockEditorStore","isSelectionEnabled","hasMultiSelection","isDraggingBlocks","useSelect","useRefEffect","ownerDocument","defaultView","anchorElement","rafId","onMouseUp","removeEventListener","requestAnimationFrame","selection","getSelection","rangeCount","commonAncestorContainer","getRangeAt","contains","onMouseLeave","buttons","target","getAttribute","addEventListener","cancelAnimationFrame"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-drag-selection.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\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\tnode.contentEditable = value;\n\t// Firefox doesn't automatically move focus.\n\tif ( value ) node.focus();\n}\n\n/**\n * Sets a multi-selection based on the native selection across blocks.\n */\nexport default function useDragSelection() {\n\tconst { startMultiSelect, stopMultiSelect } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { isSelectionEnabled, hasMultiSelection, isDraggingBlocks } =\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\tlet anchorElement;\n\t\t\tlet rafId;\n\n\t\t\tfunction onMouseUp() {\n\t\t\t\tstopMultiSelect();\n\t\t\t\t// Equivalent to attaching the listener once.\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onMouseUp );\n\t\t\t\t// The browser selection won't have updated yet at this point,\n\t\t\t\t// so wait until the next animation frame to get the browser\n\t\t\t\t// selection.\n\t\t\t\trafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\t\tif ( hasMultiSelection() ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// If the selection is complete (on mouse up), and no\n\t\t\t\t\t// multiple blocks have been selected, set focus back to the\n\t\t\t\t\t// anchor element. if the anchor element contains the\n\t\t\t\t\t// selection. Additionally, the contentEditable wrapper can\n\t\t\t\t\t// now be disabled again.\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\n\t\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\t\tif ( selection.rangeCount ) {\n\t\t\t\t\t\tconst { commonAncestorContainer } =\n\t\t\t\t\t\t\tselection.getRangeAt( 0 );\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tanchorElement.contains( commonAncestorContainer )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tanchorElement.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tfunction onMouseLeave( { buttons, target } ) {\n\t\t\t\t// Avoid triggering a multi-selection if the user is already\n\t\t\t\t// dragging blocks.\n\t\t\t\tif ( isDraggingBlocks() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// The primary button must be pressed to initiate selection.\n\t\t\t\t// See https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\n\t\t\t\tif ( buttons !== 1 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Check the attribute, not the contentEditable attribute. All\n\t\t\t\t// child elements of the content editable wrapper are editable\n\t\t\t\t// and return true for this property. We only want to start\n\t\t\t\t// multi selecting when the mouse leaves the wrapper.\n\t\t\t\tif ( target.getAttribute( 'contenteditable' ) !== 'true' ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( ! isSelectionEnabled() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Do not rely on the active element because it may change after\n\t\t\t\t// the mouse leaves for the first time. See\n\t\t\t\t// https://github.com/WordPress/gutenberg/issues/48747.\n\t\t\t\tanchorElement = target;\n\n\t\t\t\tstartMultiSelect();\n\n\t\t\t\t// `onSelectionStart` is called after `mousedown` and\n\t\t\t\t// `mouseleave` (from a block). The selection ends when\n\t\t\t\t// `mouseup` happens anywhere in the window.\n\t\t\t\tdefaultView.addEventListener( 'mouseup', onMouseUp );\n\n\t\t\t\t// Allow cross contentEditable selection by temporarily making\n\t\t\t\t// all content editable. We can't rely on using the store and\n\t\t\t\t// React because re-rending happens too slowly. We need to be\n\t\t\t\t// able to select across instances immediately.\n\t\t\t\tsetContentEditableWrapper( node, true );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mouseout', onMouseLeave );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mouseout', onMouseLeave );\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onMouseUp );\n\t\t\t\tdefaultView.cancelAnimationFrame( rafId );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tstartMultiSelect,\n\t\t\tstopMultiSelect,\n\t\t\tisSelectionEnabled,\n\t\t\thasMultiSelection,\n\t\t]\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,SAASG,yBAAyBA,CAAEC,IAAI,EAAEC,KAAK,EAAG;EACjDD,IAAI,CAACE,eAAe,GAAGD,KAAK;EAC5B;EACA,IAAKA,KAAK,EAAGD,IAAI,CAACG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AG;QACpB;MACD;;MAEA;MACA;MACA;MACA;MACA,IAAKC,MAAM,CAACC,YAAY,CAAE,iBAAkB,CAAC,KAAK,MAAM,EAAG;QAC1D;MACD;MAEA,IAAK,CAAErB,kBAAkB,CAAC,CAAC,EAAG;QAC7B;MACD;;MAEA;MACA;MACA;MACAO,aAAa,GAAGa,MAAM;MAEtBxB,gBAAgB,CAAC,CAAC;;MAElB;MACA;MACA;MACAU,WAAW,CAACgB,gBAAgB,CAAE,SAAS,EAAEb,SAAU,CAAC;;MAEpD;MACA;MACA;MACA;MACAnB,yBAAyB,CAAEC,IAAI,EAAE,IAAK,CAAC;IACxC;IAEAA,IAAI,CAAC+B,gBAAgB,CAAE,UAAU,EAAEJ,YAAa,CAAC;IAEjD,OAAO,MAAM;MACZ3B,IAAI,CAACmB,mBAAmB,CAAE,UAAU,EAAEQ,YAAa,CAAC;MACpDZ,WAAW,CAACI,mBAAmB,CAAE,SAAS,EAAED,SAAU,CAAC;MACvDH,WAAW,CAACiB,oBAAoB,CAAEf,KAAM,CAAC;IAC1C,CAAC;EACF,CAAC,EACD,CACCZ,gBAAgB,EAChBC,eAAe,EACfG,kBAAkB,EAClBC,iBAAiB,CAEnB,CAAC;AACF"}
1
+ {"version":3,"names":["_data","require","_compose","_store","setContentEditableWrapper","node","value","contentEditable","focus","useDragSelection","startMultiSelect","stopMultiSelect","useDispatch","blockEditorStore","isSelectionEnabled","hasSelectedBlock","isDraggingBlocks","isMultiSelecting","useSelect","useRefEffect","ownerDocument","defaultView","anchorElement","rafId","onMouseUp","removeEventListener","requestAnimationFrame","selection","getSelection","rangeCount","commonAncestorContainer","getRangeAt","contains","onMouseLeave","buttons","target","getAttribute","addEventListener","cancelAnimationFrame"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-drag-selection.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\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\tnode.contentEditable = value;\n\t// Firefox doesn't automatically move focus.\n\tif ( value ) node.focus();\n}\n\n/**\n * Sets a multi-selection based on the native selection across blocks.\n */\nexport default function useDragSelection() {\n\tconst { startMultiSelect, stopMultiSelect } =\n\t\tuseDispatch( blockEditorStore );\n\tconst {\n\t\tisSelectionEnabled,\n\t\thasSelectedBlock,\n\t\tisDraggingBlocks,\n\t\tisMultiSelecting,\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\tlet anchorElement;\n\t\t\tlet rafId;\n\n\t\t\tfunction onMouseUp() {\n\t\t\t\tstopMultiSelect();\n\t\t\t\t// Equivalent to attaching the listener once.\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onMouseUp );\n\t\t\t\t// The browser selection won't have updated yet at this point,\n\t\t\t\t// so wait until the next animation frame to get the browser\n\t\t\t\t// selection.\n\t\t\t\trafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\t\tif ( ! hasSelectedBlock() ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// If the selection is complete (on mouse up), and no\n\t\t\t\t\t// multiple blocks have been selected, set focus back to the\n\t\t\t\t\t// anchor element. if the anchor element contains the\n\t\t\t\t\t// selection. Additionally, the contentEditable wrapper can\n\t\t\t\t\t// now be disabled again.\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\n\t\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\t\tif ( selection.rangeCount ) {\n\t\t\t\t\t\tconst { commonAncestorContainer } =\n\t\t\t\t\t\t\tselection.getRangeAt( 0 );\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tanchorElement.contains( commonAncestorContainer )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tanchorElement.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tfunction onMouseLeave( { buttons, target } ) {\n\t\t\t\t// Avoid triggering a multi-selection if the user is already\n\t\t\t\t// dragging blocks.\n\t\t\t\tif ( isDraggingBlocks() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// The primary button must be pressed to initiate selection.\n\t\t\t\t// See https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\n\t\t\t\tif ( buttons !== 1 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Abort if we are already multi-selecting.\n\t\t\t\tif ( isMultiSelecting() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Abort if selection is leaving writing flow.\n\t\t\t\tif ( node === target ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Check the attribute, not the contentEditable attribute. All\n\t\t\t\t// child elements of the content editable wrapper are editable\n\t\t\t\t// and return true for this property. We only want to start\n\t\t\t\t// multi selecting when the mouse leaves the wrapper.\n\t\t\t\tif ( target.getAttribute( 'contenteditable' ) !== 'true' ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( ! isSelectionEnabled() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Do not rely on the active element because it may change after\n\t\t\t\t// the mouse leaves for the first time. See\n\t\t\t\t// https://github.com/WordPress/gutenberg/issues/48747.\n\t\t\t\tanchorElement = target;\n\n\t\t\t\tstartMultiSelect();\n\n\t\t\t\t// `onSelectionStart` is called after `mousedown` and\n\t\t\t\t// `mouseleave` (from a block). The selection ends when\n\t\t\t\t// `mouseup` happens anywhere in the window.\n\t\t\t\tdefaultView.addEventListener( 'mouseup', onMouseUp );\n\n\t\t\t\t// Allow cross contentEditable selection by temporarily making\n\t\t\t\t// all content editable. We can't rely on using the store and\n\t\t\t\t// React because re-rending happens too slowly. We need to be\n\t\t\t\t// able to select across instances immediately.\n\t\t\t\tsetContentEditableWrapper( node, true );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mouseout', onMouseLeave );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mouseout', onMouseLeave );\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onMouseUp );\n\t\t\t\tdefaultView.cancelAnimationFrame( rafId );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tstartMultiSelect,\n\t\t\tstopMultiSelect,\n\t\t\tisSelectionEnabled,\n\t\t\thasSelectedBlock,\n\t\t]\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,SAASG,yBAAyBA,CAAEC,IAAI,EAAEC,KAAK,EAAG;EACjDD,IAAI,CAACE,eAAe,GAAGD,KAAK;EAC5B;EACA,IAAKA,KAAK,EAAGD,IAAI,CAACG,KAAK,CAAC,CAAC;AAC1B;;AAEA;AACA;AACA;AACe,SAASC,gBAAgBA,CAAA,EAAG;EAC1C,MAAM;IAAEC,gBAAgB;IAAEC;EAAgB,CAAC,GAC1C,IAAAC,iBAAW,EAAEC,YAAiB,CAAC;EAChC,MAAM;IACLC,kBAAkB;IAClBC,gBAAgB;IAChBC,gBAAgB;IAChBC;EACD,CAAC,GAAG,IAAAC,eAAS,EAAEL,YAAiB,CAAC;EACjC,OAAO,IAAAM,qBAAY,EAChBd,IAAI,IAAM;IACX,MAAM;MAAEe;IAAc,CAAC,GAAGf,IAAI;IAC9B,MAAM;MAAEgB;IAAY,CAAC,GAAGD,aAAa;IAErC,IAAIE,aAAa;IACjB,IAAIC,KAAK;IAET,SAASC,SA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ACA;MACA;MACApB,yBAAyB,CAAEC,IAAI,EAAE,IAAK,CAAC;IACxC;IAEAA,IAAI,CAACgC,gBAAgB,CAAE,UAAU,EAAEJ,YAAa,CAAC;IAEjD,OAAO,MAAM;MACZ5B,IAAI,CAACoB,mBAAmB,CAAE,UAAU,EAAEQ,YAAa,CAAC;MACpDZ,WAAW,CAACI,mBAAmB,CAAE,SAAS,EAAED,SAAU,CAAC;MACvDH,WAAW,CAACiB,oBAAoB,CAAEf,KAAM,CAAC;IAC1C,CAAC;EACF,CAAC,EACD,CACCb,gBAAgB,EAChBC,eAAe,EACfG,kBAAkB,EAClBC,gBAAgB,CAElB,CAAC;AACF"}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = useSelectionObserver;
7
7
  var _data = require("@wordpress/data");
8
8
  var _compose = require("@wordpress/compose");
9
+ var _richText = require("@wordpress/rich-text");
9
10
  var _store = require("../../store");
10
11
  var _dom = require("../../utils/dom");
11
12
  /**
@@ -78,9 +79,18 @@ function setContentEditableWrapper(node, value) {
78
79
  // Since we are calling this on every selection change, check if the value
79
80
  // needs to be updated first because it trigger the browser to recalculate
80
81
  // style.
81
- if (node.contentEditable !== String(value)) node.contentEditable = value;
82
- // Firefox doesn't automatically move focus.
83
- if (value) node.focus();
82
+ if (node.contentEditable !== String(value)) {
83
+ node.contentEditable = value;
84
+
85
+ // Firefox doesn't automatically move focus.
86
+ if (value) {
87
+ node.focus();
88
+ }
89
+ }
90
+ }
91
+ function getRichTextElement(node) {
92
+ const element = node.nodeType === node.ELEMENT_NODE ? node : node.parentElement;
93
+ return element?.closest('[data-wp-block-attribute-key]');
84
94
  }
85
95
 
86
96
  /**
@@ -94,7 +104,8 @@ function useSelectionObserver() {
94
104
  } = (0, _data.useDispatch)(_store.store);
95
105
  const {
96
106
  getBlockParents,
97
- getBlockSelectionStart
107
+ getBlockSelectionStart,
108
+ isMultiSelecting
98
109
  } = (0, _data.useSelect)(_store.store);
99
110
  return (0, _compose.useRefEffect)(node => {
100
111
  const {
@@ -108,6 +119,11 @@ function useSelectionObserver() {
108
119
  if (!selection.rangeCount) {
109
120
  return;
110
121
  }
122
+ const startNode = extractSelectionStartNode(selection);
123
+ const endNode = extractSelectionEndNode(selection);
124
+ if (!node.contains(startNode) || !node.contains(endNode)) {
125
+ return;
126
+ }
111
127
 
112
128
  // If selection is collapsed and we haven't used `shift+click`,
113
129
  // end multi selection and disable the contentEditable wrapper.
@@ -117,11 +133,17 @@ function useSelectionObserver() {
117
133
  // For now we check if the event is a `mouse` event.
118
134
  const isClickShift = event.shiftKey && event.type === 'mouseup';
119
135
  if (selection.isCollapsed && !isClickShift) {
120
- setContentEditableWrapper(node, false);
136
+ if (node.contentEditable === 'true' && !isMultiSelecting()) {
137
+ setContentEditableWrapper(node, false);
138
+ let element = startNode.nodeType === startNode.ELEMENT_NODE ? startNode : startNode.parentElement;
139
+ element = element?.closest('[contenteditable]');
140
+ element?.focus();
141
+ }
121
142
  return;
122
143
  }
123
- let startClientId = (0, _dom.getBlockClientId)(extractSelectionStartNode(selection));
124
- let endClientId = (0, _dom.getBlockClientId)(extractSelectionEndNode(selection));
144
+ let startClientId = (0, _dom.getBlockClientId)(startNode);
145
+ let endClientId = (0, _dom.getBlockClientId)(endNode);
146
+
125
147
  // If the selection has changed and we had pressed `shift+click`,
126
148
  // we need to check if in an element that doesn't support
127
149
  // text selection has been clicked.
@@ -148,34 +170,58 @@ function useSelectionObserver() {
148
170
  }
149
171
  const isSingularSelection = startClientId === endClientId;
150
172
  if (isSingularSelection) {
151
- selectBlock(startClientId);
173
+ if (!isMultiSelecting()) {
174
+ selectBlock(startClientId);
175
+ } else {
176
+ multiSelect(startClientId, startClientId);
177
+ }
152
178
  } else {
153
179
  const startPath = [...getBlockParents(startClientId), startClientId];
154
180
  const endPath = [...getBlockParents(endClientId), endClientId];
155
181
  const depth = findDepth(startPath, endPath);
156
- multiSelect(startPath[depth], endPath[depth]);
182
+ if (startPath[depth] !== startClientId || endPath[depth] !== endClientId) {
183
+ multiSelect(startPath[depth], endPath[depth]);
184
+ return;
185
+ }
186
+ const richTextElementStart = getRichTextElement(startNode);
187
+ const richTextElementEnd = getRichTextElement(endNode);
188
+ if (richTextElementStart && richTextElementEnd) {
189
+ var _richTextDataStart$st, _richTextDataEnd$star;
190
+ const range = selection.getRangeAt(0);
191
+ const richTextDataStart = (0, _richText.create)({
192
+ element: richTextElementStart,
193
+ range,
194
+ __unstableIsEditableTree: true
195
+ });
196
+ const richTextDataEnd = (0, _richText.create)({
197
+ element: richTextElementEnd,
198
+ range,
199
+ __unstableIsEditableTree: true
200
+ });
201
+ const startOffset = (_richTextDataStart$st = richTextDataStart.start) !== null && _richTextDataStart$st !== void 0 ? _richTextDataStart$st : richTextDataStart.end;
202
+ const endOffset = (_richTextDataEnd$star = richTextDataEnd.start) !== null && _richTextDataEnd$star !== void 0 ? _richTextDataEnd$star : richTextDataEnd.end;
203
+ selectionChange({
204
+ start: {
205
+ clientId: startClientId,
206
+ attributeKey: richTextElementStart.dataset.wpBlockAttributeKey,
207
+ offset: startOffset
208
+ },
209
+ end: {
210
+ clientId: endClientId,
211
+ attributeKey: richTextElementEnd.dataset.wpBlockAttributeKey,
212
+ offset: endOffset
213
+ }
214
+ });
215
+ } else {
216
+ multiSelect(startClientId, endClientId);
217
+ }
157
218
  }
158
219
  }
159
- function addListeners() {
160
- ownerDocument.addEventListener('selectionchange', onSelectionChange);
161
- defaultView.addEventListener('mouseup', onSelectionChange);
162
- }
163
- function removeListeners() {
220
+ ownerDocument.addEventListener('selectionchange', onSelectionChange);
221
+ defaultView.addEventListener('mouseup', onSelectionChange);
222
+ return () => {
164
223
  ownerDocument.removeEventListener('selectionchange', onSelectionChange);
165
224
  defaultView.removeEventListener('mouseup', onSelectionChange);
166
- }
167
- function resetListeners() {
168
- removeListeners();
169
- addListeners();
170
- }
171
- addListeners();
172
- // We must allow rich text to set selection first. This ensures that
173
- // our `selectionchange` listener is always reset to be called after
174
- // the rich text one.
175
- node.addEventListener('focusin', resetListeners);
176
- return () => {
177
- removeListeners();
178
- node.removeEventListener('focusin', resetListeners);
179
225
  };
180
226
  }, [multiSelect, selectBlock, selectionChange, getBlockParents]);
181
227
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_compose","_store","_dom","extractSelectionStartNode","selection","anchorNode","anchorOffset","nodeType","TEXT_NODE","childNodes","extractSelectionEndNode","focusNode","focusOffset","length","findDepth","a","b","depth","setContentEditableWrapper","node","value","contentEditable","String","focus","useSelectionObserver","multiSelect","selectBlock","selectionChange","useDispatch","blockEditorStore","getBlockParents","getBlockSelectionStart","useSelect","useRefEffect","ownerDocument","defaultView","onSelectionChange","event","getSelection","rangeCount","isClickShift","shiftKey","type","isCollapsed","startClientId","getBlockClientId","endClientId","selectedClientId","clickedClientId","target","focusNodeIsNonSelectable","undefined","isSingularSelection","startPath","endPath","addListeners","addEventListener","removeListeners","removeEventListener","resetListeners"],"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';\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\t// Firefox doesn't automatically move focus.\n\tif ( value ) node.focus();\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 } =\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\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\tsetContentEditableWrapper( node, false );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet startClientId = getBlockClientId(\n\t\t\t\t\textractSelectionStartNode( selection )\n\t\t\t\t);\n\t\t\t\tlet endClientId = getBlockClientId(\n\t\t\t\t\textractSelectionEndNode( selection )\n\t\t\t\t);\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\tselectBlock( startClientId );\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\tmultiSelect( startPath[ depth ], endPath[ depth ] );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction addListeners() {\n\t\t\t\townerDocument.addEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tonSelectionChange\n\t\t\t\t);\n\t\t\t\tdefaultView.addEventListener( 'mouseup', onSelectionChange );\n\t\t\t}\n\n\t\t\tfunction removeListeners() {\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\n\t\t\tfunction resetListeners() {\n\t\t\t\tremoveListeners();\n\t\t\t\taddListeners();\n\t\t\t}\n\n\t\t\taddListeners();\n\t\t\t// We must allow rich text to set selection first. This ensures that\n\t\t\t// our `selectionchange` listener is always reset to be called after\n\t\t\t// the rich text one.\n\t\t\tnode.addEventListener( 'focusin', resetListeners );\n\t\t\treturn () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tnode.removeEventListener( 'focusin', resetListeners );\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;AAKA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,S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e,CAAC,CAAC;MACjBtC,IAAI,CAACuC,mBAAmB,CAAE,SAAS,EAAEC,cAAe,CAAC;IACtD,CAAC;EACF,CAAC,EACD,CAAElC,WAAW,EAAEC,WAAW,EAAEC,eAAe,EAAEG,eAAe,CAC7D,CAAC;AACF"}
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,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AAiB,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"}
@@ -12,6 +12,7 @@ var _compose = require("@wordpress/compose");
12
12
  var _element = require("@wordpress/element");
13
13
  var _store = require("../../store");
14
14
  var _dom2 = require("../../utils/dom");
15
+ var _lockUnlock = require("../../lock-unlock");
15
16
  /**
16
17
  * WordPress dependencies
17
18
  */
@@ -32,9 +33,11 @@ function useTabNav() {
32
33
  const {
33
34
  setNavigationMode,
34
35
  setLastFocus
35
- } = (0, _data.useDispatch)(_store.store);
36
+ } = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
36
37
  const isNavigationMode = (0, _data.useSelect)(select => select(_store.store).isNavigationMode(), []);
37
- const lastFocus = (0, _data.useSelect)(select => select(_store.store).getLastFocus(), []);
38
+ const {
39
+ getLastFocus
40
+ } = (0, _lockUnlock.unlock)((0, _data.useSelect)(_store.store));
38
41
 
39
42
  // Don't allow tabbing to this element in Navigation mode.
40
43
  const focusCaptureTabIndex = !isNavigationMode ? '0' : undefined;
@@ -49,7 +52,7 @@ function useTabNav() {
49
52
  } else if (hasMultiSelection()) {
50
53
  container.current.focus();
51
54
  } else if (getSelectedBlockClientId()) {
52
- lastFocus.current.focus();
55
+ getLastFocus()?.current.focus();
53
56
  } else {
54
57
  setNavigationMode(true);
55
58
  const canvasElement = container.current.ownerDocument === event.target.ownerDocument ? container.current : container.current.ownerDocument.defaultView.frameElement;
@@ -140,7 +143,7 @@ function useTabNav() {
140
143
  }
141
144
  function onFocusOut(event) {
142
145
  setLastFocus({
143
- ...lastFocus,
146
+ ...getLastFocus(),
144
147
  current: event.target
145
148
  });
146
149
  const {
@@ -1 +1 @@
1
- {"version":3,"names":["_dom","require","_keycodes","_data","_compose","_element","_store","_dom2","useTabNav","container","useRef","focusCaptureBeforeRef","focusCaptureAfterRef","hasMultiSelection","getSelectedBlockClientId","getBlockCount","useSelect","blockEditorStore","setNavigationMode","setLastFocus","useDispatch","isNavigationMode","select","lastFocus","getLastFocus","focusCaptureTabIndex","undefined","noCapture","onFocusCapture","event","current","focus","canvasElement","ownerDocument","target","defaultView","frameElement","isBefore","compareDocumentPosition","DOCUMENT_POSITION_FOLLOWING","tabbables","tabbable","find","length","next","before","_react","createElement","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';\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 } = useDispatch( blockEditorStore );\n\tconst isNavigationMode = useSelect(\n\t\t( select ) => select( blockEditorStore ).isNavigationMode(),\n\t\t[]\n\t);\n\n\tconst lastFocus = useSelect(\n\t\t( select ) => select( blockEditorStore ).getLastFocus(),\n\t\t[]\n\t);\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\tlastFocus.current.focus();\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 ) setNavigationMode( true );\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( { ...lastFocus, 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;AAbA;AACA;AACA;;AAOA;AACA;AACA;;AAIe,SAASO,SAASA,CAAA,EAAG;EACnC,MAAMC,SAAS,GAAG,IAAAC,eAAM,EAAC,CAAC;EAC1B,MAAMC,qBAAqB,GAAG,IAAAD,eAAM,EAAC,CAAC;EACtC,MAAME,oBAAoB,GAAG,IAAAF,eAAM,EAAC,CAAC;EAErC,MAAM;IAAEG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nD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMQ,UAAU,GAAG,IAAAC,qBAAY,EAAE,CAAEvE,SAAS,EAAEuC,GAAG,CAAG,CAAC;EAErD,OAAO,CAAEH,MAAM,EAAEkC,UAAU,EAAE5B,KAAK,CAAE;AACrC"}
1
+ {"version":3,"names":["_dom","require","_keycodes","_data","_compose","_element","_store","_dom2","_lockUnlock","useTabNav","container","useRef","focusCaptureBeforeRef","focusCaptureAfterRef","hasMultiSelection","getSelectedBlockClientId","getBlockCount","useSelect","blockEditorStore","setNavigationMode","setLastFocus","unlock","useDispatch","isNavigationMode","select","getLastFocus","focusCaptureTabIndex","undefined","noCapture","onFocusCapture","event","current","focus","canvasElement","ownerDocument","target","defaultView","frameElement","isBefore","compareDocumentPosition","DOCUMENT_POSITION_FOLLOWING","tabbables","tabbable","find","length","next","before","_react","createElement","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\tgetLastFocus()?.current.focus();\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 ) setNavigationMode( true );\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 [ 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,GA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B,CAAC;IAC7DtB,IAAI,CAACwB,gBAAgB,CAAE,SAAS,EAAEvB,SAAU,CAAC;IAC7CD,IAAI,CAACwB,gBAAgB,CAAE,UAAU,EAAEN,UAAW,CAAC;IAC/C,OAAO,MAAM;MACZpC,WAAW,CAAC2C,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,CAAEH,MAAM,EAAEkC,UAAU,EAAE5B,KAAK,CAAE;AACrC"}
@@ -142,6 +142,7 @@ var _default = {
142
142
  shareWithChildBlocks: true,
143
143
  edit: BlockEditAlignmentToolbarControlsPure,
144
144
  useBlockProps,
145
+ addSaveProps: addAssignedAlign,
145
146
  attributeKeys: ['align'],
146
147
  hasSupport(name) {
147
148
  return (0, _blocks.hasBlockSupport)(name, 'align', false);
@@ -189,5 +190,4 @@ function addAssignedAlign(props, blockType, attributes) {
189
190
  return props;
190
191
  }
191
192
  (0, _hooks.addFilter)('blocks.registerBlockType', 'core/editor/align/addAttribute', addAttribute);
192
- (0, _hooks.addFilter)('blocks.getSaveContent.extraProps', 'core/editor/align/addAssignedAlign', addAssignedAlign);
193
193
  //# sourceMappingURL=align.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_classnames","_interopRequireDefault","require","_hooks","_blocks","_components","_useAvailableAlignments","_blockEditingMode","ALL_ALIGNMENTS","WIDE_ALIGNMENTS","getValidAlignments","blockAlign","hasWideBlockSupport","hasWideEnabled","validAlignments","Array","isArray","filter","value","includes","alignment","addAttribute","settings","_settings$attributes$","attributes","align","hasBlockSupport","type","enum","BlockEditAlignmentToolbarControlsPure","name","blockName","setAttributes","blockAllowedAlignments","getBlockSupport","useAvailableAlignments","map","blockEditingMode","useBlockEditingMode","length","updateAlignment","nextAlign","blockType","getBlockType","blockDefaultAlign","default","_react","createElement","BlockControls","group","__experimentalShareWithChildBlocks","BlockAlignmentControl","onChange","controls","_default","shareWithChildBlocks","edit","useBlockProps","attributeKeys","hasSupport","exports","some","addAssignedAlign","props","isAlignValid","className","classnames","addFilter"],"sources":["@wordpress/block-editor/src/hooks/align.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport {\n\tgetBlockSupport,\n\tgetBlockType,\n\thasBlockSupport,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { BlockControls, BlockAlignmentControl } from '../components';\nimport useAvailableAlignments from '../components/block-alignment-control/use-available-alignments';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * An array which includes all possible valid alignments,\n * used to validate if an alignment is valid or not.\n *\n * @constant\n * @type {string[]}\n */\nconst ALL_ALIGNMENTS = [ 'left', 'center', 'right', 'wide', 'full' ];\n\n/**\n * An array which includes all wide alignments.\n * In order for this alignments to be valid they need to be supported by the block,\n * and by the theme.\n *\n * @constant\n * @type {string[]}\n */\nconst WIDE_ALIGNMENTS = [ 'wide', 'full' ];\n\n/**\n * Returns the valid alignments.\n * Takes into consideration the aligns supported by a block, if the block supports wide controls or not and if theme supports wide controls or not.\n * Exported just for testing purposes, not exported outside the module.\n *\n * @param {?boolean|string[]} blockAlign Aligns supported by the block.\n * @param {?boolean} hasWideBlockSupport True if block supports wide alignments. And False otherwise.\n * @param {?boolean} hasWideEnabled True if theme supports wide alignments. And False otherwise.\n *\n * @return {string[]} Valid alignments.\n */\nexport function getValidAlignments(\n\tblockAlign,\n\thasWideBlockSupport = true,\n\thasWideEnabled = true\n) {\n\tlet validAlignments;\n\tif ( Array.isArray( blockAlign ) ) {\n\t\tvalidAlignments = ALL_ALIGNMENTS.filter( ( value ) =>\n\t\t\tblockAlign.includes( value )\n\t\t);\n\t} else if ( blockAlign === true ) {\n\t\t// `true` includes all alignments...\n\t\tvalidAlignments = [ ...ALL_ALIGNMENTS ];\n\t} else {\n\t\tvalidAlignments = [];\n\t}\n\n\tif (\n\t\t! hasWideEnabled ||\n\t\t( blockAlign === true && ! hasWideBlockSupport )\n\t) {\n\t\treturn validAlignments.filter(\n\t\t\t( alignment ) => ! WIDE_ALIGNMENTS.includes( alignment )\n\t\t);\n\t}\n\n\treturn validAlignments;\n}\n\n/**\n * Filters registered block settings, extending attributes to include `align`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( 'type' in ( settings.attributes?.align ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'align' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\talign: {\n\t\t\t\ttype: 'string',\n\t\t\t\t// Allow for '' since it is used by the `updateAlignment` function\n\t\t\t\t// in toolbar controls for special cases with defined default values.\n\t\t\t\tenum: [ ...ALL_ALIGNMENTS, '' ],\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockEditAlignmentToolbarControlsPure( {\n\tname: blockName,\n\talign,\n\tsetAttributes,\n} ) {\n\t// Compute the block valid alignments by taking into account,\n\t// if the theme supports wide alignments or not and the layout's\n\t// available alignments. We do that for conditionally rendering\n\t// Slot.\n\tconst blockAllowedAlignments = getValidAlignments(\n\t\tgetBlockSupport( blockName, 'align' ),\n\t\thasBlockSupport( blockName, 'alignWide', true )\n\t);\n\n\tconst validAlignments = useAvailableAlignments(\n\t\tblockAllowedAlignments\n\t).map( ( { name } ) => name );\n\tconst blockEditingMode = useBlockEditingMode();\n\tif ( ! validAlignments.length || blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\tconst updateAlignment = ( nextAlign ) => {\n\t\tif ( ! nextAlign ) {\n\t\t\tconst blockType = getBlockType( blockName );\n\t\t\tconst blockDefaultAlign = blockType?.attributes?.align?.default;\n\t\t\tif ( blockDefaultAlign ) {\n\t\t\t\tnextAlign = '';\n\t\t\t}\n\t\t}\n\t\tsetAttributes( { align: nextAlign } );\n\t};\n\n\treturn (\n\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t<BlockAlignmentControl\n\t\t\t\tvalue={ align }\n\t\t\t\tonChange={ updateAlignment }\n\t\t\t\tcontrols={ validAlignments }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n}\n\nexport default {\n\tshareWithChildBlocks: true,\n\tedit: BlockEditAlignmentToolbarControlsPure,\n\tuseBlockProps,\n\tattributeKeys: [ 'align' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'align', false );\n\t},\n};\n\nfunction useBlockProps( { name, align } ) {\n\tconst blockAllowedAlignments = getValidAlignments(\n\t\tgetBlockSupport( name, 'align' ),\n\t\thasBlockSupport( name, 'alignWide', true )\n\t);\n\tconst validAlignments = useAvailableAlignments( blockAllowedAlignments );\n\n\tif ( validAlignments.some( ( alignment ) => alignment.name === align ) ) {\n\t\treturn { 'data-align': align };\n\t}\n\n\treturn {};\n}\n\n/**\n * Override props assigned to save component to inject alignment class name if\n * block supports it.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addAssignedAlign( props, blockType, attributes ) {\n\tconst { align } = attributes;\n\tconst blockAlign = getBlockSupport( blockType, 'align' );\n\tconst hasWideBlockSupport = hasBlockSupport( blockType, 'alignWide', true );\n\n\t// Compute valid alignments without taking into account if\n\t// the theme supports wide alignments or not.\n\t// This way changing themes does not impact the block save.\n\tconst isAlignValid = getValidAlignments(\n\t\tblockAlign,\n\t\thasWideBlockSupport\n\t).includes( align );\n\tif ( isAlignValid ) {\n\t\tprops.className = classnames( `align${ align }`, props.className );\n\t}\n\n\treturn props;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/align/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/editor/align/addAssignedAlign',\n\taddAssignedAlign\n);\n"],"mappings":";;;;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AASA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,uBAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AApBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMM,cAAc,GAAG,CAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAE;;AAEpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,eAAe,GAAG,CAAE,MAAM,EAAE,MAAM,CAAE;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,kBAAkBA,CACjCC,UAAU,EACVC,mBAAmB,GAAG,IAAI,EAC1BC,cAAc,GAAG,IAAI,EACpB;EACD,IAAIC,eAAe;EACnB,IAAKC,KAAK,CAACC,OAAO,CAAEL,UAAW,CAAC,EAAG;IAClCG,eAAe,GAAGN,cAAc,CAACS,MAAM,CAAIC,KAAK,IAC/CP,UAAU,CAACQ,QAAQ,CAAED,KAAM,CAC5B,CAAC;EACF,CAAC,MAAM,IAAKP,UAAU,KAAK,IAAI,EAAG;IACjC;IACAG,eAAe,GAAG,CAAE,GAAGN,cAAc,CAAE;EACxC,CAAC,MAAM;IACNM,eAAe,GAAG,EAAE;EACr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C,CAAC;EACD,MAAMhB,eAAe,GAAG,IAAAqB,+BAAsB,EAAEF,sBAAuB,CAAC;EAExE,IAAKnB,eAAe,CAAC+C,IAAI,CAAIzC,SAAS,IAAMA,SAAS,CAACU,IAAI,KAAKL,KAAM,CAAC,EAAG;IACxE,OAAO;MAAE,YAAY,EAAEA;IAAM,CAAC;EAC/B;EAEA,OAAO,CAAC,CAAC;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASqC,gBAAgBA,CAAEC,KAAK,EAAErB,SAAS,EAAElB,UAAU,EAAG;EAChE,MAAM;IAAEC;EAAM,CAAC,GAAGD,UAAU;EAC5B,MAAMb,UAAU,GAAG,IAAAuB,uBAAe,EAAEQ,SAAS,EAAE,OAAQ,CAAC;EACxD,MAAM9B,mBAAmB,GAAG,IAAAc,uBAAe,EAAEgB,SAAS,EAAE,WAAW,EAAE,IAAK,CAAC;;EAE3E;EACA;EACA;EACA,MAAMsB,YAAY,GAAGtD,kBAAkB,CACtCC,UAAU,EACVC,mBACD,CAAC,CAACO,QAAQ,CAAEM,KAAM,CAAC;EACnB,IAAKuC,YAAY,EAAG;IACnBD,KAAK,CAACE,SAAS,GAAG,IAAAC,mBAAU,EAAG,QAAQzC,KAAO,EAAC,EAAEsC,KAAK,CAACE,SAAU,CAAC;EACnE;EAEA,OAAOF,KAAK;AACb;AAEA,IAAAI,gBAAS,EACR,0BAA0B,EAC1B,gCAAgC,EAChC9C,YACD,CAAC;AACD,IAAA8C,gBAAS,EACR,kCAAkC,EAClC,oCAAoC,EACpCL,gBACD,CAAC"}
1
+ {"version":3,"names":["_classnames","_interopRequireDefault","require","_hooks","_blocks","_components","_useAvailableAlignments","_blockEditingMode","ALL_ALIGNMENTS","WIDE_ALIGNMENTS","getValidAlignments","blockAlign","hasWideBlockSupport","hasWideEnabled","validAlignments","Array","isArray","filter","value","includes","alignment","addAttribute","settings","_settings$attributes$","attributes","align","hasBlockSupport","type","enum","BlockEditAlignmentToolbarControlsPure","name","blockName","setAttributes","blockAllowedAlignments","getBlockSupport","useAvailableAlignments","map","blockEditingMode","useBlockEditingMode","length","updateAlignment","nextAlign","blockType","getBlockType","blockDefaultAlign","default","_react","createElement","BlockControls","group","__experimentalShareWithChildBlocks","BlockAlignmentControl","onChange","controls","_default","shareWithChildBlocks","edit","useBlockProps","addSaveProps","addAssignedAlign","attributeKeys","hasSupport","exports","some","props","isAlignValid","className","classnames","addFilter"],"sources":["@wordpress/block-editor/src/hooks/align.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport {\n\tgetBlockSupport,\n\tgetBlockType,\n\thasBlockSupport,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { BlockControls, BlockAlignmentControl } from '../components';\nimport useAvailableAlignments from '../components/block-alignment-control/use-available-alignments';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * An array which includes all possible valid alignments,\n * used to validate if an alignment is valid or not.\n *\n * @constant\n * @type {string[]}\n */\nconst ALL_ALIGNMENTS = [ 'left', 'center', 'right', 'wide', 'full' ];\n\n/**\n * An array which includes all wide alignments.\n * In order for this alignments to be valid they need to be supported by the block,\n * and by the theme.\n *\n * @constant\n * @type {string[]}\n */\nconst WIDE_ALIGNMENTS = [ 'wide', 'full' ];\n\n/**\n * Returns the valid alignments.\n * Takes into consideration the aligns supported by a block, if the block supports wide controls or not and if theme supports wide controls or not.\n * Exported just for testing purposes, not exported outside the module.\n *\n * @param {?boolean|string[]} blockAlign Aligns supported by the block.\n * @param {?boolean} hasWideBlockSupport True if block supports wide alignments. And False otherwise.\n * @param {?boolean} hasWideEnabled True if theme supports wide alignments. And False otherwise.\n *\n * @return {string[]} Valid alignments.\n */\nexport function getValidAlignments(\n\tblockAlign,\n\thasWideBlockSupport = true,\n\thasWideEnabled = true\n) {\n\tlet validAlignments;\n\tif ( Array.isArray( blockAlign ) ) {\n\t\tvalidAlignments = ALL_ALIGNMENTS.filter( ( value ) =>\n\t\t\tblockAlign.includes( value )\n\t\t);\n\t} else if ( blockAlign === true ) {\n\t\t// `true` includes all alignments...\n\t\tvalidAlignments = [ ...ALL_ALIGNMENTS ];\n\t} else {\n\t\tvalidAlignments = [];\n\t}\n\n\tif (\n\t\t! hasWideEnabled ||\n\t\t( blockAlign === true && ! hasWideBlockSupport )\n\t) {\n\t\treturn validAlignments.filter(\n\t\t\t( alignment ) => ! WIDE_ALIGNMENTS.includes( alignment )\n\t\t);\n\t}\n\n\treturn validAlignments;\n}\n\n/**\n * Filters registered block settings, extending attributes to include `align`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( 'type' in ( settings.attributes?.align ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'align' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\talign: {\n\t\t\t\ttype: 'string',\n\t\t\t\t// Allow for '' since it is used by the `updateAlignment` function\n\t\t\t\t// in toolbar controls for special cases with defined default values.\n\t\t\t\tenum: [ ...ALL_ALIGNMENTS, '' ],\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockEditAlignmentToolbarControlsPure( {\n\tname: blockName,\n\talign,\n\tsetAttributes,\n} ) {\n\t// Compute the block valid alignments by taking into account,\n\t// if the theme supports wide alignments or not and the layout's\n\t// available alignments. We do that for conditionally rendering\n\t// Slot.\n\tconst blockAllowedAlignments = getValidAlignments(\n\t\tgetBlockSupport( blockName, 'align' ),\n\t\thasBlockSupport( blockName, 'alignWide', true )\n\t);\n\n\tconst validAlignments = useAvailableAlignments(\n\t\tblockAllowedAlignments\n\t).map( ( { name } ) => name );\n\tconst blockEditingMode = useBlockEditingMode();\n\tif ( ! validAlignments.length || blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\tconst updateAlignment = ( nextAlign ) => {\n\t\tif ( ! nextAlign ) {\n\t\t\tconst blockType = getBlockType( blockName );\n\t\t\tconst blockDefaultAlign = blockType?.attributes?.align?.default;\n\t\t\tif ( blockDefaultAlign ) {\n\t\t\t\tnextAlign = '';\n\t\t\t}\n\t\t}\n\t\tsetAttributes( { align: nextAlign } );\n\t};\n\n\treturn (\n\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t<BlockAlignmentControl\n\t\t\t\tvalue={ align }\n\t\t\t\tonChange={ updateAlignment }\n\t\t\t\tcontrols={ validAlignments }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n}\n\nexport default {\n\tshareWithChildBlocks: true,\n\tedit: BlockEditAlignmentToolbarControlsPure,\n\tuseBlockProps,\n\taddSaveProps: addAssignedAlign,\n\tattributeKeys: [ 'align' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'align', false );\n\t},\n};\n\nfunction useBlockProps( { name, align } ) {\n\tconst blockAllowedAlignments = getValidAlignments(\n\t\tgetBlockSupport( name, 'align' ),\n\t\thasBlockSupport( name, 'alignWide', true )\n\t);\n\tconst validAlignments = useAvailableAlignments( blockAllowedAlignments );\n\n\tif ( validAlignments.some( ( alignment ) => alignment.name === align ) ) {\n\t\treturn { 'data-align': align };\n\t}\n\n\treturn {};\n}\n\n/**\n * Override props assigned to save component to inject alignment class name if\n * block supports it.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addAssignedAlign( props, blockType, attributes ) {\n\tconst { align } = attributes;\n\tconst blockAlign = getBlockSupport( blockType, 'align' );\n\tconst hasWideBlockSupport = hasBlockSupport( blockType, 'alignWide', true );\n\n\t// Compute valid alignments without taking into account if\n\t// the theme supports wide alignments or not.\n\t// This way changing themes does not impact the block save.\n\tconst isAlignValid = getValidAlignments(\n\t\tblockAlign,\n\t\thasWideBlockSupport\n\t).includes( align );\n\tif ( isAlignValid ) {\n\t\tprops.className = classnames( `align${ align }`, props.className );\n\t}\n\n\treturn props;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/align/addAttribute',\n\taddAttribute\n);\n"],"mappings":";;;;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AASA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,uBAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AApBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMM,cAAc,GAAG,CAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAE;;AAEpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,eAAe,GAAG,CAAE,MAAM,EAAE,MAAM,CAAE;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,kBAAkBA,CACjCC,UAAU,EACVC,mBAAmB,GAAG,IAAI,EAC1BC,cAAc,GAAG,IAAI,EACpB;EACD,IAAIC,eAAe;EACnB,IAAKC,KAAK,CAACC,OAAO,CAAEL,UAAW,CAAC,EAAG;IAClCG,eAAe,GAAGN,cAAc,CAACS,MAAM,CAAIC,KAAK,IAC/CP,UAAU,CAACQ,QAAQ,CAAED,KAAM,CAC5B,CAAC;EACF,CAAC,MAAM,IAAKP,UAAU,KAAK,IAAI,EAAG;IACjC;IACAG,eAAe,GAAG,CAAE,GAAGN,cAAc,CAAE;EACxC,CAAC,MAAM;IACNM,eAAe,GAAG,EAAE;EACrB;EAEA,IACC,CAAED,cAAc,IACdF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1C,CAAC;EACD,MAAMhB,eAAe,GAAG,IAAAqB,+BAAsB,EAAEF,sBAAuB,CAAC;EAExE,IAAKnB,eAAe,CAACiD,IAAI,CAAI3C,SAAS,IAAMA,SAAS,CAACU,IAAI,KAAKL,KAAM,CAAC,EAAG;IACxE,OAAO;MAAE,YAAY,EAAEA;IAAM,CAAC;EAC/B;EAEA,OAAO,CAAC,CAAC;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASkC,gBAAgBA,CAAEK,KAAK,EAAEtB,SAAS,EAAElB,UAAU,EAAG;EAChE,MAAM;IAAEC;EAAM,CAAC,GAAGD,UAAU;EAC5B,MAAMb,UAAU,GAAG,IAAAuB,uBAAe,EAAEQ,SAAS,EAAE,OAAQ,CAAC;EACxD,MAAM9B,mBAAmB,GAAG,IAAAc,uBAAe,EAAEgB,SAAS,EAAE,WAAW,EAAE,IAAK,CAAC;;EAE3E;EACA;EACA;EACA,MAAMuB,YAAY,GAAGvD,kBAAkB,CACtCC,UAAU,EACVC,mBACD,CAAC,CAACO,QAAQ,CAAEM,KAAM,CAAC;EACnB,IAAKwC,YAAY,EAAG;IACnBD,KAAK,CAACE,SAAS,GAAG,IAAAC,mBAAU,EAAG,QAAQ1C,KAAO,EAAC,EAAEuC,KAAK,CAACE,SAAU,CAAC;EACnE;EAEA,OAAOF,KAAK;AACb;AAEA,IAAAI,gBAAS,EACR,0BAA0B,EAC1B,gCAAgC,EAChC/C,YACD,CAAC"}
@@ -91,6 +91,7 @@ function BlockEditAnchorControlPure({
91
91
  }, textControl)));
92
92
  }
93
93
  var _default = {
94
+ addSaveProps,
94
95
  edit: BlockEditAnchorControlPure,
95
96
  attributeKeys: ['anchor'],
96
97
  hasSupport(name) {
@@ -116,5 +117,4 @@ function addSaveProps(extraProps, blockType, attributes) {
116
117
  return extraProps;
117
118
  }
118
119
  (0, _hooks.addFilter)('blocks.registerBlockType', 'core/anchor/attribute', addAttribute);
119
- (0, _hooks.addFilter)('blocks.getSaveContent.extraProps', 'core/editor/anchor/save-props', addSaveProps);
120
120
  //# sourceMappingURL=anchor.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_hooks","require","_components","_i18n","_blocks","_element","_components2","_blockEditingMode","ANCHOR_REGEX","ANCHOR_SCHEMA","type","source","attribute","selector","addAttribute","settings","_settings$attributes$","attributes","anchor","hasBlockSupport","BlockEditAnchorControlPure","name","blockName","setAttributes","blockEditingMode","useBlockEditingMode","isWeb","Platform","OS","textControl","_react","createElement","TextControl","__nextHasNoMarginBottom","__next40pxDefaultSize","className","label","__","help","Fragment","ExternalLink","href","value","placeholder","onChange","nextValue","replace","autoCapitalize","autoComplete","InspectorControls","group","PanelBody","title","_default","edit","attributeKeys","hasSupport","exports","default","addSaveProps","extraProps","blockType","id","addFilter"],"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\nconst ANCHOR_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'id',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( 'type' in ( settings.attributes?.anchor ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: ANCHOR_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockEditAnchorControlPure( {\n\tname: blockName,\n\tanchor,\n\tsetAttributes,\n} ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst isWeb = Platform.OS === 'web';\n\tconst textControl = (\n\t\t<TextControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tclassName=\"html-anchor-control\"\n\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\thelp={\n\t\t\t\t<>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-jumps/'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t}\n\t\t\tvalue={ anchor || '' }\n\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tanchor: nextValue,\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tautoCapitalize=\"none\"\n\t\t\tautoComplete=\"off\"\n\t\t/>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ isWeb && blockEditingMode === 'default' && (\n\t\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t\t{ textControl }\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t{ /*\n\t\t\t * We plan to remove scoping anchors to 'core/heading' to support\n\t\t\t * anchors for all eligble blocks. Additionally we plan to explore\n\t\t\t * leveraging InspectorAdvancedControls instead of a custom\n\t\t\t * PanelBody title. https://github.com/WordPress/gutenberg/issues/28363\n\t\t\t */ }\n\t\t\t{ ! isWeb && blockName === 'core/heading' && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Heading settings' ) }>\n\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default {\n\tedit: BlockEditAnchorControlPure,\n\tattributeKeys: [ 'anchor' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'anchor' );\n\t},\n};\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/editor/anchor/save-props',\n\taddSaveProps\n);\n"],"mappings":";;;;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAN,OAAA;AAbA;AACA;AACA;;AAOA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA,MA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AE5C,UAAU,EAAG;EACjE,IAAK,IAAAE,uBAAe,EAAE0C,SAAS,EAAE,QAAS,CAAC,EAAG;IAC7CD,UAAU,CAACE,EAAE,GAAG7C,UAAU,CAACC,MAAM,KAAK,EAAE,GAAG,IAAI,GAAGD,UAAU,CAACC,MAAM;EACpE;EAEA,OAAO0C,UAAU;AAClB;AAEA,IAAAG,gBAAS,EAAE,0BAA0B,EAAE,uBAAuB,EAAEjD,YAAa,CAAC;AAC9E,IAAAiD,gBAAS,EACR,kCAAkC,EAClC,+BAA+B,EAC/BJ,YACD,CAAC"}
1
+ {"version":3,"names":["_hooks","require","_components","_i18n","_blocks","_element","_components2","_blockEditingMode","ANCHOR_REGEX","ANCHOR_SCHEMA","type","source","attribute","selector","addAttribute","settings","_settings$attributes$","attributes","anchor","hasBlockSupport","BlockEditAnchorControlPure","name","blockName","setAttributes","blockEditingMode","useBlockEditingMode","isWeb","Platform","OS","textControl","_react","createElement","TextControl","__nextHasNoMarginBottom","__next40pxDefaultSize","className","label","__","help","Fragment","ExternalLink","href","value","placeholder","onChange","nextValue","replace","autoCapitalize","autoComplete","InspectorControls","group","PanelBody","title","_default","addSaveProps","edit","attributeKeys","hasSupport","exports","default","extraProps","blockType","id","addFilter"],"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\nconst ANCHOR_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'id',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( 'type' in ( settings.attributes?.anchor ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: ANCHOR_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockEditAnchorControlPure( {\n\tname: blockName,\n\tanchor,\n\tsetAttributes,\n} ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst isWeb = Platform.OS === 'web';\n\tconst textControl = (\n\t\t<TextControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tclassName=\"html-anchor-control\"\n\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\thelp={\n\t\t\t\t<>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-jumps/'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t}\n\t\t\tvalue={ anchor || '' }\n\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tanchor: nextValue,\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tautoCapitalize=\"none\"\n\t\t\tautoComplete=\"off\"\n\t\t/>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ isWeb && blockEditingMode === 'default' && (\n\t\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t\t{ textControl }\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t{ /*\n\t\t\t * We plan to remove scoping anchors to 'core/heading' to support\n\t\t\t * anchors for all eligble blocks. Additionally we plan to explore\n\t\t\t * leveraging InspectorAdvancedControls instead of a custom\n\t\t\t * PanelBody title. https://github.com/WordPress/gutenberg/issues/28363\n\t\t\t */ }\n\t\t\t{ ! isWeb && blockName === 'core/heading' && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Heading settings' ) }>\n\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default {\n\taddSaveProps,\n\tedit: BlockEditAnchorControlPure,\n\tattributeKeys: [ 'anchor' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'anchor' );\n\t},\n};\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\n"],"mappings":";;;;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,G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AG;IAClB,OAAO,IAAAF,uBAAe,EAAEE,IAAI,EAAE,QAAS,CAAC;EACzC;AACD,CAAC;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVAqC,OAAA,CAAAC,OAAA,GAAAN,QAAA;AAWO,SAASC,YAAYA,CAAEM,UAAU,EAAEC,SAAS,EAAE5C,UAAU,EAAG;EACjE,IAAK,IAAAE,uBAAe,EAAE0C,SAAS,EAAE,QAAS,CAAC,EAAG;IAC7CD,UAAU,CAACE,EAAE,GAAG7C,UAAU,CAACC,MAAM,KAAK,EAAE,GAAG,IAAI,GAAGD,UAAU,CAACC,MAAM;EACpE;EAEA,OAAO0C,UAAU;AAClB;AAEA,IAAAG,gBAAS,EAAE,0BAA0B,EAAE,uBAAuB,EAAEjD,YAAa,CAAC"}
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.addAttribute = addAttribute;
7
7
  exports.addSaveProps = addSaveProps;
8
+ exports.default = void 0;
8
9
  var _hooks = require("@wordpress/hooks");
9
10
  var _blocks = require("@wordpress/blocks");
10
11
  /**
@@ -58,6 +59,13 @@ function addSaveProps(extraProps, blockType, attributes) {
58
59
  }
59
60
  return extraProps;
60
61
  }
62
+ var _default = {
63
+ addSaveProps,
64
+ attributeKeys: ['ariaLabel'],
65
+ hasSupport(name) {
66
+ return (0, _blocks.hasBlockSupport)(name, 'ariaLabel');
67
+ }
68
+ };
69
+ exports.default = _default;
61
70
  (0, _hooks.addFilter)('blocks.registerBlockType', 'core/ariaLabel/attribute', addAttribute);
62
- (0, _hooks.addFilter)('blocks.getSaveContent.extraProps', 'core/ariaLabel/save-props', addSaveProps);
63
71
  //# sourceMappingURL=aria-label.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_hooks","require","_blocks","ARIA_LABEL_SCHEMA","type","source","attribute","selector","addAttribute","settings","attributes","ariaLabel","hasBlockSupport","addSaveProps","extraProps","blockType","addFilter"],"sources":["@wordpress/block-editor/src/hooks/aria-label.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\n\nconst ARIA_LABEL_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'aria-label',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with ariaLabel using aria-label\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( settings?.attributes?.ariaLabel?.type ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'ariaLabel' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tariaLabel: ARIA_LABEL_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override props assigned to save component to inject aria-label, if block\n * supports ariaLabel. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'ariaLabel' ) ) {\n\t\textraProps[ 'aria-label' ] =\n\t\t\tattributes.ariaLabel === '' ? null : attributes.ariaLabel;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/ariaLabel/attribute',\n\taddAttribute\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/ariaLabel/save-props',\n\taddSaveProps\n);\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIA,MAAME,iBAAiB,GAAG;EACzBC,IAAI,EAAE,QAAQ;EACdC,MAAM,EAAE,WAAW;EACnBC,SAAS,EAAE,YAAY;EACvBC,QAAQ,EAAE;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,YAAYA,CAAEC,QAAQ,EAAG;EACxC;EACA,IAAKA,QAAQ,EAAEC,UAAU,EAAEC,SAAS,EAAEP,IAAI,EAAG;IAC5C,OAAOK,QAAQ;EAChB;EACA,IAAK,IAAAG,uBAAe,EAAEH,QAAQ,EAAE,WAAY,CAAC,EAAG;IAC/C;IACAA,QAAQ,CAACC,UAAU,GAAG;MACrB,GAAGD,QAAQ,CAACC,UAAU;MACtBC,SAAS,EAAER;IACZ,CAAC;EACF;EAEA,OAAOM,QAAQ;AAChB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,YAAYA,CAAEC,UAAU,EAAEC,SAAS,EAAEL,UAAU,EAAG;EACjE,IAAK,IAAAE,uBAAe,EAAEG,SAAS,EAAE,WAAY,CAAC,EAAG;IAChDD,UAAU,CAAE,YAAY,CAAE,GACzBJ,UAAU,CAACC,SAAS,KAAK,EAAE,GAAG,IAAI,GAAGD,UAAU,CAACC,SAAS;EAC3D;EAEA,OAAOG,UAAU;AAClB;AAEA,IAAAE,gBAAS,EACR,0BAA0B,EAC1B,0BAA0B,EAC1BR,YACD,CAAC;AACD,IAAAQ,gBAAS,EACR,kCAAkC,EAClC,2BAA2B,EAC3BH,YACD,CAAC"}
1
+ {"version":3,"names":["_hooks","require","_blocks","ARIA_LABEL_SCHEMA","type","source","attribute","selector","addAttribute","settings","attributes","ariaLabel","hasBlockSupport","addSaveProps","extraProps","blockType","_default","attributeKeys","hasSupport","name","exports","default","addFilter"],"sources":["@wordpress/block-editor/src/hooks/aria-label.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\n\nconst ARIA_LABEL_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'aria-label',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with ariaLabel using aria-label\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( settings?.attributes?.ariaLabel?.type ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'ariaLabel' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tariaLabel: ARIA_LABEL_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override props assigned to save component to inject aria-label, if block\n * supports ariaLabel. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'ariaLabel' ) ) {\n\t\textraProps[ 'aria-label' ] =\n\t\t\tattributes.ariaLabel === '' ? null : attributes.ariaLabel;\n\t}\n\n\treturn extraProps;\n}\n\nexport default {\n\taddSaveProps,\n\tattributeKeys: [ 'ariaLabel' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'ariaLabel' );\n\t},\n};\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/ariaLabel/attribute',\n\taddAttribute\n);\n"],"mappings":";;;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIA,MAAME,iBAAiB,GAAG;EACzBC,IAAI,EAAE,QAAQ;EACdC,MAAM,EAAE,WAAW;EACnBC,SAAS,EAAE,YAAY;EACvBC,QAAQ,EAAE;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;A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