@wordpress/block-editor 12.25.0 → 12.26.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 (674) hide show
  1. package/CHANGELOG.md +9 -3
  2. package/README.md +6 -0
  3. package/build/components/block-actions/index.js +4 -2
  4. package/build/components/block-actions/index.js.map +1 -1
  5. package/build/components/block-alignment-control/ui.js +2 -2
  6. package/build/components/block-alignment-control/ui.js.map +1 -1
  7. package/build/components/block-card/index.js +2 -2
  8. package/build/components/block-card/index.js.map +1 -1
  9. package/build/components/block-compare/index.js +2 -2
  10. package/build/components/block-compare/index.js.map +1 -1
  11. package/build/components/block-edit/edit.js +2 -2
  12. package/build/components/block-edit/edit.js.map +1 -1
  13. package/build/components/block-icon/index.js +2 -2
  14. package/build/components/block-icon/index.js.map +1 -1
  15. package/build/components/block-inspector/index.js +1 -1
  16. package/build/components/block-inspector/index.js.map +1 -1
  17. package/build/components/block-list/block.js +4 -4
  18. package/build/components/block-list/block.js.map +1 -1
  19. package/build/components/block-list/block.native.js +2 -2
  20. package/build/components/block-list/block.native.js.map +1 -1
  21. package/build/components/block-list/index.js +2 -2
  22. package/build/components/block-list/index.js.map +1 -1
  23. package/build/components/block-list/use-block-props/index.js +5 -2
  24. package/build/components/block-list/use-block-props/index.js.map +1 -1
  25. package/build/components/block-list/use-block-props/use-scroll-into-view.js +44 -0
  26. package/build/components/block-list/use-block-props/use-scroll-into-view.js.map +1 -0
  27. package/build/components/block-list-appender/index.js +2 -2
  28. package/build/components/block-list-appender/index.js.map +1 -1
  29. package/build/components/block-mover/button.js +2 -2
  30. package/build/components/block-mover/button.js.map +1 -1
  31. package/build/components/block-mover/index.js +2 -2
  32. package/build/components/block-mover/index.js.map +1 -1
  33. package/build/components/block-patterns-list/index.js +26 -5
  34. package/build/components/block-patterns-list/index.js.map +1 -1
  35. package/build/components/block-popover/cover.js +9 -6
  36. package/build/components/block-popover/cover.js.map +1 -1
  37. package/build/components/block-popover/inbetween.js +2 -2
  38. package/build/components/block-popover/inbetween.js.map +1 -1
  39. package/build/components/block-popover/index.js +22 -4
  40. package/build/components/block-popover/index.js.map +1 -1
  41. package/build/components/block-preview/index.js +2 -2
  42. package/build/components/block-preview/index.js.map +1 -1
  43. package/build/components/block-settings-menu/block-settings-dropdown.js +8 -5
  44. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  45. package/build/components/block-settings-menu-controls/index.js +10 -7
  46. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  47. package/build/components/block-styles/index.js +2 -2
  48. package/build/components/block-styles/index.js.map +1 -1
  49. package/build/components/block-toolbar/index.js +3 -3
  50. package/build/components/block-toolbar/index.js.map +1 -1
  51. package/build/components/block-tools/block-selection-button.js +2 -2
  52. package/build/components/block-tools/block-selection-button.js.map +1 -1
  53. package/build/components/block-tools/block-toolbar-breadcrumb.js +4 -4
  54. package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
  55. package/build/components/block-tools/block-toolbar-popover.js +2 -2
  56. package/build/components/block-tools/block-toolbar-popover.js.map +1 -1
  57. package/build/components/block-tools/empty-block-inserter.js +2 -2
  58. package/build/components/block-tools/empty-block-inserter.js.map +1 -1
  59. package/build/components/block-tools/index.js +20 -1
  60. package/build/components/block-tools/index.js.map +1 -1
  61. package/build/components/block-tools/insertion-point.js +4 -4
  62. package/build/components/block-tools/insertion-point.js.map +1 -1
  63. package/build/components/block-tools/zoom-out-mode-inserters.js +66 -22
  64. package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  65. package/build/components/block-variation-picker/index.js +2 -2
  66. package/build/components/block-variation-picker/index.js.map +1 -1
  67. package/build/components/button-block-appender/index.js +2 -2
  68. package/build/components/button-block-appender/index.js.map +1 -1
  69. package/build/components/child-layout-control/index.js +2 -2
  70. package/build/components/child-layout-control/index.js.map +1 -1
  71. package/build/components/colors-gradients/control.js +3 -3
  72. package/build/components/colors-gradients/control.js.map +1 -1
  73. package/build/components/colors-gradients/dropdown.js +2 -2
  74. package/build/components/colors-gradients/dropdown.js.map +1 -1
  75. package/build/components/colors-gradients/panel-color-gradient-settings.js +2 -2
  76. package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  77. package/build/components/convert-to-group-buttons/index.js +6 -0
  78. package/build/components/convert-to-group-buttons/index.js.map +1 -1
  79. package/build/components/default-block-appender/index.js +2 -2
  80. package/build/components/default-block-appender/index.js.map +1 -1
  81. package/build/components/dimensions-tool/aspect-ratio-tool.js +30 -36
  82. package/build/components/dimensions-tool/aspect-ratio-tool.js.map +1 -1
  83. package/build/components/global-styles/background-panel.js +3 -3
  84. package/build/components/global-styles/background-panel.js.map +1 -1
  85. package/build/components/global-styles/color-panel.js +3 -3
  86. package/build/components/global-styles/color-panel.js.map +1 -1
  87. package/build/components/global-styles/dimensions-panel.js +4 -4
  88. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  89. package/build/components/global-styles/filters-panel.js +2 -2
  90. package/build/components/global-styles/filters-panel.js.map +1 -1
  91. package/build/components/global-styles/shadow-panel-components.js +4 -4
  92. package/build/components/global-styles/shadow-panel-components.js.map +1 -1
  93. package/build/components/global-styles/use-global-styles-output.js +1 -1
  94. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  95. package/build/components/grid-visualizer/grid-item-resizer.js +141 -24
  96. package/build/components/grid-visualizer/grid-item-resizer.js.map +1 -1
  97. package/build/components/grid-visualizer/grid-visualizer.js +11 -5
  98. package/build/components/grid-visualizer/grid-visualizer.js.map +1 -1
  99. package/build/components/iframe/index.js +69 -30
  100. package/build/components/iframe/index.js.map +1 -1
  101. package/build/components/image-editor/aspect-ratio-dropdown.js +53 -36
  102. package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  103. package/build/components/image-editor/cropper.js +2 -2
  104. package/build/components/image-editor/cropper.js.map +1 -1
  105. package/build/components/image-editor/index.js +1 -1
  106. package/build/components/image-editor/index.js.map +1 -1
  107. package/build/components/index.js +8 -0
  108. package/build/components/index.js.map +1 -1
  109. package/build/components/inner-blocks/button-block-appender.js +2 -2
  110. package/build/components/inner-blocks/button-block-appender.js.map +1 -1
  111. package/build/components/inner-blocks/index.js +22 -21
  112. package/build/components/inner-blocks/index.js.map +1 -1
  113. package/build/components/inserter/block-patterns-explorer/pattern-list.js +1 -1
  114. package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  115. package/build/components/inserter/block-patterns-tab/index.js +9 -0
  116. package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
  117. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +1 -1
  118. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  119. package/build/components/inserter/block-types-tab.js +5 -3
  120. package/build/components/inserter/block-types-tab.js.map +1 -1
  121. package/build/components/inserter/hooks/use-insertion-point.js +11 -2
  122. package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
  123. package/build/components/inserter/hooks/use-patterns-state.js +12 -5
  124. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  125. package/build/components/inserter/index.js +2 -2
  126. package/build/components/inserter/index.js.map +1 -1
  127. package/build/components/inserter/library.js +8 -2
  128. package/build/components/inserter/library.js.map +1 -1
  129. package/build/components/inserter/media-tab/media-preview.js +2 -2
  130. package/build/components/inserter/media-tab/media-preview.js.map +1 -1
  131. package/build/components/inserter/menu.js +72 -56
  132. package/build/components/inserter/menu.js.map +1 -1
  133. package/build/components/inserter/quick-inserter.js +2 -2
  134. package/build/components/inserter/quick-inserter.js.map +1 -1
  135. package/build/components/inserter/tabs.js +17 -5
  136. package/build/components/inserter/tabs.js.map +1 -1
  137. package/build/components/inserter-list-item/index.js +3 -3
  138. package/build/components/inserter-list-item/index.js.map +1 -1
  139. package/build/components/keyboard-shortcuts/index.js +9 -0
  140. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  141. package/build/components/link-control/index.js +2 -2
  142. package/build/components/link-control/index.js.map +1 -1
  143. package/build/components/link-control/link-preview.js +3 -3
  144. package/build/components/link-control/link-preview.js.map +1 -1
  145. package/build/components/link-control/search-results.js +2 -2
  146. package/build/components/link-control/search-results.js.map +1 -1
  147. package/build/components/list-view/block-contents.js +2 -2
  148. package/build/components/list-view/block-contents.js.map +1 -1
  149. package/build/components/list-view/block-select-button.js +11 -3
  150. package/build/components/list-view/block-select-button.js.map +1 -1
  151. package/build/components/list-view/block.js +35 -12
  152. package/build/components/list-view/block.js.map +1 -1
  153. package/build/components/list-view/drop-indicator.js +3 -3
  154. package/build/components/list-view/drop-indicator.js.map +1 -1
  155. package/build/components/list-view/index.js +2 -2
  156. package/build/components/list-view/index.js.map +1 -1
  157. package/build/components/list-view/leaf.js +2 -2
  158. package/build/components/list-view/leaf.js.map +1 -1
  159. package/build/components/media-placeholder/index.js +4 -4
  160. package/build/components/media-placeholder/index.js.map +1 -1
  161. package/build/components/media-replace-flow/index.js +2 -2
  162. package/build/components/media-replace-flow/index.js.map +1 -1
  163. package/build/components/plain-text/index.js +2 -2
  164. package/build/components/plain-text/index.js.map +1 -1
  165. package/build/components/provider/use-block-sync.js +18 -0
  166. package/build/components/provider/use-block-sync.js.map +1 -1
  167. package/build/components/responsive-block-control/index.js +2 -2
  168. package/build/components/responsive-block-control/index.js.map +1 -1
  169. package/build/components/rich-text/event-listeners/enter.js +33 -42
  170. package/build/components/rich-text/event-listeners/enter.js.map +1 -1
  171. package/build/components/rich-text/event-listeners/paste-handler.js +22 -42
  172. package/build/components/rich-text/event-listeners/paste-handler.js.map +1 -1
  173. package/build/components/rich-text/format-toolbar/index.js +2 -2
  174. package/build/components/rich-text/format-toolbar/index.js.map +1 -1
  175. package/build/components/rich-text/index.js +9 -2
  176. package/build/components/rich-text/index.js.map +1 -1
  177. package/build/components/rich-text/index.native.js +2 -2
  178. package/build/components/rich-text/index.native.js.map +1 -1
  179. package/build/components/rich-text/multiline.js +30 -2
  180. package/build/components/rich-text/multiline.js.map +1 -1
  181. package/build/components/segmented-text-control/index.js +2 -2
  182. package/build/components/segmented-text-control/index.js.map +1 -1
  183. package/build/components/text-alignment-control/index.js +2 -2
  184. package/build/components/text-alignment-control/index.js.map +1 -1
  185. package/build/components/text-decoration-control/index.js +2 -2
  186. package/build/components/text-decoration-control/index.js.map +1 -1
  187. package/build/components/text-transform-control/index.js +2 -2
  188. package/build/components/text-transform-control/index.js.map +1 -1
  189. package/build/components/url-input/index.js +4 -4
  190. package/build/components/url-input/index.js.map +1 -1
  191. package/build/components/url-popover/link-editor.js +2 -2
  192. package/build/components/url-popover/link-editor.js.map +1 -1
  193. package/build/components/url-popover/link-viewer-url.js +2 -2
  194. package/build/components/url-popover/link-viewer-url.js.map +1 -1
  195. package/build/components/url-popover/link-viewer.js +2 -2
  196. package/build/components/url-popover/link-viewer.js.map +1 -1
  197. package/build/components/warning/index.js +2 -2
  198. package/build/components/warning/index.js.map +1 -1
  199. package/build/components/writing-flow/index.js +2 -2
  200. package/build/components/writing-flow/index.js.map +1 -1
  201. package/build/components/writing-flow/use-clipboard-handler.js +77 -30
  202. package/build/components/writing-flow/use-clipboard-handler.js.map +1 -1
  203. package/build/components/writing-flow/use-input.js +44 -2
  204. package/build/components/writing-flow/use-input.js.map +1 -1
  205. package/build/components/writing-flow/use-tab-nav.js +6 -1
  206. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  207. package/build/components/writing-mode-control/index.js +2 -2
  208. package/build/components/writing-mode-control/index.js.map +1 -1
  209. package/build/hooks/align.js +2 -2
  210. package/build/hooks/align.js.map +1 -1
  211. package/build/hooks/background.js +1 -1
  212. package/build/hooks/background.js.map +1 -1
  213. package/build/hooks/border.js +3 -3
  214. package/build/hooks/border.js.map +1 -1
  215. package/build/hooks/color.js +3 -3
  216. package/build/hooks/color.js.map +1 -1
  217. package/build/hooks/content-lock-ui.js +5 -28
  218. package/build/hooks/content-lock-ui.js.map +1 -1
  219. package/build/hooks/custom-class-name.js +2 -2
  220. package/build/hooks/custom-class-name.js.map +1 -1
  221. package/build/hooks/custom-class-name.native.js +2 -2
  222. package/build/hooks/custom-class-name.native.js.map +1 -1
  223. package/build/hooks/dimensions.js +2 -2
  224. package/build/hooks/dimensions.js.map +1 -1
  225. package/build/hooks/layout-child.js +16 -8
  226. package/build/hooks/layout-child.js.map +1 -1
  227. package/build/hooks/layout.js +2 -2
  228. package/build/hooks/layout.js.map +1 -1
  229. package/build/hooks/position.js +2 -2
  230. package/build/hooks/position.js.map +1 -1
  231. package/build/hooks/text-align.js +3 -3
  232. package/build/hooks/text-align.js.map +1 -1
  233. package/build/hooks/use-bindings-attributes.js +39 -13
  234. package/build/hooks/use-bindings-attributes.js.map +1 -1
  235. package/build/hooks/use-color-props.js +2 -2
  236. package/build/hooks/use-color-props.js.map +1 -1
  237. package/build/hooks/use-typography-props.js +2 -2
  238. package/build/hooks/use-typography-props.js.map +1 -1
  239. package/build/hooks/utils.js +2 -2
  240. package/build/hooks/utils.js.map +1 -1
  241. package/build/layouts/grid.js +7 -6
  242. package/build/layouts/grid.js.map +1 -1
  243. package/build/private-apis.js +4 -1
  244. package/build/private-apis.js.map +1 -1
  245. package/build/store/actions.js +134 -40
  246. package/build/store/actions.js.map +1 -1
  247. package/build/store/private-actions.js +26 -1
  248. package/build/store/private-actions.js.map +1 -1
  249. package/build/store/private-keys.js +2 -1
  250. package/build/store/private-keys.js.map +1 -1
  251. package/build/store/private-selectors.js +6 -0
  252. package/build/store/private-selectors.js.map +1 -1
  253. package/build/store/selectors.js +4 -1
  254. package/build/store/selectors.js.map +1 -1
  255. package/build/utils/selection.js +8 -0
  256. package/build/utils/selection.js.map +1 -1
  257. package/build/utils/transform-styles/index.js +12 -7
  258. package/build/utils/transform-styles/index.js.map +1 -1
  259. package/build-module/components/block-actions/index.js +4 -2
  260. package/build-module/components/block-actions/index.js.map +1 -1
  261. package/build-module/components/block-alignment-control/ui.js +2 -2
  262. package/build-module/components/block-alignment-control/ui.js.map +1 -1
  263. package/build-module/components/block-card/index.js +2 -2
  264. package/build-module/components/block-card/index.js.map +1 -1
  265. package/build-module/components/block-compare/index.js +2 -2
  266. package/build-module/components/block-compare/index.js.map +1 -1
  267. package/build-module/components/block-edit/edit.js +2 -2
  268. package/build-module/components/block-edit/edit.js.map +1 -1
  269. package/build-module/components/block-icon/index.js +2 -2
  270. package/build-module/components/block-icon/index.js.map +1 -1
  271. package/build-module/components/block-inspector/index.js +1 -1
  272. package/build-module/components/block-inspector/index.js.map +1 -1
  273. package/build-module/components/block-list/block.js +4 -4
  274. package/build-module/components/block-list/block.js.map +1 -1
  275. package/build-module/components/block-list/block.native.js +2 -2
  276. package/build-module/components/block-list/block.native.js.map +1 -1
  277. package/build-module/components/block-list/index.js +2 -2
  278. package/build-module/components/block-list/index.js.map +1 -1
  279. package/build-module/components/block-list/use-block-props/index.js +5 -2
  280. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  281. package/build-module/components/block-list/use-block-props/use-scroll-into-view.js +37 -0
  282. package/build-module/components/block-list/use-block-props/use-scroll-into-view.js.map +1 -0
  283. package/build-module/components/block-list-appender/index.js +2 -2
  284. package/build-module/components/block-list-appender/index.js.map +1 -1
  285. package/build-module/components/block-mover/button.js +2 -2
  286. package/build-module/components/block-mover/button.js.map +1 -1
  287. package/build-module/components/block-mover/index.js +2 -2
  288. package/build-module/components/block-mover/index.js.map +1 -1
  289. package/build-module/components/block-patterns-list/index.js +27 -6
  290. package/build-module/components/block-patterns-list/index.js.map +1 -1
  291. package/build-module/components/block-popover/cover.js +9 -5
  292. package/build-module/components/block-popover/cover.js.map +1 -1
  293. package/build-module/components/block-popover/inbetween.js +2 -2
  294. package/build-module/components/block-popover/inbetween.js.map +1 -1
  295. package/build-module/components/block-popover/index.js +21 -3
  296. package/build-module/components/block-popover/index.js.map +1 -1
  297. package/build-module/components/block-preview/index.js +2 -2
  298. package/build-module/components/block-preview/index.js.map +1 -1
  299. package/build-module/components/block-settings-menu/block-settings-dropdown.js +8 -5
  300. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  301. package/build-module/components/block-settings-menu-controls/index.js +10 -7
  302. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  303. package/build-module/components/block-styles/index.js +2 -2
  304. package/build-module/components/block-styles/index.js.map +1 -1
  305. package/build-module/components/block-toolbar/index.js +3 -3
  306. package/build-module/components/block-toolbar/index.js.map +1 -1
  307. package/build-module/components/block-tools/block-selection-button.js +2 -2
  308. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  309. package/build-module/components/block-tools/block-toolbar-breadcrumb.js +4 -4
  310. package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
  311. package/build-module/components/block-tools/block-toolbar-popover.js +2 -2
  312. package/build-module/components/block-tools/block-toolbar-popover.js.map +1 -1
  313. package/build-module/components/block-tools/empty-block-inserter.js +2 -2
  314. package/build-module/components/block-tools/empty-block-inserter.js.map +1 -1
  315. package/build-module/components/block-tools/index.js +20 -1
  316. package/build-module/components/block-tools/index.js.map +1 -1
  317. package/build-module/components/block-tools/insertion-point.js +4 -4
  318. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  319. package/build-module/components/block-tools/zoom-out-mode-inserters.js +67 -23
  320. package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  321. package/build-module/components/block-variation-picker/index.js +2 -2
  322. package/build-module/components/block-variation-picker/index.js.map +1 -1
  323. package/build-module/components/button-block-appender/index.js +2 -2
  324. package/build-module/components/button-block-appender/index.js.map +1 -1
  325. package/build-module/components/child-layout-control/index.js +2 -2
  326. package/build-module/components/child-layout-control/index.js.map +1 -1
  327. package/build-module/components/colors-gradients/control.js +3 -3
  328. package/build-module/components/colors-gradients/control.js.map +1 -1
  329. package/build-module/components/colors-gradients/dropdown.js +2 -2
  330. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  331. package/build-module/components/colors-gradients/panel-color-gradient-settings.js +2 -2
  332. package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  333. package/build-module/components/convert-to-group-buttons/index.js +7 -1
  334. package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
  335. package/build-module/components/default-block-appender/index.js +2 -2
  336. package/build-module/components/default-block-appender/index.js.map +1 -1
  337. package/build-module/components/dimensions-tool/aspect-ratio-tool.js +30 -36
  338. package/build-module/components/dimensions-tool/aspect-ratio-tool.js.map +1 -1
  339. package/build-module/components/global-styles/background-panel.js +3 -3
  340. package/build-module/components/global-styles/background-panel.js.map +1 -1
  341. package/build-module/components/global-styles/color-panel.js +3 -3
  342. package/build-module/components/global-styles/color-panel.js.map +1 -1
  343. package/build-module/components/global-styles/dimensions-panel.js +4 -4
  344. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  345. package/build-module/components/global-styles/filters-panel.js +2 -2
  346. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  347. package/build-module/components/global-styles/shadow-panel-components.js +4 -4
  348. package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
  349. package/build-module/components/global-styles/use-global-styles-output.js +1 -1
  350. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  351. package/build-module/components/grid-visualizer/grid-item-resizer.js +141 -24
  352. package/build-module/components/grid-visualizer/grid-item-resizer.js.map +1 -1
  353. package/build-module/components/grid-visualizer/grid-visualizer.js +12 -6
  354. package/build-module/components/grid-visualizer/grid-visualizer.js.map +1 -1
  355. package/build-module/components/iframe/index.js +70 -31
  356. package/build-module/components/iframe/index.js.map +1 -1
  357. package/build-module/components/image-editor/aspect-ratio-dropdown.js +52 -36
  358. package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  359. package/build-module/components/image-editor/cropper.js +2 -2
  360. package/build-module/components/image-editor/cropper.js.map +1 -1
  361. package/build-module/components/image-editor/index.js +1 -1
  362. package/build-module/components/image-editor/index.js.map +1 -1
  363. package/build-module/components/index.js +1 -0
  364. package/build-module/components/index.js.map +1 -1
  365. package/build-module/components/inner-blocks/button-block-appender.js +2 -2
  366. package/build-module/components/inner-blocks/button-block-appender.js.map +1 -1
  367. package/build-module/components/inner-blocks/index.js +22 -21
  368. package/build-module/components/inner-blocks/index.js.map +1 -1
  369. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +1 -1
  370. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  371. package/build-module/components/inserter/block-patterns-tab/index.js +10 -1
  372. package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
  373. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +1 -1
  374. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  375. package/build-module/components/inserter/block-types-tab.js +6 -4
  376. package/build-module/components/inserter/block-types-tab.js.map +1 -1
  377. package/build-module/components/inserter/hooks/use-insertion-point.js +11 -2
  378. package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
  379. package/build-module/components/inserter/hooks/use-patterns-state.js +12 -5
  380. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  381. package/build-module/components/inserter/index.js +2 -2
  382. package/build-module/components/inserter/index.js.map +1 -1
  383. package/build-module/components/inserter/library.js +8 -2
  384. package/build-module/components/inserter/library.js.map +1 -1
  385. package/build-module/components/inserter/media-tab/media-preview.js +2 -2
  386. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
  387. package/build-module/components/inserter/menu.js +72 -56
  388. package/build-module/components/inserter/menu.js.map +1 -1
  389. package/build-module/components/inserter/quick-inserter.js +2 -2
  390. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  391. package/build-module/components/inserter/tabs.js +18 -6
  392. package/build-module/components/inserter/tabs.js.map +1 -1
  393. package/build-module/components/inserter-list-item/index.js +3 -3
  394. package/build-module/components/inserter-list-item/index.js.map +1 -1
  395. package/build-module/components/keyboard-shortcuts/index.js +9 -0
  396. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  397. package/build-module/components/link-control/index.js +2 -2
  398. package/build-module/components/link-control/index.js.map +1 -1
  399. package/build-module/components/link-control/link-preview.js +3 -3
  400. package/build-module/components/link-control/link-preview.js.map +1 -1
  401. package/build-module/components/link-control/search-results.js +2 -2
  402. package/build-module/components/link-control/search-results.js.map +1 -1
  403. package/build-module/components/list-view/block-contents.js +2 -2
  404. package/build-module/components/list-view/block-contents.js.map +1 -1
  405. package/build-module/components/list-view/block-select-button.js +11 -3
  406. package/build-module/components/list-view/block-select-button.js.map +1 -1
  407. package/build-module/components/list-view/block.js +36 -13
  408. package/build-module/components/list-view/block.js.map +1 -1
  409. package/build-module/components/list-view/drop-indicator.js +3 -3
  410. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  411. package/build-module/components/list-view/index.js +2 -2
  412. package/build-module/components/list-view/index.js.map +1 -1
  413. package/build-module/components/list-view/leaf.js +2 -2
  414. package/build-module/components/list-view/leaf.js.map +1 -1
  415. package/build-module/components/media-placeholder/index.js +4 -4
  416. package/build-module/components/media-placeholder/index.js.map +1 -1
  417. package/build-module/components/media-replace-flow/index.js +2 -2
  418. package/build-module/components/media-replace-flow/index.js.map +1 -1
  419. package/build-module/components/plain-text/index.js +2 -2
  420. package/build-module/components/plain-text/index.js.map +1 -1
  421. package/build-module/components/provider/use-block-sync.js +19 -1
  422. package/build-module/components/provider/use-block-sync.js.map +1 -1
  423. package/build-module/components/responsive-block-control/index.js +2 -2
  424. package/build-module/components/responsive-block-control/index.js.map +1 -1
  425. package/build-module/components/rich-text/event-listeners/enter.js +33 -43
  426. package/build-module/components/rich-text/event-listeners/enter.js.map +1 -1
  427. package/build-module/components/rich-text/event-listeners/paste-handler.js +23 -43
  428. package/build-module/components/rich-text/event-listeners/paste-handler.js.map +1 -1
  429. package/build-module/components/rich-text/format-toolbar/index.js +2 -2
  430. package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
  431. package/build-module/components/rich-text/index.js +9 -2
  432. package/build-module/components/rich-text/index.js.map +1 -1
  433. package/build-module/components/rich-text/index.native.js +2 -2
  434. package/build-module/components/rich-text/index.native.js.map +1 -1
  435. package/build-module/components/rich-text/multiline.js +31 -3
  436. package/build-module/components/rich-text/multiline.js.map +1 -1
  437. package/build-module/components/segmented-text-control/index.js +2 -2
  438. package/build-module/components/segmented-text-control/index.js.map +1 -1
  439. package/build-module/components/text-alignment-control/index.js +2 -2
  440. package/build-module/components/text-alignment-control/index.js.map +1 -1
  441. package/build-module/components/text-decoration-control/index.js +2 -2
  442. package/build-module/components/text-decoration-control/index.js.map +1 -1
  443. package/build-module/components/text-transform-control/index.js +2 -2
  444. package/build-module/components/text-transform-control/index.js.map +1 -1
  445. package/build-module/components/url-input/index.js +4 -4
  446. package/build-module/components/url-input/index.js.map +1 -1
  447. package/build-module/components/url-popover/link-editor.js +2 -2
  448. package/build-module/components/url-popover/link-editor.js.map +1 -1
  449. package/build-module/components/url-popover/link-viewer-url.js +2 -2
  450. package/build-module/components/url-popover/link-viewer-url.js.map +1 -1
  451. package/build-module/components/url-popover/link-viewer.js +2 -2
  452. package/build-module/components/url-popover/link-viewer.js.map +1 -1
  453. package/build-module/components/warning/index.js +2 -2
  454. package/build-module/components/warning/index.js.map +1 -1
  455. package/build-module/components/writing-flow/index.js +2 -2
  456. package/build-module/components/writing-flow/index.js.map +1 -1
  457. package/build-module/components/writing-flow/use-clipboard-handler.js +78 -31
  458. package/build-module/components/writing-flow/use-clipboard-handler.js.map +1 -1
  459. package/build-module/components/writing-flow/use-input.js +45 -3
  460. package/build-module/components/writing-flow/use-input.js.map +1 -1
  461. package/build-module/components/writing-flow/use-tab-nav.js +6 -1
  462. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  463. package/build-module/components/writing-mode-control/index.js +2 -2
  464. package/build-module/components/writing-mode-control/index.js.map +1 -1
  465. package/build-module/hooks/align.js +2 -2
  466. package/build-module/hooks/align.js.map +1 -1
  467. package/build-module/hooks/background.js +1 -1
  468. package/build-module/hooks/background.js.map +1 -1
  469. package/build-module/hooks/border.js +3 -3
  470. package/build-module/hooks/border.js.map +1 -1
  471. package/build-module/hooks/color.js +3 -3
  472. package/build-module/hooks/color.js.map +1 -1
  473. package/build-module/hooks/content-lock-ui.js +5 -28
  474. package/build-module/hooks/content-lock-ui.js.map +1 -1
  475. package/build-module/hooks/custom-class-name.js +2 -2
  476. package/build-module/hooks/custom-class-name.js.map +1 -1
  477. package/build-module/hooks/custom-class-name.native.js +2 -2
  478. package/build-module/hooks/custom-class-name.native.js.map +1 -1
  479. package/build-module/hooks/dimensions.js +2 -2
  480. package/build-module/hooks/dimensions.js.map +1 -1
  481. package/build-module/hooks/layout-child.js +16 -8
  482. package/build-module/hooks/layout-child.js.map +1 -1
  483. package/build-module/hooks/layout.js +2 -2
  484. package/build-module/hooks/layout.js.map +1 -1
  485. package/build-module/hooks/position.js +2 -2
  486. package/build-module/hooks/position.js.map +1 -1
  487. package/build-module/hooks/text-align.js +3 -3
  488. package/build-module/hooks/text-align.js.map +1 -1
  489. package/build-module/hooks/use-bindings-attributes.js +39 -13
  490. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  491. package/build-module/hooks/use-color-props.js +2 -2
  492. package/build-module/hooks/use-color-props.js.map +1 -1
  493. package/build-module/hooks/use-typography-props.js +2 -2
  494. package/build-module/hooks/use-typography-props.js.map +1 -1
  495. package/build-module/hooks/utils.js +2 -2
  496. package/build-module/hooks/utils.js.map +1 -1
  497. package/build-module/layouts/grid.js +7 -6
  498. package/build-module/layouts/grid.js.map +1 -1
  499. package/build-module/private-apis.js +5 -2
  500. package/build-module/private-apis.js.map +1 -1
  501. package/build-module/store/actions.js +136 -42
  502. package/build-module/store/actions.js.map +1 -1
  503. package/build-module/store/private-actions.js +24 -0
  504. package/build-module/store/private-actions.js.map +1 -1
  505. package/build-module/store/private-keys.js +1 -0
  506. package/build-module/store/private-keys.js.map +1 -1
  507. package/build-module/store/private-selectors.js +5 -0
  508. package/build-module/store/private-selectors.js.map +1 -1
  509. package/build-module/store/selectors.js +4 -1
  510. package/build-module/store/selectors.js.map +1 -1
  511. package/build-module/utils/selection.js +7 -0
  512. package/build-module/utils/selection.js.map +1 -1
  513. package/build-module/utils/transform-styles/index.js +12 -7
  514. package/build-module/utils/transform-styles/index.js.map +1 -1
  515. package/build-style/content-rtl.css +89 -96
  516. package/build-style/content.css +89 -96
  517. package/build-style/style-rtl.css +14 -4
  518. package/build-style/style.css +14 -4
  519. package/build-types/components/block-context/index.d.ts +1 -1
  520. package/build-types/components/block-context/index.d.ts.map +1 -1
  521. package/package.json +32 -32
  522. package/src/components/block-actions/index.js +5 -1
  523. package/src/components/block-alignment-control/ui.js +2 -2
  524. package/src/components/block-card/index.js +2 -2
  525. package/src/components/block-compare/index.js +2 -2
  526. package/src/components/block-content-overlay/content.scss +4 -37
  527. package/src/components/block-draggable/test/helpers.native.js +8 -8
  528. package/src/components/block-edit/edit.js +2 -2
  529. package/src/components/block-icon/index.js +2 -2
  530. package/src/components/block-inspector/index.js +2 -1
  531. package/src/components/block-list/block.js +4 -4
  532. package/src/components/block-list/block.native.js +2 -2
  533. package/src/components/block-list/content.scss +46 -73
  534. package/src/components/block-list/index.js +2 -2
  535. package/src/components/block-list/use-block-props/index.js +4 -2
  536. package/src/components/block-list/use-block-props/use-scroll-into-view.js +38 -0
  537. package/src/components/block-list-appender/index.js +2 -2
  538. package/src/components/block-mover/button.js +2 -2
  539. package/src/components/block-mover/index.js +2 -2
  540. package/src/components/block-patterns-list/index.js +29 -4
  541. package/src/components/block-popover/README.md +1 -1
  542. package/src/components/block-popover/cover.js +22 -7
  543. package/src/components/block-popover/inbetween.js +2 -2
  544. package/src/components/block-popover/index.js +24 -6
  545. package/src/components/block-preview/index.js +2 -2
  546. package/src/components/block-settings-menu/block-settings-dropdown.js +14 -6
  547. package/src/components/block-settings-menu-controls/index.js +25 -16
  548. package/src/components/block-styles/index.js +2 -2
  549. package/src/components/block-toolbar/index.js +3 -3
  550. package/src/components/block-tools/block-selection-button.js +2 -2
  551. package/src/components/block-tools/block-toolbar-breadcrumb.js +5 -5
  552. package/src/components/block-tools/block-toolbar-popover.js +4 -7
  553. package/src/components/block-tools/empty-block-inserter.js +2 -2
  554. package/src/components/block-tools/index.js +24 -3
  555. package/src/components/block-tools/insertion-point.js +4 -4
  556. package/src/components/block-tools/style.scss +8 -0
  557. package/src/components/block-tools/zoom-out-mode-inserters.js +73 -21
  558. package/src/components/block-variation-picker/index.js +2 -2
  559. package/src/components/button-block-appender/index.js +2 -2
  560. package/src/components/child-layout-control/index.js +14 -2
  561. package/src/components/colors-gradients/control.js +3 -3
  562. package/src/components/colors-gradients/dropdown.js +2 -2
  563. package/src/components/colors-gradients/panel-color-gradient-settings.js +2 -2
  564. package/src/components/colors-gradients/test/control.js +3 -3
  565. package/src/components/convert-to-group-buttons/index.js +10 -1
  566. package/src/components/default-block-appender/index.js +2 -2
  567. package/src/components/dimensions-tool/aspect-ratio-tool.js +40 -67
  568. package/src/components/dimensions-tool/test/index.js +10 -0
  569. package/src/components/editable-text/README.md +0 -4
  570. package/src/components/global-styles/background-panel.js +3 -3
  571. package/src/components/global-styles/color-panel.js +3 -3
  572. package/src/components/global-styles/dimensions-panel.js +4 -4
  573. package/src/components/global-styles/filters-panel.js +2 -2
  574. package/src/components/global-styles/shadow-panel-components.js +6 -9
  575. package/src/components/global-styles/test/get-global-styles-changes.js +0 -2
  576. package/src/components/global-styles/test/use-global-styles-output.js +5 -5
  577. package/src/components/global-styles/use-global-styles-output.js +1 -1
  578. package/src/components/grid-visualizer/grid-item-resizer.js +169 -40
  579. package/src/components/grid-visualizer/grid-visualizer.js +19 -6
  580. package/src/components/iframe/content.scss +63 -0
  581. package/src/components/iframe/index.js +119 -39
  582. package/src/components/image-editor/aspect-ratio-dropdown.js +91 -59
  583. package/src/components/image-editor/cropper.js +2 -2
  584. package/src/components/image-editor/index.js +1 -1
  585. package/src/components/image-editor/test/index.js +22 -0
  586. package/src/components/index.js +1 -0
  587. package/src/components/inner-blocks/button-block-appender.js +2 -2
  588. package/src/components/inner-blocks/index.js +19 -17
  589. package/src/components/inserter/block-patterns-explorer/pattern-list.js +2 -1
  590. package/src/components/inserter/block-patterns-tab/index.js +17 -1
  591. package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +2 -1
  592. package/src/components/inserter/block-types-tab.js +7 -9
  593. package/src/components/inserter/hooks/use-insertion-point.js +15 -1
  594. package/src/components/inserter/hooks/use-patterns-state.js +18 -5
  595. package/src/components/inserter/index.js +4 -5
  596. package/src/components/inserter/library.js +6 -0
  597. package/src/components/inserter/media-tab/media-preview.js +2 -2
  598. package/src/components/inserter/menu.js +113 -107
  599. package/src/components/inserter/quick-inserter.js +2 -2
  600. package/src/components/inserter/style.scss +6 -8
  601. package/src/components/inserter/tabs.js +29 -15
  602. package/src/components/inserter-list-item/index.js +3 -3
  603. package/src/components/keyboard-shortcuts/index.js +12 -0
  604. package/src/components/line-height-control/test/index.js +16 -14
  605. package/src/components/link-control/index.js +2 -2
  606. package/src/components/link-control/link-preview.js +3 -3
  607. package/src/components/link-control/search-results.js +2 -2
  608. package/src/components/list-view/block-contents.js +2 -2
  609. package/src/components/list-view/block-select-button.js +14 -3
  610. package/src/components/list-view/block.js +54 -30
  611. package/src/components/list-view/drop-indicator.js +3 -3
  612. package/src/components/list-view/index.js +2 -2
  613. package/src/components/list-view/leaf.js +2 -5
  614. package/src/components/media-placeholder/index.js +4 -4
  615. package/src/components/media-replace-flow/index.js +2 -2
  616. package/src/components/plain-text/index.js +2 -2
  617. package/src/components/provider/use-block-sync.js +27 -1
  618. package/src/components/responsive-block-control/index.js +2 -2
  619. package/src/components/rich-text/README.md +0 -8
  620. package/src/components/rich-text/event-listeners/enter.js +28 -48
  621. package/src/components/rich-text/event-listeners/paste-handler.js +21 -58
  622. package/src/components/rich-text/format-toolbar/index.js +2 -2
  623. package/src/components/rich-text/index.js +10 -3
  624. package/src/components/rich-text/index.native.js +2 -2
  625. package/src/components/rich-text/multiline.js +31 -3
  626. package/src/components/segmented-text-control/index.js +2 -2
  627. package/src/components/text-alignment-control/index.js +2 -2
  628. package/src/components/text-decoration-control/index.js +2 -2
  629. package/src/components/text-transform-control/index.js +2 -2
  630. package/src/components/url-input/index.js +4 -4
  631. package/src/components/url-popover/link-editor.js +2 -2
  632. package/src/components/url-popover/link-viewer-url.js +2 -2
  633. package/src/components/url-popover/link-viewer.js +2 -2
  634. package/src/components/warning/index.js +2 -2
  635. package/src/components/writing-flow/index.js +2 -2
  636. package/src/components/writing-flow/use-clipboard-handler.js +107 -47
  637. package/src/components/writing-flow/use-input.js +75 -1
  638. package/src/components/writing-flow/use-tab-nav.js +10 -1
  639. package/src/components/writing-mode-control/index.js +2 -5
  640. package/src/content.scss +1 -0
  641. package/src/hooks/align.js +2 -2
  642. package/src/hooks/background.js +1 -1
  643. package/src/hooks/border.js +3 -3
  644. package/src/hooks/color.js +12 -19
  645. package/src/hooks/color.scss +1 -0
  646. package/src/hooks/content-lock-ui.js +16 -33
  647. package/src/hooks/custom-class-name.js +2 -2
  648. package/src/hooks/custom-class-name.native.js +2 -2
  649. package/src/hooks/dimensions.js +2 -2
  650. package/src/hooks/layout-child.js +34 -20
  651. package/src/hooks/layout.js +2 -2
  652. package/src/hooks/position.js +2 -2
  653. package/src/hooks/text-align.js +3 -3
  654. package/src/hooks/use-bindings-attributes.js +48 -16
  655. package/src/hooks/use-color-props.js +2 -2
  656. package/src/hooks/use-typography-props.js +2 -2
  657. package/src/hooks/utils.js +2 -2
  658. package/src/layouts/grid.js +3 -7
  659. package/src/private-apis.js +4 -0
  660. package/src/store/actions.js +225 -70
  661. package/src/store/private-actions.js +24 -0
  662. package/src/store/private-keys.js +1 -0
  663. package/src/store/private-selectors.js +15 -0
  664. package/src/store/selectors.js +4 -2
  665. package/src/utils/selection.js +8 -0
  666. package/src/utils/test/__snapshots__/transform-styles.js.snap +6 -0
  667. package/src/utils/test/transform-styles.js +14 -0
  668. package/src/utils/transform-styles/index.js +12 -9
  669. package/tsconfig.tsbuildinfo +1 -1
  670. package/build/components/rich-text/split-value.js +0 -81
  671. package/build/components/rich-text/split-value.js.map +0 -1
  672. package/build-module/components/rich-text/split-value.js +0 -75
  673. package/build-module/components/rich-text/split-value.js.map +0 -1
  674. package/src/components/rich-text/split-value.js +0 -64
@@ -4,7 +4,7 @@
4
4
  import { useSelect, useDispatch } from '@wordpress/data';
5
5
  import { useRefEffect } from '@wordpress/compose';
6
6
  import { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';
7
- import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
7
+ import { createBlock, getDefaultBlockName, hasBlockSupport, getBlockTransforms, findTransform } from '@wordpress/blocks';
8
8
 
9
9
  /**
10
10
  * Internal dependencies
@@ -18,15 +18,23 @@ export default function useInput() {
18
18
  const {
19
19
  __unstableIsFullySelected,
20
20
  getSelectedBlockClientIds,
21
+ getSelectedBlockClientId,
21
22
  __unstableIsSelectionMergeable,
22
- hasMultiSelection
23
+ hasMultiSelection,
24
+ getBlockName,
25
+ canInsertBlockType,
26
+ getBlockRootClientId,
27
+ getSelectionStart,
28
+ getSelectionEnd,
29
+ getBlockAttributes
23
30
  } = useSelect(blockEditorStore);
24
31
  const {
25
32
  replaceBlocks,
26
33
  __unstableSplitSelection,
27
34
  removeBlocks,
28
35
  __unstableDeleteSelection,
29
- __unstableExpandSelection
36
+ __unstableExpandSelection,
37
+ __unstableMarkAutomaticChange
30
38
  } = useDispatch(blockEditorStore);
31
39
  return useRefEffect(node => {
32
40
  function onBeforeInput(event) {
@@ -42,6 +50,40 @@ export default function useInput() {
42
50
  return;
43
51
  }
44
52
  if (!hasMultiSelection()) {
53
+ if (event.keyCode === ENTER) {
54
+ if (event.shiftKey || __unstableIsFullySelected()) {
55
+ return;
56
+ }
57
+ const clientId = getSelectedBlockClientId();
58
+ const blockName = getBlockName(clientId);
59
+ const selectionStart = getSelectionStart();
60
+ const selectionEnd = getSelectionEnd();
61
+ if (selectionStart.attributeKey === selectionEnd.attributeKey) {
62
+ const selectedAttributeValue = getBlockAttributes(clientId)[selectionStart.attributeKey];
63
+ const transforms = getBlockTransforms('from').filter(({
64
+ type
65
+ }) => type === 'enter');
66
+ const transformation = findTransform(transforms, item => {
67
+ return item.regExp.test(selectedAttributeValue);
68
+ });
69
+ if (transformation) {
70
+ replaceBlocks(clientId, transformation.transform({
71
+ content: selectedAttributeValue
72
+ }));
73
+ __unstableMarkAutomaticChange();
74
+ return;
75
+ }
76
+ }
77
+ if (!hasBlockSupport(blockName, 'splitting', false) && !event.__deprecatedOnSplit) {
78
+ return;
79
+ }
80
+
81
+ // Ensure template is not locked.
82
+ if (canInsertBlockType(blockName, getBlockRootClientId(clientId))) {
83
+ __unstableSplitSelection();
84
+ event.preventDefault();
85
+ }
86
+ }
45
87
  return;
46
88
  }
47
89
  if (event.keyCode === ENTER) {
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","useDispatch","useRefEffect","ENTER","BACKSPACE","DELETE","createBlock","getDefaultBlockName","store","blockEditorStore","useInput","__unstableIsFullySelected","getSelectedBlockClientIds","__unstableIsSelectionMergeable","hasMultiSelection","replaceBlocks","__unstableSplitSelection","removeBlocks","__unstableDeleteSelection","__unstableExpandSelection","node","onBeforeInput","event","contentEditable","preventDefault","onKeyDown","defaultPrevented","keyCode","key","length","metaKey","ctrlKey","ownerDocument","defaultView","getSelection","removeAllRanges","onCompositionStart","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-input.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Handles input for selections across blocks.\n */\nexport default function useInput() {\n\tconst {\n\t\t__unstableIsFullySelected,\n\t\tgetSelectedBlockClientIds,\n\t\t__unstableIsSelectionMergeable,\n\t\thasMultiSelection,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\treplaceBlocks,\n\t\t__unstableSplitSelection,\n\t\tremoveBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t} = useDispatch( blockEditorStore );\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onBeforeInput( event ) {\n\t\t\t// If writing flow is editable, NEVER allow the browser to alter the\n\t\t\t// DOM. This will cause React errors (and the DOM should only be\n\t\t\t// altered in a controlled fashion).\n\t\t\tif ( node.contentEditable === 'true' ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\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 ( ! hasMultiSelection() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\tgetSelectedBlockClientIds(),\n\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tevent.keyCode === BACKSPACE ||\n\t\t\t\tevent.keyCode === DELETE\n\t\t\t) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\tremoveBlocks( getSelectedBlockClientIds() );\n\t\t\t\t} else if ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\t// If key.length is longer than 1, it's a control key that doesn't\n\t\t\t\t// input anything.\n\t\t\t\tevent.key.length === 1 &&\n\t\t\t\t! ( event.metaKey || event.ctrlKey )\n\t\t\t) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\t\tnode.ownerDocument.defaultView\n\t\t\t\t\t\t.getSelection()\n\t\t\t\t\t\t.removeAllRanges();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction onCompositionStart( event ) {\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tnode.contentEditable = false;\n\n\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t__unstableDeleteSelection();\n\t\t\t} else {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\tnode.ownerDocument.defaultView.getSelection().removeAllRanges();\n\t\t\t}\n\t\t}\n\n\t\tnode.addEventListener( 'beforeinput', onBeforeInput );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'compositionstart', onCompositionStart );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'beforeinput', onBeforeInput );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'compositionstart', onCompositionStart );\n\t\t};\n\t}, [] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,KAAK,EAAEC,SAAS,EAAEC,MAAM,QAAQ,qBAAqB;AAC9D,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,mBAAmB;;AAEpE;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ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B,aAAc,CAAC;MACxDD,IAAI,CAACkB,mBAAmB,CAAE,SAAS,EAAEb,SAAU,CAAC;MAChDL,IAAI,CAACkB,mBAAmB,CAAE,kBAAkB,EAAEF,kBAAmB,CAAC;IACnE,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","useDispatch","useRefEffect","ENTER","BACKSPACE","DELETE","createBlock","getDefaultBlockName","hasBlockSupport","getBlockTransforms","findTransform","store","blockEditorStore","useInput","__unstableIsFullySelected","getSelectedBlockClientIds","getSelectedBlockClientId","__unstableIsSelectionMergeable","hasMultiSelection","getBlockName","canInsertBlockType","getBlockRootClientId","getSelectionStart","getSelectionEnd","getBlockAttributes","replaceBlocks","__unstableSplitSelection","removeBlocks","__unstableDeleteSelection","__unstableExpandSelection","__unstableMarkAutomaticChange","node","onBeforeInput","event","contentEditable","preventDefault","onKeyDown","defaultPrevented","keyCode","shiftKey","clientId","blockName","selectionStart","selectionEnd","attributeKey","selectedAttributeValue","transforms","filter","type","transformation","item","regExp","test","transform","content","__deprecatedOnSplit","key","length","metaKey","ctrlKey","ownerDocument","defaultView","getSelection","removeAllRanges","onCompositionStart","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-input.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport {\n\tcreateBlock,\n\tgetDefaultBlockName,\n\thasBlockSupport,\n\tgetBlockTransforms,\n\tfindTransform,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Handles input for selections across blocks.\n */\nexport default function useInput() {\n\tconst {\n\t\t__unstableIsFullySelected,\n\t\tgetSelectedBlockClientIds,\n\t\tgetSelectedBlockClientId,\n\t\t__unstableIsSelectionMergeable,\n\t\thasMultiSelection,\n\t\tgetBlockName,\n\t\tcanInsertBlockType,\n\t\tgetBlockRootClientId,\n\t\tgetSelectionStart,\n\t\tgetSelectionEnd,\n\t\tgetBlockAttributes,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\treplaceBlocks,\n\t\t__unstableSplitSelection,\n\t\tremoveBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t\t__unstableMarkAutomaticChange,\n\t} = useDispatch( blockEditorStore );\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onBeforeInput( event ) {\n\t\t\t// If writing flow is editable, NEVER allow the browser to alter the\n\t\t\t// DOM. This will cause React errors (and the DOM should only be\n\t\t\t// altered in a controlled fashion).\n\t\t\tif ( node.contentEditable === 'true' ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\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 ( ! hasMultiSelection() ) {\n\t\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\t\tif ( event.shiftKey || __unstableIsFullySelected() ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t\tconst selectionStart = getSelectionStart();\n\t\t\t\t\tconst selectionEnd = getSelectionEnd();\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectionStart.attributeKey ===\n\t\t\t\t\t\tselectionEnd.attributeKey\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst selectedAttributeValue =\n\t\t\t\t\t\t\tgetBlockAttributes( clientId )[\n\t\t\t\t\t\t\t\tselectionStart.attributeKey\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\tconst transforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t\t\t\t( { type } ) => type === 'enter'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\t\t\ttransforms,\n\t\t\t\t\t\t\t( item ) => {\n\t\t\t\t\t\t\t\treturn item.regExp.test(\n\t\t\t\t\t\t\t\t\tselectedAttributeValue\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( transformation ) {\n\t\t\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\ttransformation.transform( {\n\t\t\t\t\t\t\t\t\tcontent: selectedAttributeValue,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t! hasBlockSupport( blockName, 'splitting', false ) &&\n\t\t\t\t\t\t! event.__deprecatedOnSplit\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Ensure template is not locked.\n\t\t\t\t\tif (\n\t\t\t\t\t\tcanInsertBlockType(\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\tgetSelectedBlockClientIds(),\n\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tevent.keyCode === BACKSPACE ||\n\t\t\t\tevent.keyCode === DELETE\n\t\t\t) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\tremoveBlocks( getSelectedBlockClientIds() );\n\t\t\t\t} else if ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\t// If key.length is longer than 1, it's a control key that doesn't\n\t\t\t\t// input anything.\n\t\t\t\tevent.key.length === 1 &&\n\t\t\t\t! ( event.metaKey || event.ctrlKey )\n\t\t\t) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\t\tnode.ownerDocument.defaultView\n\t\t\t\t\t\t.getSelection()\n\t\t\t\t\t\t.removeAllRanges();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction onCompositionStart( event ) {\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tnode.contentEditable = false;\n\n\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t__unstableDeleteSelection();\n\t\t\t} else {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\tnode.ownerDocument.defaultView.getSelection().removeAllRanges();\n\t\t\t}\n\t\t}\n\n\t\tnode.addEventListener( 'beforeinput', onBeforeInput );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'compositionstart', onCompositionStart );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'beforeinput', onBeforeInput );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'compositionstart', onCompositionStart );\n\t\t};\n\t}, [] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,KAAK,EAAEC,SAAS,EAAEC,MAAM,QAAQ,qBAAqB;AAC9D,SACCC,WAAW,EACXC,mBAAmB,EACnBC,eAAe,EACfC,kBAAkB,EAClBC,aAAa,QACP,mBAAmB;;AAE1B;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;;AAEvD;AACA;AACA;AACA,eAAe,SAASC,QAAQA,CAAA,EAAG;EAClC,MAAM;IACLC,yBAAyB;IACzBC,yBAAyB;IACzBC,wBAAwB;IACxBC,8BAA8B;IAC9BC,iBAAiB;IACjBC,YAAY;IACZC,kBAAkB;IAClBC,oBAAoB;IACpBC,iBAAiB;IACjBC,eAAe;IACfC;EACD,CAAC,GAAGxB,SAAS,CAAEY,gBAAiB,CAAC;EACjC,MAAM;IACLa,aAAa;IACbC,wBAAwB;IACxBC,YAAY;IACZC,yBAAyB;IACzBC,yBAAyB;IACzBC;EACD,CAAC,GAAG7B,WAAW,CAAEW,gBAAiB,CAAC;EAEnC,OAAOV,YAAY,CAAI6B,IAAI,IAAM;IAChC,SAASC,aAAaA,CAAEC,KAAK,EAAG;MAC/B;MACA;MACA;MACA,IAAKF,IAAI,CAACG,eAAe,KAAK,MAAM,EAAG;QACtCD,KAAK,CAACE,cAAc,CAAC,CAAC;MACvB;IACD;IAEA,SAASC,SAASA,CAAEH,KAAK,EAAG;MAC3B,IAAKA,KAAK,CAACI,gBAAgB,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AC,CAAC,CACdC,eAAe,CAAC,CAAC;QACpB;MACD;IACD;IAEA,SAASC,kBAAkBA,CAAE/B,KAAK,EAAG;MACpC,IAAK,CAAEf,iBAAiB,CAAC,CAAC,EAAG;QAC5B;MACD;MAEAa,IAAI,CAACG,eAAe,GAAG,KAAK;MAE5B,IAAKjB,8BAA8B,CAAC,CAAC,EAAG;QACvCW,yBAAyB,CAAC,CAAC;MAC5B,CAAC,MAAM;QACNK,KAAK,CAACE,cAAc,CAAC,CAAC;QACtB;QACA;QACA;QACAJ,IAAI,CAAC6B,aAAa,CAACC,WAAW,CAACC,YAAY,CAAC,CAAC,CAACC,eAAe,CAAC,CAAC;MAChE;IACD;IAEAhC,IAAI,CAACkC,gBAAgB,CAAE,aAAa,EAAEjC,aAAc,CAAC;IACrDD,IAAI,CAACkC,gBAAgB,CAAE,SAAS,EAAE7B,SAAU,CAAC;IAC7CL,IAAI,CAACkC,gBAAgB,CAAE,kBAAkB,EAAED,kBAAmB,CAAC;IAC/D,OAAO,MAAM;MACZjC,IAAI,CAACmC,mBAAmB,CAAE,aAAa,EAAElC,aAAc,CAAC;MACxDD,IAAI,CAACmC,mBAAmB,CAAE,SAAS,EAAE9B,SAAU,CAAC;MAChDL,IAAI,CAACmC,mBAAmB,CAAE,kBAAkB,EAAEF,kBAAmB,CAAC;IACnE,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
@@ -45,7 +45,12 @@ export default function useTabNav() {
45
45
  } else if (hasMultiSelection()) {
46
46
  container.current.focus();
47
47
  } else if (getSelectedBlockClientId()) {
48
- getLastFocus()?.current.focus();
48
+ if (getLastFocus()?.current) {
49
+ getLastFocus().current.focus();
50
+ } else {
51
+ // Handles when the last focus has not been set yet, or has been cleared by new blocks being added via the inserter.
52
+ container.current.querySelector(`[data-block="${getSelectedBlockClientId()}"]`).focus();
53
+ }
49
54
  } else {
50
55
  setNavigationMode(true);
51
56
  const canvasElement = container.current.ownerDocument === event.target.ownerDocument ? container.current : container.current.ownerDocument.defaultView.frameElement;
@@ -1 +1 @@
1
- {"version":3,"names":["focus","isFormElement","TAB","ESCAPE","useSelect","useDispatch","useRefEffect","useMergeRefs","useRef","store","blockEditorStore","isInSameBlock","isInsideRootBlock","unlock","useTabNav","container","focusCaptureBeforeRef","focusCaptureAfterRef","hasMultiSelection","getSelectedBlockClientId","getBlockCount","setNavigationMode","setLastFocus","isNavigationMode","select","getLastFocus","focusCaptureTabIndex","undefined","noCapture","onFocusCapture","event","current","canvasElement","ownerDocument","target","defaultView","frameElement","isBefore","compareDocumentPosition","DOCUMENT_POSITION_FOLLOWING","tabbables","tabbable","find","length","next","before","createElement","ref","tabIndex","onFocus","after","node","onKeyDown","defaultPrevented","keyCode","preventDefault","isShift","shiftKey","direction","nextTabbable","currentBlock","closest","isElementPartOfSelectedBlock","preventScroll","onFocusOut","relatedTarget","activeElement","body","preventScrollOnTab","getAttribute","addEventListener","removeEventListener","mergedRefs"],"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 ) {\n\t\t\t\t\tsetNavigationMode( true );\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nextTabbable = focus.tabbable[ direction ]( event.target );\n\n\t\t\t// We want to constrain the tabbing to the block and its child blocks.\n\t\t\t// If the preceding form element is within a different block,\n\t\t\t// such as two sibling image blocks in the placeholder state,\n\t\t\t// we want shift + tab from the first form element to move to the image\n\t\t\t// block toolbar and not the previous image block's form element.\n\t\t\tconst currentBlock = event.target.closest( '[data-block]' );\n\t\t\tconst isElementPartOfSelectedBlock =\n\t\t\t\tcurrentBlock &&\n\t\t\t\tnextTabbable &&\n\t\t\t\t( isInSameBlock( currentBlock, nextTabbable ) ||\n\t\t\t\t\tisInsideRootBlock( currentBlock, nextTabbable ) );\n\n\t\t\t// Allow tabbing from the block wrapper to a form element,\n\t\t\t// and between form elements rendered in a block and its child blocks,\n\t\t\t// such as inside a placeholder. Form elements are generally\n\t\t\t// meant to be UI rather than part of the content. Ideally\n\t\t\t// these are not rendered in the content and perhaps in the\n\t\t\t// future they can be rendered in an iframe or shadow DOM.\n\t\t\tif (\n\t\t\t\tisFormElement( nextTabbable ) &&\n\t\t\t\tisElementPartOfSelectedBlock\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef;\n\n\t\t\t// Disable focus capturing on the focus capture element, so it\n\t\t\t// doesn't refocus this block and so it allows default behaviour\n\t\t\t// (moving focus to the next tabbable element).\n\t\t\tnoCapture.current = true;\n\n\t\t\t// Focusing the focus capture element, which is located above and\n\t\t\t// below the editor, should not scroll the page all the way up or\n\t\t\t// down.\n\t\t\tnext.current.focus( { preventScroll: true } );\n\t\t}\n\n\t\tfunction onFocusOut( event ) {\n\t\t\tsetLastFocus( { ...getLastFocus(), current: event.target } );\n\n\t\t\tconst { ownerDocument } = node;\n\n\t\t\t// If focus disappears due to there being no blocks, move focus to\n\t\t\t// the writing flow wrapper.\n\t\t\tif (\n\t\t\t\t! event.relatedTarget &&\n\t\t\t\townerDocument.activeElement === ownerDocument.body &&\n\t\t\t\tgetBlockCount() === 0\n\t\t\t) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t}\n\n\t\t// When tabbing back to an element in block list, this event handler prevents scrolling if the\n\t\t// focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph\n\t\t// when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the\n\t\t// top or bottom of the document.\n\t\t//\n\t\t// Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this\n\t\t// earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters\n\t\tfunction preventScrollOnTab( event ) {\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.target?.getAttribute( 'role' ) === 'region' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( container.current === event.target ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst target = focus.tabbable[ direction ]( event.target );\n\t\t\t// Only do something when the next tabbable is a focus capture div (before/after)\n\t\t\tif (\n\t\t\t\ttarget === focusCaptureBeforeRef.current ||\n\t\t\t\ttarget === focusCaptureAfterRef.current\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\ttarget.focus( { preventScroll: true } );\n\t\t\t}\n\t\t}\n\n\t\tconst { ownerDocument } = node;\n\t\tconst { defaultView } = ownerDocument;\n\t\tdefaultView.addEventListener( 'keydown', preventScrollOnTab );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'focusout', onFocusOut );\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'keydown', preventScrollOnTab );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'focusout', onFocusOut );\n\t\t};\n\t}, [] );\n\n\tconst mergedRefs = useMergeRefs( [ container, ref ] );\n\n\treturn [ before, mergedRefs, after ];\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,EAAEC,aAAa,QAAQ,gBAAgB;AACrD,SAASC,GAAG,EAAEC,MAAM,QAAQ,qBAAqB;AACjD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,YAAY,EAAEC,YAAY,QAAQ,oBAAoB;AAC/D,SAASC,MAAM,QAAQ,oBAAoB;;AAE3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,aAAa,EAAEC,iBAAiB,QAAQ,iBAAiB;AAClE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CAACoC,mBAAmB,CAAE,SAAS,EAAEH,kBAAmB,CAAC;MAChEjB,IAAI,CAACoB,mBAAmB,CAAE,SAAS,EAAEnB,SAAU,CAAC;MAChDD,IAAI,CAACoB,mBAAmB,CAAE,UAAU,EAAEP,UAAW,CAAC;IACnD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMQ,UAAU,GAAGjE,YAAY,CAAE,CAAEQ,SAAS,EAAEgC,GAAG,CAAG,CAAC;EAErD,OAAO,CAAEF,MAAM,EAAE2B,UAAU,EAAEtB,KAAK,CAAE;AACrC","ignoreList":[]}
1
+ {"version":3,"names":["focus","isFormElement","TAB","ESCAPE","useSelect","useDispatch","useRefEffect","useMergeRefs","useRef","store","blockEditorStore","isInSameBlock","isInsideRootBlock","unlock","useTabNav","container","focusCaptureBeforeRef","focusCaptureAfterRef","hasMultiSelection","getSelectedBlockClientId","getBlockCount","setNavigationMode","setLastFocus","isNavigationMode","select","getLastFocus","focusCaptureTabIndex","undefined","noCapture","onFocusCapture","event","current","querySelector","canvasElement","ownerDocument","target","defaultView","frameElement","isBefore","compareDocumentPosition","DOCUMENT_POSITION_FOLLOWING","tabbables","tabbable","find","length","next","before","createElement","ref","tabIndex","onFocus","after","node","onKeyDown","defaultPrevented","keyCode","preventDefault","isShift","shiftKey","direction","nextTabbable","currentBlock","closest","isElementPartOfSelectedBlock","preventScroll","onFocusOut","relatedTarget","activeElement","body","preventScrollOnTab","getAttribute","addEventListener","removeEventListener","mergedRefs"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-tab-nav.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { focus, isFormElement } from '@wordpress/dom';\nimport { TAB, ESCAPE } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { isInSameBlock, isInsideRootBlock } from '../../utils/dom';\nimport { unlock } from '../../lock-unlock';\n\nexport default function useTabNav() {\n\tconst container = useRef();\n\tconst focusCaptureBeforeRef = useRef();\n\tconst focusCaptureAfterRef = useRef();\n\n\tconst { hasMultiSelection, getSelectedBlockClientId, getBlockCount } =\n\t\tuseSelect( blockEditorStore );\n\tconst { setNavigationMode, setLastFocus } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\tconst isNavigationMode = useSelect(\n\t\t( select ) => select( blockEditorStore ).isNavigationMode(),\n\t\t[]\n\t);\n\n\tconst { getLastFocus } = unlock( useSelect( blockEditorStore ) );\n\n\t// Don't allow tabbing to this element in Navigation mode.\n\tconst focusCaptureTabIndex = ! isNavigationMode ? '0' : undefined;\n\n\t// Reference that holds the a flag for enabling or disabling\n\t// capturing on the focus capture elements.\n\tconst noCapture = useRef();\n\n\tfunction onFocusCapture( event ) {\n\t\t// Do not capture incoming focus if set by us in WritingFlow.\n\t\tif ( noCapture.current ) {\n\t\t\tnoCapture.current = null;\n\t\t} else if ( hasMultiSelection() ) {\n\t\t\tcontainer.current.focus();\n\t\t} else if ( getSelectedBlockClientId() ) {\n\t\t\tif ( getLastFocus()?.current ) {\n\t\t\t\tgetLastFocus().current.focus();\n\t\t\t} else {\n\t\t\t\t// Handles when the last focus has not been set yet, or has been cleared by new blocks being added via the inserter.\n\t\t\t\tcontainer.current\n\t\t\t\t\t.querySelector(\n\t\t\t\t\t\t`[data-block=\"${ getSelectedBlockClientId() }\"]`\n\t\t\t\t\t)\n\t\t\t\t\t.focus();\n\t\t\t}\n\t\t} else {\n\t\t\tsetNavigationMode( true );\n\n\t\t\tconst canvasElement =\n\t\t\t\tcontainer.current.ownerDocument === event.target.ownerDocument\n\t\t\t\t\t? container.current\n\t\t\t\t\t: container.current.ownerDocument.defaultView.frameElement;\n\n\t\t\tconst isBefore =\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tevent.target.compareDocumentPosition( canvasElement ) &\n\t\t\t\tevent.target.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tconst tabbables = focus.tabbable.find( container.current );\n\n\t\t\tif ( tabbables.length ) {\n\t\t\t\tconst next = isBefore\n\t\t\t\t\t? tabbables[ 0 ]\n\t\t\t\t\t: tabbables[ tabbables.length - 1 ];\n\n\t\t\t\tnext.focus();\n\t\t\t}\n\t\t}\n\t}\n\n\tconst before = (\n\t\t<div\n\t\t\tref={ focusCaptureBeforeRef }\n\t\t\ttabIndex={ focusCaptureTabIndex }\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst after = (\n\t\t<div\n\t\t\tref={ focusCaptureAfterRef }\n\t\t\ttabIndex={ focusCaptureTabIndex }\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst ref = useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ESCAPE && ! hasMultiSelection() ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetNavigationMode( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// In Edit mode, Tab should focus the first tabbable element after\n\t\t\t// the content, which is normally the sidebar (with block controls)\n\t\t\t// and Shift+Tab should focus the first tabbable element before the\n\t\t\t// content, which is normally the block toolbar.\n\t\t\t// Arrow keys can be used, and Tab and arrow keys can be used in\n\t\t\t// Navigation mode (press Esc), to navigate through blocks.\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\n\t\t\tif ( ! hasMultiSelection() && ! getSelectedBlockClientId() ) {\n\t\t\t\t// Preserve the behaviour of entering navigation mode when\n\t\t\t\t// tabbing into the content without a block selection.\n\t\t\t\t// `onFocusCapture` already did this previously, but we need to\n\t\t\t\t// do it again here because after clearing block selection,\n\t\t\t\t// focus land on the writing flow container and pressing Tab\n\t\t\t\t// will no longer send focus through the focus capture element.\n\t\t\t\tif ( event.target === node ) {\n\t\t\t\t\tsetNavigationMode( true );\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nextTabbable = focus.tabbable[ direction ]( event.target );\n\n\t\t\t// We want to constrain the tabbing to the block and its child blocks.\n\t\t\t// If the preceding form element is within a different block,\n\t\t\t// such as two sibling image blocks in the placeholder state,\n\t\t\t// we want shift + tab from the first form element to move to the image\n\t\t\t// block toolbar and not the previous image block's form element.\n\t\t\tconst currentBlock = event.target.closest( '[data-block]' );\n\t\t\tconst isElementPartOfSelectedBlock =\n\t\t\t\tcurrentBlock &&\n\t\t\t\tnextTabbable &&\n\t\t\t\t( isInSameBlock( currentBlock, nextTabbable ) ||\n\t\t\t\t\tisInsideRootBlock( currentBlock, nextTabbable ) );\n\n\t\t\t// Allow tabbing from the block wrapper to a form element,\n\t\t\t// and between form elements rendered in a block and its child blocks,\n\t\t\t// such as inside a placeholder. Form elements are generally\n\t\t\t// meant to be UI rather than part of the content. Ideally\n\t\t\t// these are not rendered in the content and perhaps in the\n\t\t\t// future they can be rendered in an iframe or shadow DOM.\n\t\t\tif (\n\t\t\t\tisFormElement( nextTabbable ) &&\n\t\t\t\tisElementPartOfSelectedBlock\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef;\n\n\t\t\t// Disable focus capturing on the focus capture element, so it\n\t\t\t// doesn't refocus this block and so it allows default behaviour\n\t\t\t// (moving focus to the next tabbable element).\n\t\t\tnoCapture.current = true;\n\n\t\t\t// Focusing the focus capture element, which is located above and\n\t\t\t// below the editor, should not scroll the page all the way up or\n\t\t\t// down.\n\t\t\tnext.current.focus( { preventScroll: true } );\n\t\t}\n\n\t\tfunction onFocusOut( event ) {\n\t\t\tsetLastFocus( { ...getLastFocus(), current: event.target } );\n\n\t\t\tconst { ownerDocument } = node;\n\n\t\t\t// If focus disappears due to there being no blocks, move focus to\n\t\t\t// the writing flow wrapper.\n\t\t\tif (\n\t\t\t\t! event.relatedTarget &&\n\t\t\t\townerDocument.activeElement === ownerDocument.body &&\n\t\t\t\tgetBlockCount() === 0\n\t\t\t) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t}\n\n\t\t// When tabbing back to an element in block list, this event handler prevents scrolling if the\n\t\t// focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph\n\t\t// when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the\n\t\t// top or bottom of the document.\n\t\t//\n\t\t// Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this\n\t\t// earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters\n\t\tfunction preventScrollOnTab( event ) {\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.target?.getAttribute( 'role' ) === 'region' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( container.current === event.target ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst target = focus.tabbable[ direction ]( event.target );\n\t\t\t// Only do something when the next tabbable is a focus capture div (before/after)\n\t\t\tif (\n\t\t\t\ttarget === focusCaptureBeforeRef.current ||\n\t\t\t\ttarget === focusCaptureAfterRef.current\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\ttarget.focus( { preventScroll: true } );\n\t\t\t}\n\t\t}\n\n\t\tconst { ownerDocument } = node;\n\t\tconst { defaultView } = ownerDocument;\n\t\tdefaultView.addEventListener( 'keydown', preventScrollOnTab );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'focusout', onFocusOut );\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'keydown', preventScrollOnTab );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'focusout', onFocusOut );\n\t\t};\n\t}, [] );\n\n\tconst mergedRefs = useMergeRefs( [ container, ref ] );\n\n\treturn [ before, mergedRefs, after ];\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,EAAEC,aAAa,QAAQ,gBAAgB;AACrD,SAASC,GAAG,EAAEC,MAAM,QAAQ,qBAAqB;AACjD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,YAAY,EAAEC,YAAY,QAAQ,oBAAoB;AAC/D,SAASC,MAAM,QAAQ,oBAAoB;;AAE3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,aAAa,EAAEC,iBAAiB,QAAQ,iBAAiB;AAClE,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,eAAe,SAASC,SAASA,CAAA,EAAG;EACnC,MAAMC,SAAS,GAAGP,MAAM,CAAC,CAAC;EAC1B,MAAMQ,qBAAqB,GAAGR,MAAM,CAAC,CAAC;EACtC,MAAMS,oBAAoB,GAAGT,MAAM,CAAC,CAAC;EAErC,MAAM;IAAEU,iBAAiB;IAAEC,wBAAwB;IAAEC;EAAc,CAAC,GACnEhB,SAAS,CAAEM,gBAAiB,CAAC;EAC9B,MAAM;IAAEW,iBAAiB;IAAEC;EAAa,CAAC,GAAGT,MAAM,CACjDR,WAAW,CAAEK,gBAAiB,CAC/B,CAAC;EACD,MAAMa,gBAAgB,GAAGnB,SAAS,CAC/BoB,MAAM,IAAMA,MAAM,CAAEd,gBAAiB,CAAC,CAACa,gBAAgB,CAAC,CAAC,EAC3D,EACD,CAAC;EAED,MAAM;IAAEE;EAAa,CAAC,GAAGZ,MAAM,CAAET,SAAS,CAAEM,gBAAiB,CAAE,CAAC;;EAEhE;EACA,MAAMgB,oBAAoB,GAAG,CAAEH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,EAAG;QACzC;MACD;MAEA,MAAMsB,OAAO,GAAG3B,KAAK,CAAC4B,QAAQ;MAC9B,MAAMC,SAAS,GAAGF,OAAO,GAAG,cAAc,GAAG,UAAU;MACvD,MAAMtB,MAAM,GAAGnC,KAAK,CAAC0C,QAAQ,CAAEiB,SAAS,CAAE,CAAE7B,KAAK,CAACK,MAAO,CAAC;MAC1D;MACA,IACCA,MAAM,KAAKnB,qBAAqB,CAACe,OAAO,IACxCI,MAAM,KAAKlB,oBAAoB,CAACc,OAAO,EACtC;QACDD,KAAK,CAAC0B,cAAc,CAAC,CAAC;QACtBrB,MAAM,CAACnC,KAAK,CAAE;UAAEgE,aAAa,EAAE;QAAK,CAAE,CAAC;MACxC;IACD;IAEA,MAAM;MAAE9B;IAAc,CAAC,GAAGkB,IAAI;IAC9B,MAAM;MAAEhB;IAAY,CAAC,GAAGF,aAAa;IACrCE,WAAW,CAACmC,gBAAgB,CAAE,SAAS,EAAEF,kBAAmB,CAAC;IAC7DjB,IAAI,CAACmB,gBAAgB,CAAE,SAAS,EAAElB,SAAU,CAAC;IAC7CD,IAAI,CAACmB,gBAAgB,CAAE,UAAU,EAAEN,UAAW,CAAC;IAC/C,OAAO,MAAM;MACZ7B,WAAW,CAACoC,mBAAmB,CAAE,SAAS,EAAEH,kBAAmB,CAAC;MAChEjB,IAAI,CAACoB,mBAAmB,CAAE,SAAS,EAAEnB,SAAU,CAAC;MAChDD,IAAI,CAACoB,mBAAmB,CAAE,UAAU,EAAEP,UAAW,CAAC;IACnD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMQ,UAAU,GAAGlE,YAAY,CAAE,CAAEQ,SAAS,EAAEiC,GAAG,CAAG,CAAC;EAErD,OAAO,CAAEF,MAAM,EAAE2B,UAAU,EAAEtB,KAAK,CAAE;AACrC","ignoreList":[]}
@@ -2,7 +2,7 @@ import { createElement } from "react";
2
2
  /**
3
3
  * External dependencies
4
4
  */
5
- import classnames from 'classnames';
5
+ import clsx from 'clsx';
6
6
 
7
7
  /**
8
8
  * WordPress dependencies
@@ -42,7 +42,7 @@ export default function WritingModeControl({
42
42
  return createElement(SegmentedTextControl, {
43
43
  label: __('Orientation'),
44
44
  options: WRITING_MODES,
45
- className: classnames('block-editor-writing-mode-control', className),
45
+ className: clsx('block-editor-writing-mode-control', className),
46
46
  value: value,
47
47
  onChange: newValue => {
48
48
  onChange(newValue === value ? undefined : newValue);
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","__","isRTL","textHorizontal","textVertical","SegmentedTextControl","WRITING_MODES","label","value","icon","WritingModeControl","className","onChange","createElement","options","newValue","undefined"],"sources":["@wordpress/block-editor/src/components/writing-mode-control/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { textHorizontal, textVertical } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport SegmentedTextControl from '../segmented-text-control';\n\nconst WRITING_MODES = [\n\t{\n\t\tlabel: __( 'Horizontal' ),\n\t\tvalue: 'horizontal-tb',\n\t\ticon: textHorizontal,\n\t},\n\t{\n\t\tlabel: __( 'Vertical' ),\n\t\tvalue: isRTL() ? 'vertical-lr' : 'vertical-rl',\n\t\ticon: textVertical,\n\t},\n];\n\n/**\n * Control to facilitate writing mode selections.\n *\n * @param {Object} props Component props.\n * @param {string} props.className Class name to add to the control.\n * @param {string} props.value Currently selected writing mode.\n * @param {Function} props.onChange Handles change in the writing mode selection.\n *\n * @return {Element} Writing Mode control.\n */\nexport default function WritingModeControl( { className, value, onChange } ) {\n\treturn (\n\t\t<SegmentedTextControl\n\t\t\tlabel={ __( 'Orientation' ) }\n\t\t\toptions={ WRITING_MODES }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-writing-mode-control',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\tvalue={ value }\n\t\t\tonChange={ ( newValue ) => {\n\t\t\t\tonChange( newValue === value ? undefined : newValue );\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,EAAEC,KAAK,QAAQ,iBAAiB;AAC3C,SAASC,cAAc,EAAEC,YAAY,QAAQ,kBAAkB;;AAE/D;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,2BAA2B;AAE5D,MAAMC,aAAa,GAAG,CACrB;EACCC,KAAK,EAAEN,EAAE,CAAE,YAAa,CAAC;EACzBO,KAAK,EAAE,eAAe;EACtBC,IAAI,EAAEN;AACP,CAAC,EACD;EACCI,KAAK,EAAEN,EAAE,CAAE,UAAW,CAAC;EACvBO,KAAK,EAAEN,KAAK,CAAC,CAAC,GAAG,aAAa,GAAG,aAAa;EAC9CO,IAAI,EAAEL;AACP,CAAC,CACD;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASM,kBAAkBA,CAAE;EAAEC,SAAS;EAAEH,KAAK;EAAEI;AAAS,CAAC,EAAG;EAC5E,OACCC,aAAA,CAACR,oBAAoB;IACpBE,KAAK,EAAGN,EAAE,CAAE,aAAc,CAAG;IAC7Ba,OAAO,EAAGR,aAAe;IACzBK,SAAS,EAAGX,UAAU,CACrB,mCAAmC,EACnCW,SACD,CAAG;IACHH,KAAK,EAAGA,KAAO;IACfI,QAAQ,EAAKG,QAAQ,IAAM;MAC1BH,QAAQ,CAAEG,QAAQ,KAAKP,KAAK,GAAGQ,SAAS,GAAGD,QAAS,CAAC;IACtD;EAAG,CACH,CAAC;AAEJ","ignoreList":[]}
1
+ {"version":3,"names":["clsx","__","isRTL","textHorizontal","textVertical","SegmentedTextControl","WRITING_MODES","label","value","icon","WritingModeControl","className","onChange","createElement","options","newValue","undefined"],"sources":["@wordpress/block-editor/src/components/writing-mode-control/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { textHorizontal, textVertical } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport SegmentedTextControl from '../segmented-text-control';\n\nconst WRITING_MODES = [\n\t{\n\t\tlabel: __( 'Horizontal' ),\n\t\tvalue: 'horizontal-tb',\n\t\ticon: textHorizontal,\n\t},\n\t{\n\t\tlabel: __( 'Vertical' ),\n\t\tvalue: isRTL() ? 'vertical-lr' : 'vertical-rl',\n\t\ticon: textVertical,\n\t},\n];\n\n/**\n * Control to facilitate writing mode selections.\n *\n * @param {Object} props Component props.\n * @param {string} props.className Class name to add to the control.\n * @param {string} props.value Currently selected writing mode.\n * @param {Function} props.onChange Handles change in the writing mode selection.\n *\n * @return {Element} Writing Mode control.\n */\nexport default function WritingModeControl( { className, value, onChange } ) {\n\treturn (\n\t\t<SegmentedTextControl\n\t\t\tlabel={ __( 'Orientation' ) }\n\t\t\toptions={ WRITING_MODES }\n\t\t\tclassName={ clsx( 'block-editor-writing-mode-control', className ) }\n\t\t\tvalue={ value }\n\t\t\tonChange={ ( newValue ) => {\n\t\t\t\tonChange( newValue === value ? undefined : newValue );\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,EAAE,EAAEC,KAAK,QAAQ,iBAAiB;AAC3C,SAASC,cAAc,EAAEC,YAAY,QAAQ,kBAAkB;;AAE/D;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,2BAA2B;AAE5D,MAAMC,aAAa,GAAG,CACrB;EACCC,KAAK,EAAEN,EAAE,CAAE,YAAa,CAAC;EACzBO,KAAK,EAAE,eAAe;EACtBC,IAAI,EAAEN;AACP,CAAC,EACD;EACCI,KAAK,EAAEN,EAAE,CAAE,UAAW,CAAC;EACvBO,KAAK,EAAEN,KAAK,CAAC,CAAC,GAAG,aAAa,GAAG,aAAa;EAC9CO,IAAI,EAAEL;AACP,CAAC,CACD;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASM,kBAAkBA,CAAE;EAAEC,SAAS;EAAEH,KAAK;EAAEI;AAAS,CAAC,EAAG;EAC5E,OACCC,aAAA,CAACR,oBAAoB;IACpBE,KAAK,EAAGN,EAAE,CAAE,aAAc,CAAG;IAC7Ba,OAAO,EAAGR,aAAe;IACzBK,SAAS,EAAGX,IAAI,CAAE,mCAAmC,EAAEW,SAAU,CAAG;IACpEH,KAAK,EAAGA,KAAO;IACfI,QAAQ,EAAKG,QAAQ,IAAM;MAC1BH,QAAQ,CAAEG,QAAQ,KAAKP,KAAK,GAAGQ,SAAS,GAAGD,QAAS,CAAC;IACtD;EAAG,CACH,CAAC;AAEJ","ignoreList":[]}
@@ -2,7 +2,7 @@ import { createElement } from "react";
2
2
  /**
3
3
  * External dependencies
4
4
  */
5
- import classnames from 'classnames';
5
+ import clsx from 'clsx';
6
6
 
7
7
  /**
8
8
  * WordPress dependencies
@@ -174,7 +174,7 @@ export function addAssignedAlign(props, blockType, attributes) {
174
174
  // This way changing themes does not impact the block save.
175
175
  const isAlignValid = getValidAlignments(blockAlign, hasWideBlockSupport).includes(align);
176
176
  if (isAlignValid) {
177
- props.className = classnames(`align${align}`, props.className);
177
+ props.className = clsx(`align${align}`, props.className);
178
178
  }
179
179
  return props;
180
180
  }
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","addFilter","getBlockSupport","getBlockType","hasBlockSupport","BlockControls","BlockAlignmentControl","useAvailableAlignments","useBlockEditingMode","ALL_ALIGNMENTS","WIDE_ALIGNMENTS","getValidAlignments","blockAlign","hasWideBlockSupport","hasWideEnabled","validAlignments","Array","isArray","filter","value","includes","alignment","addAttribute","settings","_settings$attributes$","attributes","align","type","enum","BlockEditAlignmentToolbarControlsPure","name","blockName","setAttributes","blockAllowedAlignments","map","blockEditingMode","length","updateAlignment","nextAlign","blockType","blockDefaultAlign","default","createElement","group","__experimentalShareWithChildBlocks","onChange","controls","shareWithChildBlocks","edit","useBlockProps","addSaveProps","addAssignedAlign","attributeKeys","hasSupport","some","props","isAlignValid","className"],"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/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AEd,UAAU,EAAG;EAChE,MAAM;IAAEC;EAAM,CAAC,GAAGD,UAAU;EAC5B,MAAMb,UAAU,GAAGV,eAAe,CAAEqC,SAAS,EAAE,OAAQ,CAAC;EACxD,MAAM1B,mBAAmB,GAAGT,eAAe,CAAEmC,SAAS,EAAE,WAAW,EAAE,IAAK,CAAC;;EAE3E;EACA;EACA;EACA,MAAMiB,YAAY,GAAG7C,kBAAkB,CACtCC,UAAU,EACVC,mBACD,CAAC,CAACO,QAAQ,CAAEM,KAAM,CAAC;EACnB,IAAK8B,YAAY,EAAG;IACnBD,KAAK,CAACE,SAAS,GAAGzD,UAAU,CAAG,QAAQ0B,KAAO,EAAC,EAAE6B,KAAK,CAACE,SAAU,CAAC;EACnE;EAEA,OAAOF,KAAK;AACb;AAEAtD,SAAS,CACR,0BAA0B,EAC1B,gCAAgC,EAChCqB,YACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["clsx","addFilter","getBlockSupport","getBlockType","hasBlockSupport","BlockControls","BlockAlignmentControl","useAvailableAlignments","useBlockEditingMode","ALL_ALIGNMENTS","WIDE_ALIGNMENTS","getValidAlignments","blockAlign","hasWideBlockSupport","hasWideEnabled","validAlignments","Array","isArray","filter","value","includes","alignment","addAttribute","settings","_settings$attributes$","attributes","align","type","enum","BlockEditAlignmentToolbarControlsPure","name","blockName","setAttributes","blockAllowedAlignments","map","blockEditingMode","length","updateAlignment","nextAlign","blockType","blockDefaultAlign","default","createElement","group","__experimentalShareWithChildBlocks","onChange","controls","shareWithChildBlocks","edit","useBlockProps","addSaveProps","addAssignedAlign","attributeKeys","hasSupport","some","props","isAlignValid","className"],"sources":["@wordpress/block-editor/src/hooks/align.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\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 = clsx( `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":";AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SACCC,eAAe,EACfC,YAAY,EACZC,eAAe,QACT,mBAAmB;;AAE1B;AACA;AACA;AACA,SAASC,aAAa,EAAEC,qBAAqB,QAAQ,eAAe;AACpE,OAAOC,sBAAsB,MAAM,gEAAgE;AACnG,SAASC,mBAAmB,QAAQ,kCAA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CAAC;EACnB,IAAK8B,YAAY,EAAG;IACnBD,KAAK,CAACE,SAAS,GAAGzD,IAAI,CAAG,QAAQ0B,KAAO,EAAC,EAAE6B,KAAK,CAACE,SAAU,CAAC;EAC7D;EAEA,OAAOF,KAAK;AACb;AAEAtD,SAAS,CACR,0BAA0B,EAC1B,gCAAgC,EAChCqB,YACD,CAAC","ignoreList":[]}
@@ -46,7 +46,7 @@ export function setBackgroundStyleDefaults(backgroundStyle) {
46
46
  let backgroundStylesWithDefaults;
47
47
 
48
48
  // Set block background defaults.
49
- if (backgroundImage?.source === 'file' && !!backgroundImage?.url) {
49
+ if (!!backgroundImage?.url) {
50
50
  if (!backgroundStyle?.backgroundSize) {
51
51
  backgroundStylesWithDefaults = {
52
52
  backgroundSize: 'cover'
@@ -1 +1 @@
1
- {"version":3,"names":["getBlockSupport","useSelect","useCallback","InspectorControls","cleanEmptyObject","store","blockEditorStore","default","StylesBackgroundPanel","useHasBackgroundPanel","hasBackgroundImageValue","BACKGROUND_SUPPORT_KEY","BACKGROUND_DEFAULT_VALUES","backgroundSize","hasBackgroundSupport","blockName","feature","support","backgroundImage","backgroundRepeat","setBackgroundStyleDefaults","backgroundStyle","backgroundStylesWithDefaults","source","url","backgroundPosition","useBlockProps","name","style","background","backgroundStyles","getBackgroundImageClasses","BackgroundInspectorControl","children","resetAllFilter","attributes","undefined","createElement","group","BackgroundImagePanel","clientId","setAttributes","settings","select","getBlockAttributes","defaultControls","onChange","newStyle","updatedSettings","as","panelId","defaultValues","value","attributeKeys","hasSupport"],"sources":["@wordpress/block-editor/src/hooks/background.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport { cleanEmptyObject } from './utils';\nimport { store as blockEditorStore } from '../store';\nimport {\n\tdefault as StylesBackgroundPanel,\n\tuseHasBackgroundPanel,\n\thasBackgroundImageValue,\n} from '../components/global-styles/background-panel';\n\nexport const BACKGROUND_SUPPORT_KEY = 'background';\n\n// Initial control values where no block style is set.\nconst BACKGROUND_DEFAULT_VALUES = {\n\tbackgroundSize: 'cover',\n};\n\n/**\n * Determine whether there is block support for background.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBackgroundSupport( blockName, feature = 'any' ) {\n\tconst support = getBlockSupport( blockName, BACKGROUND_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn (\n\t\t\t!! support?.backgroundImage ||\n\t\t\t!! support?.backgroundSize ||\n\t\t\t!! support?.backgroundRepeat\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\nexport function setBackgroundStyleDefaults( backgroundStyle ) {\n\tif ( ! backgroundStyle ) {\n\t\treturn;\n\t}\n\n\tconst backgroundImage = backgroundStyle?.backgroundImage;\n\tlet backgroundStylesWithDefaults;\n\n\t// Set block background defaults.\n\tif ( backgroundImage?.source === 'file' && !! backgroundImage?.url ) {\n\t\tif ( ! backgroundStyle?.backgroundSize ) {\n\t\t\tbackgroundStylesWithDefaults = {\n\t\t\t\tbackgroundSize: 'cover',\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\t'contain' === backgroundStyle?.backgroundSize &&\n\t\t\t! backgroundStyle?.backgroundPosition\n\t\t) {\n\t\t\tbackgroundStylesWithDefaults = {\n\t\t\t\tbackgroundPosition: 'center',\n\t\t\t};\n\t\t}\n\t}\n\n\treturn backgroundStylesWithDefaults;\n}\n\nfunction useBlockProps( { name, style } ) {\n\tif (\n\t\t! hasBackgroundSupport( name ) ||\n\t\t! style?.background?.backgroundImage\n\t) {\n\t\treturn;\n\t}\n\n\tconst backgroundStyles = setBackgroundStyleDefaults( style?.background );\n\n\tif ( ! backgroundStyles ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tstyle: {\n\t\t\t...backgroundStyles,\n\t\t},\n\t};\n}\n\n/**\n * Generates a CSS class name if an background image is set.\n *\n * @param {Object} style A block's style attribute.\n *\n * @return {string} CSS class name.\n */\nexport function getBackgroundImageClasses( style ) {\n\treturn hasBackgroundImageValue( style ) ? 'has-background' : '';\n}\n\nfunction BackgroundInspectorControl( { children } ) {\n\tconst resetAllFilter = useCallback( ( attributes ) => {\n\t\treturn {\n\t\t\t...attributes,\n\t\t\tstyle: {\n\t\t\t\t...attributes.style,\n\t\t\t\tbackground: undefined,\n\t\t\t},\n\t\t};\n\t}, [] );\n\treturn (\n\t\t<InspectorControls group=\"background\" resetAllFilter={ resetAllFilter }>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BackgroundImagePanel( {\n\tclientId,\n\tname,\n\tsetAttributes,\n\tsettings,\n} ) {\n\tconst style = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlockAttributes( clientId )?.style,\n\t\t[ clientId ]\n\t);\n\n\tif (\n\t\t! useHasBackgroundPanel( settings ) ||\n\t\t! hasBackgroundSupport( name, 'backgroundImage' )\n\t) {\n\t\treturn null;\n\t}\n\n\tconst defaultControls = getBlockSupport( name, [\n\t\tBACKGROUND_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\tconst onChange = ( newStyle ) => {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\tconst updatedSettings = {\n\t\t...settings,\n\t\tbackground: {\n\t\t\t...settings.background,\n\t\t\tbackgroundSize:\n\t\t\t\tsettings?.background?.backgroundSize &&\n\t\t\t\thasBackgroundSupport( name, 'backgroundSize' ),\n\t\t},\n\t};\n\n\treturn (\n\t\t<StylesBackgroundPanel\n\t\t\tas={ BackgroundInspectorControl }\n\t\t\tpanelId={ clientId }\n\t\t\tdefaultControls={ defaultControls }\n\t\t\tdefaultValues={ BACKGROUND_DEFAULT_VALUES }\n\t\t\tsettings={ updatedSettings }\n\t\t\tonChange={ onChange }\n\t\t\tvalue={ style }\n\t\t/>\n\t);\n}\n\nexport default {\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport: hasBackgroundSupport,\n};\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,WAAW,QAAQ,oBAAoB;;AAEhD;AACA;AACA;AACA,OAAOC,iBAAiB,MAAM,kCAAkC;AAChE,SAASC,gBAAgB,QAAQ,SAAS;AAC1C,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,UAAU;AACpD,SACCC,OAAO,IAAIC,qBAAqB,EAChCC,qBAAqB,EACrBC,uBAAuB,QACjB,8CAA8C;AAErD,OAAO,MAAMC,sBAAsB,GAAG,YAAY;;AAElD;AACA,MAAMC,yBAAyB,GAAG;EACjCC,cAAc,EAAE;AACjB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAAEC,SAAS,EAAEC,OAAO,GAAG,KAAK,EAAG;EAClE,MAAMC,OAAO,GAAGjB,eAAe,CAAEe,SAAS,EAAEJ,sBAAuB,CAAC;EAEpE,IAAKM,OAAO,KAAK,IAAI,EAAG;IACvB,OAAO,IAAI;EACZ;EAEA,IAAKD,OAAO,KAAK,KAAK,EAAG;IACxB,OACC,CAAC,CAAEC,OAAO,EAAEC,eAAe,IAC3B,CAAC,CAAED,OAAO,EAAEJ,cAAc,IAC1B,CAAC,CAAEI,OAAO,EAAEE,gBAAgB;EAE9B;EAEA,OAAO,CAAC,CAAEF,OAAO,GAAID,OAAO,CAAE;AAC/B;AAEA,OAAO,SAASI,0BAA0BA,CAAEC,eAAe,EAAG;EAC7D,IAAK,CAAEA,eAAe,EAAG;IACxB;EACD;EAEA,MAAMH,eAAe,GAAGG,eAAe,EAAEH,eAAe;EACxD,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 {"version":3,"names":["getBlockSupport","useSelect","useCallback","InspectorControls","cleanEmptyObject","store","blockEditorStore","default","StylesBackgroundPanel","useHasBackgroundPanel","hasBackgroundImageValue","BACKGROUND_SUPPORT_KEY","BACKGROUND_DEFAULT_VALUES","backgroundSize","hasBackgroundSupport","blockName","feature","support","backgroundImage","backgroundRepeat","setBackgroundStyleDefaults","backgroundStyle","backgroundStylesWithDefaults","url","backgroundPosition","useBlockProps","name","style","background","backgroundStyles","getBackgroundImageClasses","BackgroundInspectorControl","children","resetAllFilter","attributes","undefined","createElement","group","BackgroundImagePanel","clientId","setAttributes","settings","select","getBlockAttributes","defaultControls","onChange","newStyle","updatedSettings","as","panelId","defaultValues","value","attributeKeys","hasSupport"],"sources":["@wordpress/block-editor/src/hooks/background.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport { cleanEmptyObject } from './utils';\nimport { store as blockEditorStore } from '../store';\nimport {\n\tdefault as StylesBackgroundPanel,\n\tuseHasBackgroundPanel,\n\thasBackgroundImageValue,\n} from '../components/global-styles/background-panel';\n\nexport const BACKGROUND_SUPPORT_KEY = 'background';\n\n// Initial control values where no block style is set.\nconst BACKGROUND_DEFAULT_VALUES = {\n\tbackgroundSize: 'cover',\n};\n\n/**\n * Determine whether there is block support for background.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBackgroundSupport( blockName, feature = 'any' ) {\n\tconst support = getBlockSupport( blockName, BACKGROUND_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn (\n\t\t\t!! support?.backgroundImage ||\n\t\t\t!! support?.backgroundSize ||\n\t\t\t!! support?.backgroundRepeat\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\nexport function setBackgroundStyleDefaults( backgroundStyle ) {\n\tif ( ! backgroundStyle ) {\n\t\treturn;\n\t}\n\n\tconst backgroundImage = backgroundStyle?.backgroundImage;\n\tlet backgroundStylesWithDefaults;\n\n\t// Set block background defaults.\n\tif ( !! backgroundImage?.url ) {\n\t\tif ( ! backgroundStyle?.backgroundSize ) {\n\t\t\tbackgroundStylesWithDefaults = {\n\t\t\t\tbackgroundSize: 'cover',\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\t'contain' === backgroundStyle?.backgroundSize &&\n\t\t\t! backgroundStyle?.backgroundPosition\n\t\t) {\n\t\t\tbackgroundStylesWithDefaults = {\n\t\t\t\tbackgroundPosition: 'center',\n\t\t\t};\n\t\t}\n\t}\n\n\treturn backgroundStylesWithDefaults;\n}\n\nfunction useBlockProps( { name, style } ) {\n\tif (\n\t\t! hasBackgroundSupport( name ) ||\n\t\t! style?.background?.backgroundImage\n\t) {\n\t\treturn;\n\t}\n\n\tconst backgroundStyles = setBackgroundStyleDefaults( style?.background );\n\n\tif ( ! backgroundStyles ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tstyle: {\n\t\t\t...backgroundStyles,\n\t\t},\n\t};\n}\n\n/**\n * Generates a CSS class name if an background image is set.\n *\n * @param {Object} style A block's style attribute.\n *\n * @return {string} CSS class name.\n */\nexport function getBackgroundImageClasses( style ) {\n\treturn hasBackgroundImageValue( style ) ? 'has-background' : '';\n}\n\nfunction BackgroundInspectorControl( { children } ) {\n\tconst resetAllFilter = useCallback( ( attributes ) => {\n\t\treturn {\n\t\t\t...attributes,\n\t\t\tstyle: {\n\t\t\t\t...attributes.style,\n\t\t\t\tbackground: undefined,\n\t\t\t},\n\t\t};\n\t}, [] );\n\treturn (\n\t\t<InspectorControls group=\"background\" resetAllFilter={ resetAllFilter }>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BackgroundImagePanel( {\n\tclientId,\n\tname,\n\tsetAttributes,\n\tsettings,\n} ) {\n\tconst style = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlockAttributes( clientId )?.style,\n\t\t[ clientId ]\n\t);\n\n\tif (\n\t\t! useHasBackgroundPanel( settings ) ||\n\t\t! hasBackgroundSupport( name, 'backgroundImage' )\n\t) {\n\t\treturn null;\n\t}\n\n\tconst defaultControls = getBlockSupport( name, [\n\t\tBACKGROUND_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\tconst onChange = ( newStyle ) => {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\tconst updatedSettings = {\n\t\t...settings,\n\t\tbackground: {\n\t\t\t...settings.background,\n\t\t\tbackgroundSize:\n\t\t\t\tsettings?.background?.backgroundSize &&\n\t\t\t\thasBackgroundSupport( name, 'backgroundSize' ),\n\t\t},\n\t};\n\n\treturn (\n\t\t<StylesBackgroundPanel\n\t\t\tas={ BackgroundInspectorControl }\n\t\t\tpanelId={ clientId }\n\t\t\tdefaultControls={ defaultControls }\n\t\t\tdefaultValues={ BACKGROUND_DEFAULT_VALUES }\n\t\t\tsettings={ updatedSettings }\n\t\t\tonChange={ onChange }\n\t\t\tvalue={ style }\n\t\t/>\n\t);\n}\n\nexport default {\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport: hasBackgroundSupport,\n};\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,WAAW,QAAQ,oBAAoB;;AAEhD;AACA;AACA;AACA,OAAOC,iBAAiB,MAAM,kCAAkC;AAChE,SAASC,gBAAgB,QAAQ,SAAS;AAC1C,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,UAAU;AACpD,SACCC,OAAO,IAAIC,qBAAqB,EAChCC,qBAAqB,EACrBC,uBAAuB,QACjB,8CAA8C;AAEr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IAAM;IAChCN,aAAa,CAAE;MACdb,KAAK,EAAEvB,gBAAgB,CAAE0C,QAAS;IACnC,CAAE,CAAC;EACJ,CAAC;EAED,MAAMC,eAAe,GAAG;IACvB,GAAGN,QAAQ;IACXb,UAAU,EAAE;MACX,GAAGa,QAAQ,CAACb,UAAU;MACtBf,cAAc,EACb4B,QAAQ,EAAEb,UAAU,EAAEf,cAAc,IACpCC,oBAAoB,CAAEY,IAAI,EAAE,gBAAiB;IAC/C;EACD,CAAC;EAED,OACCU,aAAA,CAAC5B,qBAAqB;IACrBwC,EAAE,EAAGjB,0BAA4B;IACjCkB,OAAO,EAAGV,QAAU;IACpBK,eAAe,EAAGA,eAAiB;IACnCM,aAAa,EAAGtC,yBAA2B;IAC3C6B,QAAQ,EAAGM,eAAiB;IAC5BF,QAAQ,EAAGA,QAAU;IACrBM,KAAK,EAAGxB;EAAO,CACf,CAAC;AAEJ;AAEA,eAAe;EACdF,aAAa;EACb2B,aAAa,EAAE,CAAE,OAAO,CAAE;EAC1BC,UAAU,EAAEvC;AACb,CAAC","ignoreList":[]}
@@ -2,7 +2,7 @@ import { createElement } from "react";
2
2
  /**
3
3
  * External dependencies
4
4
  */
5
- import classnames from 'classnames';
5
+ import clsx from 'clsx';
6
6
 
7
7
  /**
8
8
  * WordPress dependencies
@@ -283,7 +283,7 @@ function addSaveProps(props, blockNameOrType, attributes) {
283
283
  return props;
284
284
  }
285
285
  const borderClasses = getBorderClasses(attributes);
286
- const newClassName = classnames(props.className, borderClasses);
286
+ const newClassName = clsx(props.className, borderClasses);
287
287
 
288
288
  // If we are clearing the last of the previous classes in `className`
289
289
  // set it to `undefined` to avoid rendering empty DOM attributes.
@@ -305,7 +305,7 @@ export function getBorderClasses(attributes) {
305
305
  style
306
306
  } = attributes;
307
307
  const borderColorClass = getColorClassName('border-color', borderColor);
308
- return classnames({
308
+ return clsx({
309
309
  'has-border-color': borderColor || style?.border?.color,
310
310
  [borderColorClass]: !!borderColorClass
311
311
  });
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","hasBlockSupport","getBlockSupport","__experimentalHasSplitBorders","hasSplitBorders","Platform","useCallback","useMemo","addFilter","useSelect","getColorClassName","InspectorControls","useMultipleOriginColorsAndGradients","cleanEmptyObject","shouldSkipSerialization","useBlockSettings","useHasBorderPanel","useHasBorderPanelControls","BorderPanel","StylesBorderPanel","store","blockEditorStore","__","BORDER_SUPPORT_KEY","SHADOW_SUPPORT_KEY","getColorByProperty","colors","property","value","matchedColor","some","origin","color","getMultiOriginColor","namedColor","customColor","colorObject","undefined","getColorSlugFromVariable","exec","styleToAttributes","style","border","borderColor","borderColorValue","borderColorSlug","startsWith","substring","length","updatedStyle","attributesToStyle","attributes","BordersInspectorControl","label","children","resetAllFilter","attributesResetAllFilter","existingStyle","createElement","group","clientId","name","setAttributes","settings","isEnabled","selector","select","getBlockAttributes","onChange","newStyle","defaultControls","as","panelId","hasBorderSupport","blockName","feature","OS","support","radius","width","hasShadowSupport","useBorderPanelLabel","hasBorderControl","hasShadowControl","controls","hasBorderColor","hasBorderStyle","hasBorderWidth","hasBorderRadius","hasShadow","removeBorderAttribute","attribute","addAttributes","type","addSaveProps","props","blockNameOrType","borderClasses","getBorderClasses","newClassName","className","borderColorClass","useBlockProps","borderTopColor","top","borderRightColor","right","borderBottomColor","bottom","borderLeftColor","left","extraStyles","attributeKeys","hasSupport"],"sources":["@wordpress/block-editor/src/hooks/border.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { hasBlockSupport, getBlockSupport } from '@wordpress/blocks';\nimport { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/components';\nimport { Platform, useCallback, useMemo } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { getColorClassName } from '../components/colors';\nimport InspectorControls from '../components/inspector-controls';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport {\n\tcleanEmptyObject,\n\tshouldSkipSerialization,\n\tuseBlockSettings,\n} from './utils';\nimport {\n\tuseHasBorderPanel,\n\tuseHasBorderPanelControls,\n\tBorderPanel as StylesBorderPanel,\n} from '../components/global-styles';\nimport { store as blockEditorStore } from '../store';\nimport { __ } from '@wordpress/i18n';\n\nexport const BORDER_SUPPORT_KEY = '__experimentalBorder';\nexport const SHADOW_SUPPORT_KEY = 'shadow';\n\nconst getColorByProperty = ( colors, property, value ) => {\n\tlet matchedColor;\n\n\tcolors.some( ( origin ) =>\n\t\torigin.colors.some( ( color ) => {\n\t\t\tif ( color[ property ] === value ) {\n\t\t\t\tmatchedColor = color;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t} )\n\t);\n\n\treturn matchedColor;\n};\n\nexport const getMultiOriginColor = ( { colors, namedColor, customColor } ) => {\n\t// Search each origin (default, theme, or user) for matching color by name.\n\tif ( namedColor ) {\n\t\tconst colorObject = getColorByProperty( colors, 'slug', namedColor );\n\t\tif ( colorObject ) {\n\t\t\treturn colorObject;\n\t\t}\n\t}\n\n\t// Skip if no custom color or matching named color.\n\tif ( ! customColor ) {\n\t\treturn { color: undefined };\n\t}\n\n\t// Attempt to find color via custom color value or build new object.\n\tconst colorObject = getColorByProperty( colors, 'color', customColor );\n\treturn colorObject ? colorObject : { color: customColor };\n};\n\nfunction getColorSlugFromVariable( value ) {\n\tconst namedColor = /var:preset\\|color\\|(.+)/.exec( value );\n\tif ( namedColor && namedColor[ 1 ] ) {\n\t\treturn namedColor[ 1 ];\n\t}\n\treturn null;\n}\n\nfunction styleToAttributes( style ) {\n\tif ( hasSplitBorders( style?.border ) ) {\n\t\treturn {\n\t\t\tstyle,\n\t\t\tborderColor: undefined,\n\t\t};\n\t}\n\n\tconst borderColorValue = style?.border?.color;\n\tconst borderColorSlug = borderColorValue?.startsWith( 'var:preset|color|' )\n\t\t? borderColorValue.substring( 'var:preset|color|'.length )\n\t\t: undefined;\n\tconst updatedStyle = { ...style };\n\tupdatedStyle.border = {\n\t\t...updatedStyle.border,\n\t\tcolor: borderColorSlug ? undefined : borderColorValue,\n\t};\n\treturn {\n\t\tstyle: cleanEmptyObject( updatedStyle ),\n\t\tborderColor: borderColorSlug,\n\t};\n}\n\nfunction attributesToStyle( attributes ) {\n\tif ( hasSplitBorders( attributes.style?.border ) ) {\n\t\treturn attributes.style;\n\t}\n\treturn {\n\t\t...attributes.style,\n\t\tborder: {\n\t\t\t...attributes.style?.border,\n\t\t\tcolor: attributes.borderColor\n\t\t\t\t? 'var:preset|color|' + attributes.borderColor\n\t\t\t\t: attributes.style?.border?.color,\n\t\t},\n\t};\n}\n\nfunction BordersInspectorControl( { label, children, resetAllFilter } ) {\n\tconst attributesResetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst existingStyle = attributesToStyle( attributes );\n\t\t\tconst updatedStyle = resetAllFilter( existingStyle );\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\t...styleToAttributes( updatedStyle ),\n\t\t\t};\n\t\t},\n\t\t[ resetAllFilter ]\n\t);\n\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"border\"\n\t\t\tresetAllFilter={ attributesResetAllFilter }\n\t\t\tlabel={ label }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BorderPanel( { clientId, name, setAttributes, settings } ) {\n\tconst isEnabled = useHasBorderPanel( settings );\n\tfunction selector( select ) {\n\t\tconst { style, borderColor } =\n\t\t\tselect( blockEditorStore ).getBlockAttributes( clientId ) || {};\n\t\treturn { style, borderColor };\n\t}\n\tconst { style, borderColor } = useSelect( selector, [ clientId ] );\n\tconst value = useMemo( () => {\n\t\treturn attributesToStyle( { style, borderColor } );\n\t}, [ style, borderColor ] );\n\n\tconst onChange = ( newStyle ) => {\n\t\tsetAttributes( styleToAttributes( newStyle ) );\n\t};\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultControls = {\n\t\t...getBlockSupport( name, [\n\t\t\tBORDER_SUPPORT_KEY,\n\t\t\t'__experimentalDefaultControls',\n\t\t] ),\n\t\t...getBlockSupport( name, [\n\t\t\tSHADOW_SUPPORT_KEY,\n\t\t\t'__experimentalDefaultControls',\n\t\t] ),\n\t};\n\n\treturn (\n\t\t<StylesBorderPanel\n\t\t\tas={ BordersInspectorControl }\n\t\t\tpanelId={ clientId }\n\t\t\tsettings={ settings }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t/>\n\t);\n}\n\n/**\n * Determine whether there is block support for border properties.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Border feature to check support for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBorderSupport( blockName, feature = 'any' ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst support = getBlockSupport( blockName, BORDER_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn !! (\n\t\t\tsupport?.color ||\n\t\t\tsupport?.radius ||\n\t\t\tsupport?.width ||\n\t\t\tsupport?.style\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\n/**\n * Determine whether there is block support for shadow properties.\n *\n * @param {string} blockName Block name.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasShadowSupport( blockName ) {\n\treturn hasBlockSupport( blockName, SHADOW_SUPPORT_KEY );\n}\n\nexport function useBorderPanelLabel( {\n\tblockName,\n\thasBorderControl,\n\thasShadowControl,\n} = {} ) {\n\tconst settings = useBlockSettings( blockName );\n\tconst controls = useHasBorderPanelControls( settings );\n\n\tif ( ! hasBorderControl && ! hasShadowControl && blockName ) {\n\t\thasBorderControl =\n\t\t\tcontrols?.hasBorderColor ||\n\t\t\tcontrols?.hasBorderStyle ||\n\t\t\tcontrols?.hasBorderWidth ||\n\t\t\tcontrols?.hasBorderRadius;\n\t\thasShadowControl = controls?.hasShadow;\n\t}\n\n\tif ( hasBorderControl && hasShadowControl ) {\n\t\treturn __( 'Border & Shadow' );\n\t}\n\n\tif ( hasShadowControl ) {\n\t\treturn __( 'Shadow' );\n\t}\n\n\treturn __( 'Border' );\n}\n\n/**\n * Returns a new style object where the specified border attribute has been\n * removed.\n *\n * @param {Object} style Styles from block attributes.\n * @param {string} attribute The border style attribute to clear.\n *\n * @return {Object} Style object with the specified attribute removed.\n */\nexport function removeBorderAttribute( style, attribute ) {\n\treturn cleanEmptyObject( {\n\t\t...style,\n\t\tborder: {\n\t\t\t...style?.border,\n\t\t\t[ attribute ]: undefined,\n\t\t},\n\t} );\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * `borderColor` if needed.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Updated block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBorderSupport( settings, 'color' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify default value if needed.\n\tif ( settings.attributes.borderColor ) {\n\t\treturn settings;\n\t}\n\n\t// Add new borderColor attribute to block settings.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tborderColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Override props assigned to save component to inject border color.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object|string} blockNameOrType Block type definition.\n * @param {Object} attributes Block's attributes.\n *\n * @return {Object} Filtered props to apply to save element.\n */\nfunction addSaveProps( props, blockNameOrType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockNameOrType, 'color' ) ||\n\t\tshouldSkipSerialization( blockNameOrType, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst borderClasses = getBorderClasses( attributes );\n\tconst newClassName = classnames( props.className, borderClasses );\n\n\t// If we are clearing the last of the previous classes in `className`\n\t// set it to `undefined` to avoid rendering empty DOM attributes.\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Generates a CSS class name consisting of all the applicable border color\n * classes given the current block attributes.\n *\n * @param {Object} attributes Block's attributes.\n *\n * @return {string} CSS class name.\n */\nexport function getBorderClasses( attributes ) {\n\tconst { borderColor, style } = attributes;\n\tconst borderColorClass = getColorClassName( 'border-color', borderColor );\n\n\treturn classnames( {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\n}\n\nfunction useBlockProps( { name, borderColor, style } ) {\n\tconst { colors } = useMultipleOriginColorsAndGradients();\n\n\tif (\n\t\t! hasBorderSupport( name, 'color' ) ||\n\t\tshouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn {};\n\t}\n\n\tconst { color: borderColorValue } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: borderColor,\n\t} );\n\tconst { color: borderTopColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.top?.color ),\n\t} );\n\tconst { color: borderRightColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.right?.color ),\n\t} );\n\n\tconst { color: borderBottomColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.bottom?.color ),\n\t} );\n\tconst { color: borderLeftColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.left?.color ),\n\t} );\n\n\tconst extraStyles = {\n\t\tborderTopColor: borderTopColor || borderColorValue,\n\t\tborderRightColor: borderRightColor || borderColorValue,\n\t\tborderBottomColor: borderBottomColor || borderColorValue,\n\t\tborderLeftColor: borderLeftColor || borderColorValue,\n\t};\n\n\treturn addSaveProps(\n\t\t{ style: cleanEmptyObject( extraStyles ) || {} },\n\t\tname,\n\t\t{ borderColor, style }\n\t);\n}\n\nexport default {\n\tuseBlockProps,\n\taddSaveProps,\n\tattributeKeys: [ 'borderColor', 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBorderSupport( name, 'color' );\n\t},\n};\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addAttributes',\n\taddAttributes\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,eAAe,EAAEC,eAAe,QAAQ,mBAAmB;AACpE,SAASC,6BAA6B,IAAIC,eAAe,QAAQ,uBAAuB;AACxF,SAASC,QAAQ,EAAEC,WAAW,EAAEC,OAAO,QAAQ,oBAAoB;AACnE,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,OAAOC,iBAAiB,MAAM,kCAAkC;AAChE,OAAOC,mCAAmC,MAAM,yEAAyE;AACzH,SACCC,gBAAgB,EAChBC,uBAAuB,EACvBC,gBAAgB,QACV,SAAS;AAChB,SACCC,iBAAiB,EACjBC,yBAAyB,EACzBC,WAAW,IAAIC,iBAAiB,QAC1B,6BAA6B;AACpC,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,UAAU;AACpD,SAASC,EAAE,QAAQ,iBAAiB;AAEpC,OAAO,MAAMC,kBAAkB,GAAG,sBAAsB;AACxD,OAAO,MAAMC,kBAAkB,GAAG,QAAQ;AAE1C,MAAMC,kBAAkB,GAAGA,CAAEC,MAAM,EAAEC,QAAQ,EAAEC,KAAK,KAAM;EACzD,IAAIC,YAAY;EAEhBH,MAAM,CAACI,IAAI,CAAIC,MAAM,IACpBA,MAAM,CAACL,MAAM,CAACI,IAAI,CAAIE,KAAK,IAAM;IAChC,IAAKA,KAAK,CAAEL,QAAQ,CAAE,KAAKC,KAAK,EAAG;MAClCC,YAAY,GAAGG,KAAK;MACpB,OAAO,IAAI;IACZ;IAE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AC,GAAG1E,mBAAmB,CAAE;IACzDP,MAAM;IACNQ,UAAU,EAAEI,wBAAwB,CAAEG,KAAK,EAAEC,MAAM,EAAEkE,MAAM,EAAE5E,KAAM;EACpE,CAAE,CAAC;EACH,MAAM;IAAEA,KAAK,EAAE6E;EAAgB,CAAC,GAAG5E,mBAAmB,CAAE;IACvDP,MAAM;IACNQ,UAAU,EAAEI,wBAAwB,CAAEG,KAAK,EAAEC,MAAM,EAAEoE,IAAI,EAAE9E,KAAM;EAClE,CAAE,CAAC;EAEH,MAAM+E,WAAW,GAAG;IACnBR,cAAc,EAAEA,cAAc,IAAI3D,gBAAgB;IAClD6D,gBAAgB,EAAEA,gBAAgB,IAAI7D,gBAAgB;IACtD+D,iBAAiB,EAAEA,iBAAiB,IAAI/D,gBAAgB;IACxDiE,eAAe,EAAEA,eAAe,IAAIjE;EACrC,CAAC;EAED,OAAOkD,YAAY,CAClB;IAAErD,KAAK,EAAE5B,gBAAgB,CAAEkG,WAAY,CAAC,IAAI,CAAC;EAAE,CAAC,EAChDlD,IAAI,EACJ;IAAElB,WAAW;IAAEF;EAAM,CACtB,CAAC;AACF;AAEA,eAAe;EACd6D,aAAa;EACbR,YAAY;EACZkB,aAAa,EAAE,CAAE,aAAa,EAAE,OAAO,CAAE;EACzCC,UAAUA,CAAEpD,IAAI,EAAG;IAClB,OAAOY,gBAAgB,CAAEZ,IAAI,EAAE,OAAQ,CAAC;EACzC;AACD,CAAC;AAEDrD,SAAS,CACR,0BAA0B,EAC1B,2BAA2B,EAC3BoF,aACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["clsx","hasBlockSupport","getBlockSupport","__experimentalHasSplitBorders","hasSplitBorders","Platform","useCallback","useMemo","addFilter","useSelect","getColorClassName","InspectorControls","useMultipleOriginColorsAndGradients","cleanEmptyObject","shouldSkipSerialization","useBlockSettings","useHasBorderPanel","useHasBorderPanelControls","BorderPanel","StylesBorderPanel","store","blockEditorStore","__","BORDER_SUPPORT_KEY","SHADOW_SUPPORT_KEY","getColorByProperty","colors","property","value","matchedColor","some","origin","color","getMultiOriginColor","namedColor","customColor","colorObject","undefined","getColorSlugFromVariable","exec","styleToAttributes","style","border","borderColor","borderColorValue","borderColorSlug","startsWith","substring","length","updatedStyle","attributesToStyle","attributes","BordersInspectorControl","label","children","resetAllFilter","attributesResetAllFilter","existingStyle","createElement","group","clientId","name","setAttributes","settings","isEnabled","selector","select","getBlockAttributes","onChange","newStyle","defaultControls","as","panelId","hasBorderSupport","blockName","feature","OS","support","radius","width","hasShadowSupport","useBorderPanelLabel","hasBorderControl","hasShadowControl","controls","hasBorderColor","hasBorderStyle","hasBorderWidth","hasBorderRadius","hasShadow","removeBorderAttribute","attribute","addAttributes","type","addSaveProps","props","blockNameOrType","borderClasses","getBorderClasses","newClassName","className","borderColorClass","useBlockProps","borderTopColor","top","borderRightColor","right","borderBottomColor","bottom","borderLeftColor","left","extraStyles","attributeKeys","hasSupport"],"sources":["@wordpress/block-editor/src/hooks/border.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { hasBlockSupport, getBlockSupport } from '@wordpress/blocks';\nimport { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/components';\nimport { Platform, useCallback, useMemo } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { getColorClassName } from '../components/colors';\nimport InspectorControls from '../components/inspector-controls';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport {\n\tcleanEmptyObject,\n\tshouldSkipSerialization,\n\tuseBlockSettings,\n} from './utils';\nimport {\n\tuseHasBorderPanel,\n\tuseHasBorderPanelControls,\n\tBorderPanel as StylesBorderPanel,\n} from '../components/global-styles';\nimport { store as blockEditorStore } from '../store';\nimport { __ } from '@wordpress/i18n';\n\nexport const BORDER_SUPPORT_KEY = '__experimentalBorder';\nexport const SHADOW_SUPPORT_KEY = 'shadow';\n\nconst getColorByProperty = ( colors, property, value ) => {\n\tlet matchedColor;\n\n\tcolors.some( ( origin ) =>\n\t\torigin.colors.some( ( color ) => {\n\t\t\tif ( color[ property ] === value ) {\n\t\t\t\tmatchedColor = color;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t} )\n\t);\n\n\treturn matchedColor;\n};\n\nexport const getMultiOriginColor = ( { colors, namedColor, customColor } ) => {\n\t// Search each origin (default, theme, or user) for matching color by name.\n\tif ( namedColor ) {\n\t\tconst colorObject = getColorByProperty( colors, 'slug', namedColor );\n\t\tif ( colorObject ) {\n\t\t\treturn colorObject;\n\t\t}\n\t}\n\n\t// Skip if no custom color or matching named color.\n\tif ( ! customColor ) {\n\t\treturn { color: undefined };\n\t}\n\n\t// Attempt to find color via custom color value or build new object.\n\tconst colorObject = getColorByProperty( colors, 'color', customColor );\n\treturn colorObject ? colorObject : { color: customColor };\n};\n\nfunction getColorSlugFromVariable( value ) {\n\tconst namedColor = /var:preset\\|color\\|(.+)/.exec( value );\n\tif ( namedColor && namedColor[ 1 ] ) {\n\t\treturn namedColor[ 1 ];\n\t}\n\treturn null;\n}\n\nfunction styleToAttributes( style ) {\n\tif ( hasSplitBorders( style?.border ) ) {\n\t\treturn {\n\t\t\tstyle,\n\t\t\tborderColor: undefined,\n\t\t};\n\t}\n\n\tconst borderColorValue = style?.border?.color;\n\tconst borderColorSlug = borderColorValue?.startsWith( 'var:preset|color|' )\n\t\t? borderColorValue.substring( 'var:preset|color|'.length )\n\t\t: undefined;\n\tconst updatedStyle = { ...style };\n\tupdatedStyle.border = {\n\t\t...updatedStyle.border,\n\t\tcolor: borderColorSlug ? undefined : borderColorValue,\n\t};\n\treturn {\n\t\tstyle: cleanEmptyObject( updatedStyle ),\n\t\tborderColor: borderColorSlug,\n\t};\n}\n\nfunction attributesToStyle( attributes ) {\n\tif ( hasSplitBorders( attributes.style?.border ) ) {\n\t\treturn attributes.style;\n\t}\n\treturn {\n\t\t...attributes.style,\n\t\tborder: {\n\t\t\t...attributes.style?.border,\n\t\t\tcolor: attributes.borderColor\n\t\t\t\t? 'var:preset|color|' + attributes.borderColor\n\t\t\t\t: attributes.style?.border?.color,\n\t\t},\n\t};\n}\n\nfunction BordersInspectorControl( { label, children, resetAllFilter } ) {\n\tconst attributesResetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst existingStyle = attributesToStyle( attributes );\n\t\t\tconst updatedStyle = resetAllFilter( existingStyle );\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\t...styleToAttributes( updatedStyle ),\n\t\t\t};\n\t\t},\n\t\t[ resetAllFilter ]\n\t);\n\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"border\"\n\t\t\tresetAllFilter={ attributesResetAllFilter }\n\t\t\tlabel={ label }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BorderPanel( { clientId, name, setAttributes, settings } ) {\n\tconst isEnabled = useHasBorderPanel( settings );\n\tfunction selector( select ) {\n\t\tconst { style, borderColor } =\n\t\t\tselect( blockEditorStore ).getBlockAttributes( clientId ) || {};\n\t\treturn { style, borderColor };\n\t}\n\tconst { style, borderColor } = useSelect( selector, [ clientId ] );\n\tconst value = useMemo( () => {\n\t\treturn attributesToStyle( { style, borderColor } );\n\t}, [ style, borderColor ] );\n\n\tconst onChange = ( newStyle ) => {\n\t\tsetAttributes( styleToAttributes( newStyle ) );\n\t};\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultControls = {\n\t\t...getBlockSupport( name, [\n\t\t\tBORDER_SUPPORT_KEY,\n\t\t\t'__experimentalDefaultControls',\n\t\t] ),\n\t\t...getBlockSupport( name, [\n\t\t\tSHADOW_SUPPORT_KEY,\n\t\t\t'__experimentalDefaultControls',\n\t\t] ),\n\t};\n\n\treturn (\n\t\t<StylesBorderPanel\n\t\t\tas={ BordersInspectorControl }\n\t\t\tpanelId={ clientId }\n\t\t\tsettings={ settings }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t/>\n\t);\n}\n\n/**\n * Determine whether there is block support for border properties.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Border feature to check support for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBorderSupport( blockName, feature = 'any' ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst support = getBlockSupport( blockName, BORDER_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn !! (\n\t\t\tsupport?.color ||\n\t\t\tsupport?.radius ||\n\t\t\tsupport?.width ||\n\t\t\tsupport?.style\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\n/**\n * Determine whether there is block support for shadow properties.\n *\n * @param {string} blockName Block name.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasShadowSupport( blockName ) {\n\treturn hasBlockSupport( blockName, SHADOW_SUPPORT_KEY );\n}\n\nexport function useBorderPanelLabel( {\n\tblockName,\n\thasBorderControl,\n\thasShadowControl,\n} = {} ) {\n\tconst settings = useBlockSettings( blockName );\n\tconst controls = useHasBorderPanelControls( settings );\n\n\tif ( ! hasBorderControl && ! hasShadowControl && blockName ) {\n\t\thasBorderControl =\n\t\t\tcontrols?.hasBorderColor ||\n\t\t\tcontrols?.hasBorderStyle ||\n\t\t\tcontrols?.hasBorderWidth ||\n\t\t\tcontrols?.hasBorderRadius;\n\t\thasShadowControl = controls?.hasShadow;\n\t}\n\n\tif ( hasBorderControl && hasShadowControl ) {\n\t\treturn __( 'Border & Shadow' );\n\t}\n\n\tif ( hasShadowControl ) {\n\t\treturn __( 'Shadow' );\n\t}\n\n\treturn __( 'Border' );\n}\n\n/**\n * Returns a new style object where the specified border attribute has been\n * removed.\n *\n * @param {Object} style Styles from block attributes.\n * @param {string} attribute The border style attribute to clear.\n *\n * @return {Object} Style object with the specified attribute removed.\n */\nexport function removeBorderAttribute( style, attribute ) {\n\treturn cleanEmptyObject( {\n\t\t...style,\n\t\tborder: {\n\t\t\t...style?.border,\n\t\t\t[ attribute ]: undefined,\n\t\t},\n\t} );\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * `borderColor` if needed.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Updated block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBorderSupport( settings, 'color' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify default value if needed.\n\tif ( settings.attributes.borderColor ) {\n\t\treturn settings;\n\t}\n\n\t// Add new borderColor attribute to block settings.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tborderColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Override props assigned to save component to inject border color.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object|string} blockNameOrType Block type definition.\n * @param {Object} attributes Block's attributes.\n *\n * @return {Object} Filtered props to apply to save element.\n */\nfunction addSaveProps( props, blockNameOrType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockNameOrType, 'color' ) ||\n\t\tshouldSkipSerialization( blockNameOrType, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst borderClasses = getBorderClasses( attributes );\n\tconst newClassName = clsx( props.className, borderClasses );\n\n\t// If we are clearing the last of the previous classes in `className`\n\t// set it to `undefined` to avoid rendering empty DOM attributes.\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Generates a CSS class name consisting of all the applicable border color\n * classes given the current block attributes.\n *\n * @param {Object} attributes Block's attributes.\n *\n * @return {string} CSS class name.\n */\nexport function getBorderClasses( attributes ) {\n\tconst { borderColor, style } = attributes;\n\tconst borderColorClass = getColorClassName( 'border-color', borderColor );\n\n\treturn clsx( {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\n}\n\nfunction useBlockProps( { name, borderColor, style } ) {\n\tconst { colors } = useMultipleOriginColorsAndGradients();\n\n\tif (\n\t\t! hasBorderSupport( name, 'color' ) ||\n\t\tshouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn {};\n\t}\n\n\tconst { color: borderColorValue } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: borderColor,\n\t} );\n\tconst { color: borderTopColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.top?.color ),\n\t} );\n\tconst { color: borderRightColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.right?.color ),\n\t} );\n\n\tconst { color: borderBottomColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.bottom?.color ),\n\t} );\n\tconst { color: borderLeftColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.left?.color ),\n\t} );\n\n\tconst extraStyles = {\n\t\tborderTopColor: borderTopColor || borderColorValue,\n\t\tborderRightColor: borderRightColor || borderColorValue,\n\t\tborderBottomColor: borderBottomColor || borderColorValue,\n\t\tborderLeftColor: borderLeftColor || borderColorValue,\n\t};\n\n\treturn addSaveProps(\n\t\t{ style: cleanEmptyObject( extraStyles ) || {} },\n\t\tname,\n\t\t{ borderColor, style }\n\t);\n}\n\nexport default {\n\tuseBlockProps,\n\taddSaveProps,\n\tattributeKeys: [ 'borderColor', 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBorderSupport( name, 'color' );\n\t},\n};\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addAttributes',\n\taddAttributes\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;A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,EAAEC,MAAM,EAAEoE,IAAI,EAAE9E,KAAM;EAClE,CAAE,CAAC;EAEH,MAAM+E,WAAW,GAAG;IACnBR,cAAc,EAAEA,cAAc,IAAI3D,gBAAgB;IAClD6D,gBAAgB,EAAEA,gBAAgB,IAAI7D,gBAAgB;IACtD+D,iBAAiB,EAAEA,iBAAiB,IAAI/D,gBAAgB;IACxDiE,eAAe,EAAEA,eAAe,IAAIjE;EACrC,CAAC;EAED,OAAOkD,YAAY,CAClB;IAAErD,KAAK,EAAE5B,gBAAgB,CAAEkG,WAAY,CAAC,IAAI,CAAC;EAAE,CAAC,EAChDlD,IAAI,EACJ;IAAElB,WAAW;IAAEF;EAAM,CACtB,CAAC;AACF;AAEA,eAAe;EACd6D,aAAa;EACbR,YAAY;EACZkB,aAAa,EAAE,CAAE,aAAa,EAAE,OAAO,CAAE;EACzCC,UAAUA,CAAEpD,IAAI,EAAG;IAClB,OAAOY,gBAAgB,CAAEZ,IAAI,EAAE,OAAQ,CAAC;EACzC;AACD,CAAC;AAEDrD,SAAS,CACR,0BAA0B,EAC1B,2BAA2B,EAC3BoF,aACD,CAAC","ignoreList":[]}
@@ -2,7 +2,7 @@ import { createElement } from "react";
2
2
  /**
3
3
  * External dependencies
4
4
  */
5
- import classnames from 'classnames';
5
+ import clsx from 'clsx';
6
6
 
7
7
  /**
8
8
  * WordPress dependencies
@@ -119,7 +119,7 @@ export function addSaveProps(props, blockNameOrType, attributes) {
119
119
  const backgroundClass = shouldSerialize('background') ? getColorClassName('background-color', backgroundColor) : undefined;
120
120
  const serializeHasBackground = shouldSerialize('background') || shouldSerialize('gradients');
121
121
  const hasBackground = backgroundColor || style?.color?.background || hasGradient && (gradient || style?.color?.gradient);
122
- const newClassName = classnames(props.className, textClass, gradientClass, {
122
+ const newClassName = clsx(props.className, textClass, gradientClass, {
123
123
  // Don't apply the background class if there's a custom gradient.
124
124
  [backgroundClass]: (!hasGradient || !style?.color?.gradient) && !!backgroundClass,
125
125
  'has-text-color': shouldSerialize('text') && (textColor || style?.color?.text),
@@ -269,7 +269,7 @@ function useBlockProps({
269
269
  const hasBackgroundValue = backgroundColor || style?.color?.background || gradient || style?.color?.gradient;
270
270
  return {
271
271
  ...saveProps,
272
- className: classnames(saveProps.className,
272
+ className: clsx(saveProps.className,
273
273
  // Add background image classes in the editor, if not already handled by background color values.
274
274
  !hasBackgroundValue && getBackgroundImageClasses(style))
275
275
  };