@wordpress/block-editor 14.0.0 → 14.2.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 (807) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +10 -24
  3. package/build/autocompleters/block.js +1 -1
  4. package/build/autocompleters/block.js.map +1 -1
  5. package/build/components/block-alignment-matrix-control/index.js +2 -2
  6. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  7. package/build/components/block-breadcrumb/index.js +8 -2
  8. package/build/components/block-breadcrumb/index.js.map +1 -1
  9. package/build/components/block-canvas/index.js +8 -1
  10. package/build/components/block-canvas/index.js.map +1 -1
  11. package/build/components/block-compare/block-view.js +4 -1
  12. package/build/components/block-compare/block-view.js.map +1 -1
  13. package/build/components/block-draggable/index.js +4 -4
  14. package/build/components/block-draggable/index.js.map +1 -1
  15. package/build/components/block-draggable/use-scroll-when-dragging.js +25 -25
  16. package/build/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
  17. package/build/components/block-edit/multiple-usage-warning.js +8 -2
  18. package/build/components/block-edit/multiple-usage-warning.js.map +1 -1
  19. package/build/components/block-inspector/index.js +27 -9
  20. package/build/components/block-inspector/index.js.map +1 -1
  21. package/build/components/block-list/block-invalid-warning.js +6 -3
  22. package/build/components/block-list/block-invalid-warning.js.map +1 -1
  23. package/build/components/block-list/block.js +5 -1
  24. package/build/components/block-list/block.js.map +1 -1
  25. package/build/components/block-list/use-block-props/index.js +7 -3
  26. package/build/components/block-list/use-block-props/index.js.map +1 -1
  27. package/build/components/block-list/use-block-props/use-focus-first-element.js +1 -0
  28. package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  29. package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js +46 -0
  30. package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -0
  31. package/build/components/block-list/use-in-between-inserter.js +11 -4
  32. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  33. package/build/components/block-lock/toolbar.js +3 -3
  34. package/build/components/block-lock/toolbar.js.map +1 -1
  35. package/build/components/block-mover/button.js +4 -1
  36. package/build/components/block-mover/button.js.map +1 -1
  37. package/build/components/block-mover/index.js +4 -1
  38. package/build/components/block-mover/index.js.map +1 -1
  39. package/build/components/block-navigation/dropdown.js +4 -1
  40. package/build/components/block-navigation/dropdown.js.map +1 -1
  41. package/build/components/block-pattern-setup/index.js +1 -4
  42. package/build/components/block-pattern-setup/index.js.map +1 -1
  43. package/build/components/block-pattern-setup/setup-toolbar.js +22 -7
  44. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  45. package/build/components/block-patterns-list/index.js +11 -14
  46. package/build/components/block-patterns-list/index.js.map +1 -1
  47. package/build/components/block-patterns-paging/index.js +12 -3
  48. package/build/components/block-patterns-paging/index.js.map +1 -1
  49. package/build/components/block-popover/index.js +2 -15
  50. package/build/components/block-popover/index.js.map +1 -1
  51. package/build/components/block-quick-navigation/index.js +4 -1
  52. package/build/components/block-quick-navigation/index.js.map +1 -1
  53. package/build/components/block-settings-menu/block-mode-toggle.js +28 -34
  54. package/build/components/block-settings-menu/block-mode-toggle.js.map +1 -1
  55. package/build/components/block-settings-menu-controls/index.js +4 -0
  56. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  57. package/build/components/block-switcher/index.js +22 -17
  58. package/build/components/block-switcher/index.js.map +1 -1
  59. package/build/components/block-switcher/pattern-transformations-menu.js +1 -4
  60. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  61. package/build/components/block-toolbar/index.js +12 -11
  62. package/build/components/block-toolbar/index.js.map +1 -1
  63. package/build/components/block-toolbar/shuffle.js +6 -2
  64. package/build/components/block-toolbar/shuffle.js.map +1 -1
  65. package/build/components/block-tools/block-selection-button.js +8 -2
  66. package/build/components/block-tools/block-selection-button.js.map +1 -1
  67. package/build/components/block-tools/block-toolbar-popover.js +10 -6
  68. package/build/components/block-tools/block-toolbar-popover.js.map +1 -1
  69. package/build/components/block-tools/insertion-point.js +14 -3
  70. package/build/components/block-tools/insertion-point.js.map +1 -1
  71. package/build/components/block-tools/use-block-toolbar-popover-props.js +2 -1
  72. package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  73. package/build/components/block-tools/use-show-block-tools.js +2 -1
  74. package/build/components/block-tools/use-show-block-tools.js.map +1 -1
  75. package/build/components/block-tools/zoom-out-mode-inserters.js +4 -5
  76. package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  77. package/build/components/block-tools/zoom-out-popover.js +3 -4
  78. package/build/components/block-tools/zoom-out-popover.js.map +1 -1
  79. package/build/components/block-tools/zoom-out-toolbar.js +14 -5
  80. package/build/components/block-tools/zoom-out-toolbar.js.map +1 -1
  81. package/build/components/block-variation-picker/index.js +4 -1
  82. package/build/components/block-variation-picker/index.js.map +1 -1
  83. package/build/components/block-variation-transforms/index.js +4 -1
  84. package/build/components/block-variation-transforms/index.js.map +1 -1
  85. package/build/components/border-radius-control/index.js +1 -0
  86. package/build/components/border-radius-control/index.js.map +1 -1
  87. package/build/components/button-block-appender/index.js +14 -3
  88. package/build/components/button-block-appender/index.js.map +1 -1
  89. package/build/components/colors-gradients/dropdown.js +4 -1
  90. package/build/components/colors-gradients/dropdown.js.map +1 -1
  91. package/build/components/content-lock/index.js +13 -0
  92. package/build/components/content-lock/index.js.map +1 -0
  93. package/build/components/content-lock/modify-content-lock-menu-item.js +64 -0
  94. package/build/components/content-lock/modify-content-lock-menu-item.js.map +1 -0
  95. package/build/components/convert-to-group-buttons/index.js +1 -1
  96. package/build/components/convert-to-group-buttons/index.js.map +1 -1
  97. package/build/components/date-format-picker/index.js +2 -0
  98. package/build/components/date-format-picker/index.js.map +1 -1
  99. package/build/components/editor-styles/index.js +4 -3
  100. package/build/components/editor-styles/index.js.map +1 -1
  101. package/build/components/font-appearance-control/index.js +3 -0
  102. package/build/components/font-appearance-control/index.js.map +1 -1
  103. package/build/components/font-family/index.js +3 -0
  104. package/build/components/font-family/index.js.map +1 -1
  105. package/build/components/global-styles/background-panel.js +118 -50
  106. package/build/components/global-styles/background-panel.js.map +1 -1
  107. package/build/components/global-styles/color-panel.js +8 -5
  108. package/build/components/global-styles/color-panel.js.map +1 -1
  109. package/build/components/global-styles/color-panel.native.js +1 -1
  110. package/build/components/global-styles/color-panel.native.js.map +1 -1
  111. package/build/components/global-styles/dimensions-panel.js +34 -37
  112. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  113. package/build/components/global-styles/filters-panel.js +4 -1
  114. package/build/components/global-styles/filters-panel.js.map +1 -1
  115. package/build/components/global-styles/get-global-styles-changes.js +3 -1
  116. package/build/components/global-styles/get-global-styles-changes.js.map +1 -1
  117. package/build/components/global-styles/hooks.js +0 -7
  118. package/build/components/global-styles/hooks.js.map +1 -1
  119. package/build/components/global-styles/index.js +0 -6
  120. package/build/components/global-styles/index.js.map +1 -1
  121. package/build/components/global-styles/shadow-panel-components.js +13 -7
  122. package/build/components/global-styles/shadow-panel-components.js.map +1 -1
  123. package/build/components/global-styles/typography-utils.js +17 -6
  124. package/build/components/global-styles/typography-utils.js.map +1 -1
  125. package/build/components/global-styles/use-global-styles-output.js +3 -3
  126. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  127. package/build/components/global-styles/utils.js +11 -29
  128. package/build/components/global-styles/utils.js.map +1 -1
  129. package/build/components/grid/grid-item-movers.js +2 -2
  130. package/build/components/grid/grid-item-movers.js.map +1 -1
  131. package/build/components/grid/grid-visualizer.js +20 -5
  132. package/build/components/grid/grid-visualizer.js.map +1 -1
  133. package/build/components/height-control/index.js +1 -0
  134. package/build/components/height-control/index.js.map +1 -1
  135. package/build/components/iframe/index.js +8 -6
  136. package/build/components/iframe/index.js.map +1 -1
  137. package/build/components/image-editor/zoom-dropdown.js +11 -7
  138. package/build/components/image-editor/zoom-dropdown.js.map +1 -1
  139. package/build/components/inner-blocks/button-block-appender.js +8 -8
  140. package/build/components/inner-blocks/button-block-appender.js.map +1 -1
  141. package/build/components/inner-blocks/default-block-appender.js +7 -25
  142. package/build/components/inner-blocks/default-block-appender.js.map +1 -1
  143. package/build/components/inner-blocks/index.js +8 -12
  144. package/build/components/inner-blocks/index.js.map +1 -1
  145. package/build/components/inner-blocks/use-inner-block-template-sync.js +3 -3
  146. package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  147. package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +4 -1
  148. package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -1
  149. package/build/components/inserter/block-patterns-tab/index.js +4 -1
  150. package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
  151. package/build/components/inserter/media-tab/hooks.js +3 -3
  152. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  153. package/build/components/inserter/media-tab/media-list.js +1 -4
  154. package/build/components/inserter/media-tab/media-list.js.map +1 -1
  155. package/build/components/inserter/media-tab/media-preview.js +8 -2
  156. package/build/components/inserter/media-tab/media-preview.js.map +1 -1
  157. package/build/components/inserter/media-tab/media-tab.js +4 -1
  158. package/build/components/inserter/media-tab/media-tab.js.map +1 -1
  159. package/build/components/inserter/menu.js +14 -13
  160. package/build/components/inserter/menu.js.map +1 -1
  161. package/build/components/inserter/quick-inserter.js +8 -1
  162. package/build/components/inserter/quick-inserter.js.map +1 -1
  163. package/build/components/inserter-list-item/index.js +4 -4
  164. package/build/components/inserter-list-item/index.js.map +1 -1
  165. package/build/components/inserter-listbox/index.js +3 -7
  166. package/build/components/inserter-listbox/index.js.map +1 -1
  167. package/build/components/inserter-listbox/item.js +4 -1
  168. package/build/components/inserter-listbox/item.js.map +1 -1
  169. package/build/components/inspector-controls/groups.js +2 -0
  170. package/build/components/inspector-controls/groups.js.map +1 -1
  171. package/build/components/inspector-controls-tabs/index.js +4 -1
  172. package/build/components/inspector-controls-tabs/index.js.map +1 -1
  173. package/build/components/inspector-controls-tabs/settings-tab.js +3 -1
  174. package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  175. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +2 -1
  176. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  177. package/build/components/inspector-popover-header/index.js +8 -2
  178. package/build/components/inspector-popover-header/index.js.map +1 -1
  179. package/build/components/letter-spacing-control/index.js +7 -4
  180. package/build/components/letter-spacing-control/index.js.map +1 -1
  181. package/build/components/line-height-control/index.js +3 -0
  182. package/build/components/line-height-control/index.js.map +1 -1
  183. package/build/components/link-control/index.js +19 -10
  184. package/build/components/link-control/index.js.map +1 -1
  185. package/build/components/link-control/settings-drawer.js +4 -1
  186. package/build/components/link-control/settings-drawer.js.map +1 -1
  187. package/build/components/list-view/block-select-button.js +4 -1
  188. package/build/components/list-view/block-select-button.js.map +1 -1
  189. package/build/components/media-placeholder/index.js +36 -10
  190. package/build/components/media-placeholder/index.js.map +1 -1
  191. package/build/components/media-replace-flow/index.js +8 -1
  192. package/build/components/media-replace-flow/index.js.map +1 -1
  193. package/build/components/media-upload/index.native.js +4 -1
  194. package/build/components/media-upload/index.native.js.map +1 -1
  195. package/build/components/multi-selection-inspector/index.js +12 -12
  196. package/build/components/multi-selection-inspector/index.js.map +1 -1
  197. package/build/components/provider/use-block-sync.js +19 -19
  198. package/build/components/provider/use-block-sync.js.map +1 -1
  199. package/build/components/rich-text/event-listeners/paste-handler.js +12 -1
  200. package/build/components/rich-text/event-listeners/paste-handler.js.map +1 -1
  201. package/build/components/rich-text/index.js +38 -30
  202. package/build/components/rich-text/index.js.map +1 -1
  203. package/build/components/rich-text/use-mark-persistent.js +5 -5
  204. package/build/components/rich-text/use-mark-persistent.js.map +1 -1
  205. package/build/components/skip-to-selected-block/index.js +4 -1
  206. package/build/components/skip-to-selected-block/index.js.map +1 -1
  207. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +4 -2
  208. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  209. package/build/components/text-alignment-control/index.js +13 -8
  210. package/build/components/text-alignment-control/index.js.map +1 -1
  211. package/build/components/text-decoration-control/index.js +13 -8
  212. package/build/components/text-decoration-control/index.js.map +1 -1
  213. package/build/components/text-transform-control/index.js +13 -8
  214. package/build/components/text-transform-control/index.js.map +1 -1
  215. package/build/components/tool-selector/index.js +4 -1
  216. package/build/components/tool-selector/index.js.map +1 -1
  217. package/build/components/url-input/button.js +12 -3
  218. package/build/components/url-input/button.js.map +1 -1
  219. package/build/components/url-input/index.js +4 -1
  220. package/build/components/url-input/index.js.map +1 -1
  221. package/build/components/url-popover/image-url-input-ui.js +2 -0
  222. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  223. package/build/components/use-block-drop-zone/index.js +12 -2
  224. package/build/components/use-block-drop-zone/index.js.map +1 -1
  225. package/build/components/writing-flow/index.js +2 -1
  226. package/build/components/writing-flow/index.js.map +1 -1
  227. package/build/components/writing-flow/use-arrow-nav.js +4 -1
  228. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  229. package/build/components/writing-flow/use-event-redirect.js +66 -0
  230. package/build/components/writing-flow/use-event-redirect.js.map +1 -0
  231. package/build/components/writing-flow/use-input.js +31 -1
  232. package/build/components/writing-flow/use-input.js.map +1 -1
  233. package/build/components/writing-flow/use-select-all.js +14 -1
  234. package/build/components/writing-flow/use-select-all.js.map +1 -1
  235. package/build/components/writing-flow/use-selection-observer.js +20 -6
  236. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  237. package/build/components/writing-flow/use-tab-nav.js +4 -4
  238. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  239. package/build/components/writing-flow/utils.js +27 -0
  240. package/build/components/writing-flow/utils.js.map +1 -1
  241. package/build/components/writing-mode-control/index.js +13 -8
  242. package/build/components/writing-mode-control/index.js.map +1 -1
  243. package/build/hooks/background.js +19 -23
  244. package/build/hooks/background.js.map +1 -1
  245. package/build/hooks/block-bindings.js +64 -103
  246. package/build/hooks/block-bindings.js.map +1 -1
  247. package/build/hooks/content-lock-ui.js +8 -26
  248. package/build/hooks/content-lock-ui.js.map +1 -1
  249. package/build/hooks/duotone.js +0 -4
  250. package/build/hooks/duotone.js.map +1 -1
  251. package/build/hooks/layout.js +4 -1
  252. package/build/hooks/layout.js.map +1 -1
  253. package/build/hooks/spacing-visualizer.js +3 -3
  254. package/build/hooks/spacing-visualizer.js.map +1 -1
  255. package/build/hooks/style.js +1 -5
  256. package/build/hooks/style.js.map +1 -1
  257. package/build/hooks/use-bindings-attributes.js +19 -20
  258. package/build/hooks/use-bindings-attributes.js.map +1 -1
  259. package/build/hooks/use-zoom-out.js +7 -7
  260. package/build/hooks/use-zoom-out.js.map +1 -1
  261. package/build/layouts/constrained.js +42 -41
  262. package/build/layouts/constrained.js.map +1 -1
  263. package/build/layouts/flex.js +6 -1
  264. package/build/layouts/flex.js.map +1 -1
  265. package/build/layouts/grid.js +3 -0
  266. package/build/layouts/grid.js.map +1 -1
  267. package/build/layouts/utils.js +1 -7
  268. package/build/layouts/utils.js.map +1 -1
  269. package/build/private-apis.js +4 -1
  270. package/build/private-apis.js.map +1 -1
  271. package/build/store/actions.js +2 -7
  272. package/build/store/actions.js.map +1 -1
  273. package/build/store/private-actions.js +1 -0
  274. package/build/store/private-actions.js.map +1 -1
  275. package/build/store/private-keys.js +2 -1
  276. package/build/store/private-keys.js.map +1 -1
  277. package/build/store/private-selectors.js +39 -11
  278. package/build/store/private-selectors.js.map +1 -1
  279. package/build/store/reducer.js +2 -0
  280. package/build/store/reducer.js.map +1 -1
  281. package/build/store/selectors.js +19 -43
  282. package/build/store/selectors.js.map +1 -1
  283. package/build/store/utils.js +48 -0
  284. package/build/store/utils.js.map +1 -1
  285. package/build/utils/block-bindings.js +117 -0
  286. package/build/utils/block-bindings.js.map +1 -0
  287. package/build/utils/dom.js +101 -0
  288. package/build/utils/dom.js.map +1 -1
  289. package/build/utils/get-font-styles-and-weights.js +4 -4
  290. package/build/utils/get-font-styles-and-weights.js.map +1 -1
  291. package/build/utils/transform-styles/index.js +120 -16
  292. package/build/utils/transform-styles/index.js.map +1 -1
  293. package/build-module/autocompleters/block.js +1 -1
  294. package/build-module/autocompleters/block.js.map +1 -1
  295. package/build-module/components/block-alignment-matrix-control/index.js +1 -1
  296. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  297. package/build-module/components/block-breadcrumb/index.js +8 -2
  298. package/build-module/components/block-breadcrumb/index.js.map +1 -1
  299. package/build-module/components/block-canvas/index.js +9 -1
  300. package/build-module/components/block-canvas/index.js.map +1 -1
  301. package/build-module/components/block-compare/block-view.js +4 -1
  302. package/build-module/components/block-compare/block-view.js.map +1 -1
  303. package/build-module/components/block-draggable/index.js +4 -4
  304. package/build-module/components/block-draggable/index.js.map +1 -1
  305. package/build-module/components/block-draggable/use-scroll-when-dragging.js +25 -25
  306. package/build-module/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
  307. package/build-module/components/block-edit/multiple-usage-warning.js +8 -2
  308. package/build-module/components/block-edit/multiple-usage-warning.js.map +1 -1
  309. package/build-module/components/block-inspector/index.js +27 -9
  310. package/build-module/components/block-inspector/index.js.map +1 -1
  311. package/build-module/components/block-list/block-invalid-warning.js +6 -3
  312. package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
  313. package/build-module/components/block-list/block.js +5 -1
  314. package/build-module/components/block-list/block.js.map +1 -1
  315. package/build-module/components/block-list/use-block-props/index.js +7 -3
  316. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  317. package/build-module/components/block-list/use-block-props/use-focus-first-element.js +1 -0
  318. package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  319. package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js +40 -0
  320. package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -0
  321. package/build-module/components/block-list/use-in-between-inserter.js +11 -4
  322. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  323. package/build-module/components/block-lock/toolbar.js +3 -3
  324. package/build-module/components/block-lock/toolbar.js.map +1 -1
  325. package/build-module/components/block-mover/button.js +4 -1
  326. package/build-module/components/block-mover/button.js.map +1 -1
  327. package/build-module/components/block-mover/index.js +4 -1
  328. package/build-module/components/block-mover/index.js.map +1 -1
  329. package/build-module/components/block-navigation/dropdown.js +4 -1
  330. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  331. package/build-module/components/block-pattern-setup/index.js +1 -4
  332. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  333. package/build-module/components/block-pattern-setup/setup-toolbar.js +23 -8
  334. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  335. package/build-module/components/block-patterns-list/index.js +11 -14
  336. package/build-module/components/block-patterns-list/index.js.map +1 -1
  337. package/build-module/components/block-patterns-paging/index.js +12 -3
  338. package/build-module/components/block-patterns-paging/index.js.map +1 -1
  339. package/build-module/components/block-popover/index.js +2 -15
  340. package/build-module/components/block-popover/index.js.map +1 -1
  341. package/build-module/components/block-quick-navigation/index.js +4 -1
  342. package/build-module/components/block-quick-navigation/index.js.map +1 -1
  343. package/build-module/components/block-settings-menu/block-mode-toggle.js +29 -34
  344. package/build-module/components/block-settings-menu/block-mode-toggle.js.map +1 -1
  345. package/build-module/components/block-settings-menu-controls/index.js +4 -0
  346. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  347. package/build-module/components/block-switcher/index.js +22 -17
  348. package/build-module/components/block-switcher/index.js.map +1 -1
  349. package/build-module/components/block-switcher/pattern-transformations-menu.js +1 -4
  350. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  351. package/build-module/components/block-toolbar/index.js +12 -11
  352. package/build-module/components/block-toolbar/index.js.map +1 -1
  353. package/build-module/components/block-toolbar/shuffle.js +6 -2
  354. package/build-module/components/block-toolbar/shuffle.js.map +1 -1
  355. package/build-module/components/block-tools/block-selection-button.js +8 -2
  356. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  357. package/build-module/components/block-tools/block-toolbar-popover.js +10 -6
  358. package/build-module/components/block-tools/block-toolbar-popover.js.map +1 -1
  359. package/build-module/components/block-tools/insertion-point.js +14 -3
  360. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  361. package/build-module/components/block-tools/use-block-toolbar-popover-props.js +2 -1
  362. package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  363. package/build-module/components/block-tools/use-show-block-tools.js +2 -1
  364. package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
  365. package/build-module/components/block-tools/zoom-out-mode-inserters.js +4 -5
  366. package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  367. package/build-module/components/block-tools/zoom-out-popover.js +3 -4
  368. package/build-module/components/block-tools/zoom-out-popover.js.map +1 -1
  369. package/build-module/components/block-tools/zoom-out-toolbar.js +15 -6
  370. package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -1
  371. package/build-module/components/block-variation-picker/index.js +4 -1
  372. package/build-module/components/block-variation-picker/index.js.map +1 -1
  373. package/build-module/components/block-variation-transforms/index.js +4 -1
  374. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  375. package/build-module/components/border-radius-control/index.js +1 -0
  376. package/build-module/components/border-radius-control/index.js.map +1 -1
  377. package/build-module/components/button-block-appender/index.js +15 -4
  378. package/build-module/components/button-block-appender/index.js.map +1 -1
  379. package/build-module/components/colors-gradients/dropdown.js +4 -1
  380. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  381. package/build-module/components/content-lock/index.js +2 -0
  382. package/build-module/components/content-lock/index.js.map +1 -0
  383. package/build-module/components/content-lock/modify-content-lock-menu-item.js +57 -0
  384. package/build-module/components/content-lock/modify-content-lock-menu-item.js.map +1 -0
  385. package/build-module/components/convert-to-group-buttons/index.js +1 -1
  386. package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
  387. package/build-module/components/date-format-picker/index.js +2 -0
  388. package/build-module/components/date-format-picker/index.js.map +1 -1
  389. package/build-module/components/editor-styles/index.js +4 -3
  390. package/build-module/components/editor-styles/index.js.map +1 -1
  391. package/build-module/components/font-appearance-control/index.js +3 -0
  392. package/build-module/components/font-appearance-control/index.js.map +1 -1
  393. package/build-module/components/font-family/index.js +3 -0
  394. package/build-module/components/font-family/index.js.map +1 -1
  395. package/build-module/components/global-styles/background-panel.js +121 -53
  396. package/build-module/components/global-styles/background-panel.js.map +1 -1
  397. package/build-module/components/global-styles/color-panel.js +7 -4
  398. package/build-module/components/global-styles/color-panel.js.map +1 -1
  399. package/build-module/components/global-styles/color-panel.native.js +2 -2
  400. package/build-module/components/global-styles/color-panel.native.js.map +1 -1
  401. package/build-module/components/global-styles/dimensions-panel.js +36 -39
  402. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  403. package/build-module/components/global-styles/filters-panel.js +4 -1
  404. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  405. package/build-module/components/global-styles/get-global-styles-changes.js +3 -1
  406. package/build-module/components/global-styles/get-global-styles-changes.js.map +1 -1
  407. package/build-module/components/global-styles/hooks.js +0 -6
  408. package/build-module/components/global-styles/hooks.js.map +1 -1
  409. package/build-module/components/global-styles/index.js +1 -1
  410. package/build-module/components/global-styles/index.js.map +1 -1
  411. package/build-module/components/global-styles/shadow-panel-components.js +13 -7
  412. package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
  413. package/build-module/components/global-styles/typography-utils.js +17 -6
  414. package/build-module/components/global-styles/typography-utils.js.map +1 -1
  415. package/build-module/components/global-styles/use-global-styles-output.js +5 -5
  416. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  417. package/build-module/components/global-styles/utils.js +11 -28
  418. package/build-module/components/global-styles/utils.js.map +1 -1
  419. package/build-module/components/grid/grid-item-movers.js +3 -3
  420. package/build-module/components/grid/grid-item-movers.js.map +1 -1
  421. package/build-module/components/grid/grid-visualizer.js +20 -5
  422. package/build-module/components/grid/grid-visualizer.js.map +1 -1
  423. package/build-module/components/height-control/index.js +1 -0
  424. package/build-module/components/height-control/index.js.map +1 -1
  425. package/build-module/components/iframe/index.js +8 -6
  426. package/build-module/components/iframe/index.js.map +1 -1
  427. package/build-module/components/image-editor/zoom-dropdown.js +12 -8
  428. package/build-module/components/image-editor/zoom-dropdown.js.map +1 -1
  429. package/build-module/components/inner-blocks/button-block-appender.js +7 -6
  430. package/build-module/components/inner-blocks/button-block-appender.js.map +1 -1
  431. package/build-module/components/inner-blocks/default-block-appender.js +6 -23
  432. package/build-module/components/inner-blocks/default-block-appender.js.map +1 -1
  433. package/build-module/components/inner-blocks/index.js +8 -12
  434. package/build-module/components/inner-blocks/index.js.map +1 -1
  435. package/build-module/components/inner-blocks/use-inner-block-template-sync.js +3 -3
  436. package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  437. package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +4 -1
  438. package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -1
  439. package/build-module/components/inserter/block-patterns-tab/index.js +4 -1
  440. package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
  441. package/build-module/components/inserter/media-tab/hooks.js +3 -3
  442. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  443. package/build-module/components/inserter/media-tab/media-list.js +1 -4
  444. package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
  445. package/build-module/components/inserter/media-tab/media-preview.js +8 -2
  446. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
  447. package/build-module/components/inserter/media-tab/media-tab.js +4 -1
  448. package/build-module/components/inserter/media-tab/media-tab.js.map +1 -1
  449. package/build-module/components/inserter/menu.js +14 -13
  450. package/build-module/components/inserter/menu.js.map +1 -1
  451. package/build-module/components/inserter/quick-inserter.js +9 -2
  452. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  453. package/build-module/components/inserter-list-item/index.js +4 -4
  454. package/build-module/components/inserter-list-item/index.js.map +1 -1
  455. package/build-module/components/inserter-listbox/index.js +3 -7
  456. package/build-module/components/inserter-listbox/index.js.map +1 -1
  457. package/build-module/components/inserter-listbox/item.js +4 -1
  458. package/build-module/components/inserter-listbox/item.js.map +1 -1
  459. package/build-module/components/inspector-controls/groups.js +2 -0
  460. package/build-module/components/inspector-controls/groups.js.map +1 -1
  461. package/build-module/components/inspector-controls-tabs/index.js +4 -1
  462. package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
  463. package/build-module/components/inspector-controls-tabs/settings-tab.js +3 -1
  464. package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  465. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +2 -1
  466. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  467. package/build-module/components/inspector-popover-header/index.js +8 -2
  468. package/build-module/components/inspector-popover-header/index.js.map +1 -1
  469. package/build-module/components/letter-spacing-control/index.js +7 -4
  470. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  471. package/build-module/components/line-height-control/index.js +3 -0
  472. package/build-module/components/line-height-control/index.js.map +1 -1
  473. package/build-module/components/link-control/index.js +19 -10
  474. package/build-module/components/link-control/index.js.map +1 -1
  475. package/build-module/components/link-control/settings-drawer.js +4 -1
  476. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  477. package/build-module/components/list-view/block-select-button.js +4 -1
  478. package/build-module/components/list-view/block-select-button.js.map +1 -1
  479. package/build-module/components/media-placeholder/index.js +36 -10
  480. package/build-module/components/media-placeholder/index.js.map +1 -1
  481. package/build-module/components/media-replace-flow/index.js +8 -1
  482. package/build-module/components/media-replace-flow/index.js.map +1 -1
  483. package/build-module/components/media-upload/index.native.js +4 -1
  484. package/build-module/components/media-upload/index.native.js.map +1 -1
  485. package/build-module/components/multi-selection-inspector/index.js +12 -12
  486. package/build-module/components/multi-selection-inspector/index.js.map +1 -1
  487. package/build-module/components/provider/use-block-sync.js +19 -19
  488. package/build-module/components/provider/use-block-sync.js.map +1 -1
  489. package/build-module/components/rich-text/event-listeners/paste-handler.js +12 -1
  490. package/build-module/components/rich-text/event-listeners/paste-handler.js.map +1 -1
  491. package/build-module/components/rich-text/index.js +39 -31
  492. package/build-module/components/rich-text/index.js.map +1 -1
  493. package/build-module/components/rich-text/use-mark-persistent.js +5 -5
  494. package/build-module/components/rich-text/use-mark-persistent.js.map +1 -1
  495. package/build-module/components/skip-to-selected-block/index.js +4 -1
  496. package/build-module/components/skip-to-selected-block/index.js.map +1 -1
  497. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +4 -2
  498. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  499. package/build-module/components/text-alignment-control/index.js +13 -8
  500. package/build-module/components/text-alignment-control/index.js.map +1 -1
  501. package/build-module/components/text-decoration-control/index.js +13 -8
  502. package/build-module/components/text-decoration-control/index.js.map +1 -1
  503. package/build-module/components/text-transform-control/index.js +13 -8
  504. package/build-module/components/text-transform-control/index.js.map +1 -1
  505. package/build-module/components/tool-selector/index.js +4 -1
  506. package/build-module/components/tool-selector/index.js.map +1 -1
  507. package/build-module/components/url-input/button.js +12 -3
  508. package/build-module/components/url-input/button.js.map +1 -1
  509. package/build-module/components/url-input/index.js +4 -1
  510. package/build-module/components/url-input/index.js.map +1 -1
  511. package/build-module/components/url-popover/image-url-input-ui.js +2 -0
  512. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  513. package/build-module/components/use-block-drop-zone/index.js +12 -2
  514. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  515. package/build-module/components/writing-flow/index.js +2 -1
  516. package/build-module/components/writing-flow/index.js.map +1 -1
  517. package/build-module/components/writing-flow/use-arrow-nav.js +4 -1
  518. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  519. package/build-module/components/writing-flow/use-event-redirect.js +60 -0
  520. package/build-module/components/writing-flow/use-event-redirect.js.map +1 -0
  521. package/build-module/components/writing-flow/use-input.js +31 -1
  522. package/build-module/components/writing-flow/use-input.js.map +1 -1
  523. package/build-module/components/writing-flow/use-select-all.js +14 -1
  524. package/build-module/components/writing-flow/use-select-all.js.map +1 -1
  525. package/build-module/components/writing-flow/use-selection-observer.js +16 -2
  526. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  527. package/build-module/components/writing-flow/use-tab-nav.js +4 -4
  528. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  529. package/build-module/components/writing-flow/utils.js +26 -0
  530. package/build-module/components/writing-flow/utils.js.map +1 -1
  531. package/build-module/components/writing-mode-control/index.js +13 -8
  532. package/build-module/components/writing-mode-control/index.js.map +1 -1
  533. package/build-module/hooks/background.js +19 -23
  534. package/build-module/hooks/background.js.map +1 -1
  535. package/build-module/hooks/block-bindings.js +66 -105
  536. package/build-module/hooks/block-bindings.js.map +1 -1
  537. package/build-module/hooks/content-lock-ui.js +10 -30
  538. package/build-module/hooks/content-lock-ui.js.map +1 -1
  539. package/build-module/hooks/duotone.js +0 -4
  540. package/build-module/hooks/duotone.js.map +1 -1
  541. package/build-module/hooks/layout.js +4 -1
  542. package/build-module/hooks/layout.js.map +1 -1
  543. package/build-module/hooks/spacing-visualizer.js +3 -3
  544. package/build-module/hooks/spacing-visualizer.js.map +1 -1
  545. package/build-module/hooks/style.js +1 -5
  546. package/build-module/hooks/style.js.map +1 -1
  547. package/build-module/hooks/use-bindings-attributes.js +19 -20
  548. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  549. package/build-module/hooks/use-zoom-out.js +7 -7
  550. package/build-module/hooks/use-zoom-out.js.map +1 -1
  551. package/build-module/layouts/constrained.js +44 -43
  552. package/build-module/layouts/constrained.js.map +1 -1
  553. package/build-module/layouts/flex.js +6 -1
  554. package/build-module/layouts/flex.js.map +1 -1
  555. package/build-module/layouts/grid.js +3 -0
  556. package/build-module/layouts/grid.js.map +1 -1
  557. package/build-module/layouts/utils.js +1 -7
  558. package/build-module/layouts/utils.js.map +1 -1
  559. package/build-module/private-apis.js +5 -2
  560. package/build-module/private-apis.js.map +1 -1
  561. package/build-module/store/actions.js +2 -7
  562. package/build-module/store/actions.js.map +1 -1
  563. package/build-module/store/private-actions.js +1 -0
  564. package/build-module/store/private-actions.js.map +1 -1
  565. package/build-module/store/private-keys.js +1 -0
  566. package/build-module/store/private-keys.js.map +1 -1
  567. package/build-module/store/private-selectors.js +36 -12
  568. package/build-module/store/private-selectors.js.map +1 -1
  569. package/build-module/store/reducer.js +2 -0
  570. package/build-module/store/reducer.js.map +1 -1
  571. package/build-module/store/selectors.js +22 -46
  572. package/build-module/store/selectors.js.map +1 -1
  573. package/build-module/store/utils.js +46 -0
  574. package/build-module/store/utils.js.map +1 -1
  575. package/build-module/utils/block-bindings.js +110 -0
  576. package/build-module/utils/block-bindings.js.map +1 -0
  577. package/build-module/utils/dom.js +99 -0
  578. package/build-module/utils/dom.js.map +1 -1
  579. package/build-module/utils/get-font-styles-and-weights.js +4 -4
  580. package/build-module/utils/get-font-styles-and-weights.js.map +1 -1
  581. package/build-module/utils/transform-styles/index.js +120 -16
  582. package/build-module/utils/transform-styles/index.js.map +1 -1
  583. package/build-style/content-rtl.css +9 -25
  584. package/build-style/content.css +9 -25
  585. package/build-style/default-editor-styles-rtl.css +2 -2
  586. package/build-style/default-editor-styles.css +2 -2
  587. package/build-style/style-rtl.css +53 -76
  588. package/build-style/style.css +53 -76
  589. package/build-types/utils/dom.d.ts +25 -0
  590. package/build-types/utils/dom.d.ts.map +1 -1
  591. package/package.json +34 -32
  592. package/src/autocompleters/block.js +2 -1
  593. package/src/components/block-alignment-matrix-control/index.js +1 -1
  594. package/src/components/block-breadcrumb/index.js +4 -0
  595. package/src/components/block-breadcrumb/style.scss +1 -1
  596. package/src/components/block-canvas/index.js +9 -1
  597. package/src/components/block-compare/block-view.js +7 -1
  598. package/src/components/block-draggable/content.scss +1 -1
  599. package/src/components/block-draggable/index.js +4 -4
  600. package/src/components/block-draggable/style.scss +1 -1
  601. package/src/components/block-draggable/use-scroll-when-dragging.js +25 -25
  602. package/src/components/block-edit/multiple-usage-warning.js +4 -0
  603. package/src/components/block-inspector/index.js +22 -6
  604. package/src/components/block-list/block-invalid-warning.js +4 -2
  605. package/src/components/block-list/block.js +6 -2
  606. package/src/components/block-list/content.scss +7 -16
  607. package/src/components/block-list/use-block-props/index.js +5 -2
  608. package/src/components/block-list/use-block-props/use-focus-first-element.js +1 -0
  609. package/src/components/block-list/use-block-props/use-zoom-out-mode-exit.js +44 -0
  610. package/src/components/block-list/use-in-between-inserter.js +17 -5
  611. package/src/components/block-lock/style.scss +1 -1
  612. package/src/components/block-lock/toolbar.js +3 -3
  613. package/src/components/block-mover/button.js +2 -0
  614. package/src/components/block-mover/index.js +2 -0
  615. package/src/components/block-mover/style.scss +1 -1
  616. package/src/components/block-navigation/dropdown.js +2 -0
  617. package/src/components/block-pattern-setup/index.js +3 -7
  618. package/src/components/block-pattern-setup/setup-toolbar.js +17 -4
  619. package/src/components/block-pattern-setup/style.scss +2 -2
  620. package/src/components/block-patterns-list/index.js +15 -13
  621. package/src/components/block-patterns-list/style.scss +2 -2
  622. package/src/components/block-patterns-paging/index.js +6 -0
  623. package/src/components/block-popover/index.js +7 -28
  624. package/src/components/block-popover/style.scss +1 -1
  625. package/src/components/block-quick-navigation/index.js +2 -0
  626. package/src/components/block-settings-menu/block-mode-toggle.js +28 -31
  627. package/src/components/block-settings-menu/test/block-mode-toggle.js +26 -23
  628. package/src/components/block-settings-menu-controls/index.js +7 -1
  629. package/src/components/block-switcher/index.js +26 -20
  630. package/src/components/block-switcher/pattern-transformations-menu.js +3 -7
  631. package/src/components/block-switcher/style.scss +5 -6
  632. package/src/components/block-toolbar/index.js +17 -8
  633. package/src/components/block-toolbar/shuffle.js +9 -7
  634. package/src/components/block-tools/block-selection-button.js +4 -0
  635. package/src/components/block-tools/block-toolbar-popover.js +10 -6
  636. package/src/components/block-tools/insertion-point.js +11 -0
  637. package/src/components/block-tools/style.scss +4 -5
  638. package/src/components/block-tools/use-block-toolbar-popover-props.js +2 -1
  639. package/src/components/block-tools/use-show-block-tools.js +4 -1
  640. package/src/components/block-tools/zoom-out-mode-inserters.js +5 -2
  641. package/src/components/block-tools/zoom-out-popover.js +3 -7
  642. package/src/components/block-tools/zoom-out-toolbar.js +20 -6
  643. package/src/components/block-variation-picker/README.md +2 -2
  644. package/src/components/block-variation-picker/index.js +6 -1
  645. package/src/components/block-variation-transforms/index.js +2 -0
  646. package/src/components/block-variation-transforms/style.scss +2 -2
  647. package/src/components/border-radius-control/index.js +1 -0
  648. package/src/components/border-radius-control/style.scss +0 -10
  649. package/src/components/button-block-appender/content.scss +0 -1
  650. package/src/components/button-block-appender/index.js +14 -3
  651. package/src/components/color-palette/test/control.js +15 -2
  652. package/src/components/colors-gradients/dropdown.js +5 -1
  653. package/src/components/colors-gradients/style.scss +4 -4
  654. package/src/components/content-lock/index.js +1 -0
  655. package/src/components/content-lock/modify-content-lock-menu-item.js +58 -0
  656. package/src/components/convert-to-group-buttons/index.js +1 -1
  657. package/src/components/date-format-picker/index.js +2 -0
  658. package/src/components/default-block-appender/content.scss +0 -1
  659. package/src/components/editor-styles/index.js +4 -3
  660. package/src/components/font-appearance-control/index.js +3 -0
  661. package/src/components/font-family/README.md +11 -2
  662. package/src/components/font-family/index.js +3 -0
  663. package/src/components/global-styles/background-panel.js +135 -64
  664. package/src/components/global-styles/color-panel.js +8 -4
  665. package/src/components/global-styles/color-panel.native.js +2 -2
  666. package/src/components/global-styles/dimensions-panel.js +40 -40
  667. package/src/components/global-styles/filters-panel.js +5 -1
  668. package/src/components/global-styles/get-global-styles-changes.js +4 -1
  669. package/src/components/global-styles/hooks.js +0 -5
  670. package/src/components/global-styles/index.js +0 -1
  671. package/src/components/global-styles/shadow-panel-components.js +12 -8
  672. package/src/components/global-styles/style.scss +16 -6
  673. package/src/components/global-styles/test/typography-utils.js +96 -5
  674. package/src/components/global-styles/test/use-global-styles-output.js +20 -4
  675. package/src/components/global-styles/test/utils.js +10 -0
  676. package/src/components/global-styles/typography-utils.js +22 -6
  677. package/src/components/global-styles/use-global-styles-output.js +5 -6
  678. package/src/components/global-styles/utils.js +11 -35
  679. package/src/components/grid/grid-item-movers.js +3 -3
  680. package/src/components/grid/grid-visualizer.js +22 -7
  681. package/src/components/grid/style.scss +1 -1
  682. package/src/components/height-control/index.js +1 -0
  683. package/src/components/iframe/index.js +8 -6
  684. package/src/components/image-editor/zoom-dropdown.js +17 -9
  685. package/src/components/inner-blocks/button-block-appender.js +5 -7
  686. package/src/components/inner-blocks/default-block-appender.js +4 -23
  687. package/src/components/inner-blocks/index.js +11 -10
  688. package/src/components/inner-blocks/use-inner-block-template-sync.js +3 -3
  689. package/src/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +2 -0
  690. package/src/components/inserter/block-patterns-tab/index.js +2 -0
  691. package/src/components/inserter/media-tab/hooks.js +3 -3
  692. package/src/components/inserter/media-tab/media-list.js +1 -4
  693. package/src/components/inserter/media-tab/media-preview.js +12 -2
  694. package/src/components/inserter/media-tab/media-tab.js +2 -0
  695. package/src/components/inserter/menu.js +13 -22
  696. package/src/components/inserter/quick-inserter.js +6 -1
  697. package/src/components/inserter/style.scss +7 -9
  698. package/src/components/inserter-list-item/index.js +4 -4
  699. package/src/components/inserter-list-item/style.scss +2 -3
  700. package/src/components/inserter-listbox/index.js +2 -8
  701. package/src/components/inserter-listbox/item.js +9 -1
  702. package/src/components/inspector-controls/groups.js +2 -0
  703. package/src/components/inspector-controls-tabs/index.js +2 -0
  704. package/src/components/inspector-controls-tabs/settings-tab.js +1 -0
  705. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +5 -2
  706. package/src/components/inspector-popover-header/index.js +4 -0
  707. package/src/components/letter-spacing-control/README.md +8 -1
  708. package/src/components/letter-spacing-control/index.js +7 -4
  709. package/src/components/line-height-control/README.md +7 -0
  710. package/src/components/line-height-control/index.js +3 -0
  711. package/src/components/link-control/index.js +17 -8
  712. package/src/components/link-control/settings-drawer.js +2 -0
  713. package/src/components/link-control/style.scss +2 -4
  714. package/src/components/list-view/block-select-button.js +2 -0
  715. package/src/components/list-view/style.scss +14 -16
  716. package/src/components/media-placeholder/index.js +26 -7
  717. package/src/components/media-replace-flow/index.js +12 -1
  718. package/src/components/media-upload/README.md +2 -0
  719. package/src/components/media-upload/index.native.js +2 -0
  720. package/src/components/multi-selection-inspector/index.js +8 -9
  721. package/src/components/provider/use-block-sync.js +20 -20
  722. package/src/components/responsive-block-control/README.md +3 -26
  723. package/src/components/responsive-block-control/test/index.js +1 -0
  724. package/src/components/rich-text/content.scss +1 -1
  725. package/src/components/rich-text/event-listeners/paste-handler.js +6 -1
  726. package/src/components/rich-text/index.js +54 -41
  727. package/src/components/rich-text/style.scss +1 -1
  728. package/src/components/rich-text/use-mark-persistent.js +5 -5
  729. package/src/components/skip-to-selected-block/index.js +2 -0
  730. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +8 -4
  731. package/src/components/spacing-sizes-control/style.scss +17 -16
  732. package/src/components/text-alignment-control/index.js +20 -8
  733. package/src/components/text-decoration-control/index.js +20 -8
  734. package/src/components/text-decoration-control/stories/index.story.js +0 -4
  735. package/src/components/text-transform-control/index.js +20 -8
  736. package/src/components/text-transform-control/stories/index.story.js +0 -4
  737. package/src/components/tool-selector/index.js +2 -0
  738. package/src/components/url-input/button.js +6 -0
  739. package/src/components/url-input/index.js +2 -0
  740. package/src/components/url-input/style.scss +2 -2
  741. package/src/components/url-popover/image-url-input-ui.js +2 -0
  742. package/src/components/url-popover/stories/index.story.js +7 -1
  743. package/src/components/use-block-drop-zone/index.js +21 -3
  744. package/src/components/warning/content.scss +3 -10
  745. package/src/components/writing-flow/index.js +2 -0
  746. package/src/components/writing-flow/use-arrow-nav.js +9 -2
  747. package/src/components/writing-flow/use-event-redirect.js +72 -0
  748. package/src/components/writing-flow/use-input.js +36 -1
  749. package/src/components/writing-flow/use-select-all.js +18 -1
  750. package/src/components/writing-flow/use-selection-observer.js +23 -3
  751. package/src/components/writing-flow/use-tab-nav.js +4 -4
  752. package/src/components/writing-flow/utils.js +30 -0
  753. package/src/components/writing-mode-control/index.js +20 -8
  754. package/src/hooks/background.js +21 -27
  755. package/src/hooks/block-bindings.js +64 -122
  756. package/src/hooks/block-bindings.scss +2 -10
  757. package/src/hooks/content-lock-ui.js +11 -36
  758. package/src/hooks/duotone.js +0 -4
  759. package/src/hooks/layout.js +2 -0
  760. package/src/hooks/layout.scss +3 -11
  761. package/src/hooks/spacing-visualizer.js +3 -3
  762. package/src/hooks/style.js +1 -4
  763. package/src/hooks/test/background.js +60 -0
  764. package/src/hooks/use-bindings-attributes.js +23 -24
  765. package/src/hooks/use-zoom-out.js +7 -7
  766. package/src/layouts/constrained.js +51 -47
  767. package/src/layouts/flex.js +4 -0
  768. package/src/layouts/grid.js +3 -0
  769. package/src/layouts/test/grid.js +2 -2
  770. package/src/layouts/test/utils.js +6 -8
  771. package/src/layouts/utils.js +1 -9
  772. package/src/private-apis.js +4 -0
  773. package/src/store/actions.js +4 -6
  774. package/src/store/private-actions.js +1 -0
  775. package/src/store/private-keys.js +1 -0
  776. package/src/store/private-selectors.js +44 -7
  777. package/src/store/reducer.js +2 -0
  778. package/src/store/selectors.js +32 -51
  779. package/src/store/test/private-selectors.js +89 -0
  780. package/src/store/utils.js +50 -0
  781. package/src/style.scss +0 -1
  782. package/src/utils/block-bindings.js +97 -0
  783. package/src/utils/dom.js +117 -0
  784. package/src/utils/get-font-styles-and-weights.js +12 -4
  785. package/src/utils/test/get-font-styles-and-weights.js +148 -0
  786. package/src/utils/test/transform-styles.js +284 -26
  787. package/src/utils/transform-styles/index.js +132 -21
  788. package/tsconfig.json +1 -0
  789. package/tsconfig.tsbuildinfo +1 -1
  790. package/build/components/global-styles/theme-file-uri-utils.js +0 -21
  791. package/build/components/global-styles/theme-file-uri-utils.js.map +0 -1
  792. package/build/components/inner-blocks/with-client-id.js +0 -28
  793. package/build/components/inner-blocks/with-client-id.js.map +0 -1
  794. package/build/components/segmented-text-control/index.js +0 -63
  795. package/build/components/segmented-text-control/index.js.map +0 -1
  796. package/build-module/components/global-styles/theme-file-uri-utils.js +0 -15
  797. package/build-module/components/global-styles/theme-file-uri-utils.js.map +0 -1
  798. package/build-module/components/inner-blocks/with-client-id.js +0 -21
  799. package/build-module/components/inner-blocks/with-client-id.js.map +0 -1
  800. package/build-module/components/segmented-text-control/index.js +0 -58
  801. package/build-module/components/segmented-text-control/index.js.map +0 -1
  802. package/src/components/global-styles/test/theme-file-uri-utils.js +0 -41
  803. package/src/components/global-styles/theme-file-uri-utils.js +0 -18
  804. package/src/components/inner-blocks/with-client-id.js +0 -19
  805. package/src/components/segmented-text-control/index.js +0 -63
  806. package/src/components/segmented-text-control/style.scss +0 -15
  807. package/src/utils/test/__snapshots__/transform-styles.js.snap +0 -109
@@ -4,6 +4,7 @@
4
4
  import { useSelect, useDispatch } from '@wordpress/data';
5
5
  import { useRefEffect } from '@wordpress/compose';
6
6
  import { create } from '@wordpress/rich-text';
7
+ import { isSelectionForward } from '@wordpress/dom';
7
8
 
8
9
  /**
9
10
  * Internal dependencies
@@ -53,6 +54,15 @@ function extractSelectionEndNode(selection) {
53
54
  if (focusOffset === focusNode.childNodes.length) {
54
55
  return focusNode;
55
56
  }
57
+
58
+ // When the selection is forward (the selection ends with the focus node),
59
+ // the selection may extend into the next element with an offset of 0. This
60
+ // may trigger multi selection even though the selection does not visually
61
+ // end in the next block.
62
+ if (focusOffset === 0 && isSelectionForward(selection)) {
63
+ var _focusNode$previousSi;
64
+ return (_focusNode$previousSi = focusNode.previousSibling) !== null && _focusNode$previousSi !== void 0 ? _focusNode$previousSi : focusNode.parentElement;
65
+ }
56
66
  return focusNode.childNodes[focusOffset];
57
67
  }
58
68
  function findDepth(a, b) {
@@ -99,7 +109,8 @@ export default function useSelectionObserver() {
99
109
  const {
100
110
  getBlockParents,
101
111
  getBlockSelectionStart,
102
- isMultiSelecting
112
+ isMultiSelecting,
113
+ getSelectedBlockClientId
103
114
  } = useSelect(blockEditorStore);
104
115
  return useRefEffect(node => {
105
116
  const {
@@ -162,10 +173,13 @@ export default function useSelectionObserver() {
162
173
  setContentEditableWrapper(node, false);
163
174
  return;
164
175
  }
176
+ setContentEditableWrapper(node, !!(startClientId && endClientId));
165
177
  const isSingularSelection = startClientId === endClientId;
166
178
  if (isSingularSelection) {
167
179
  if (!isMultiSelecting()) {
168
- selectBlock(startClientId);
180
+ if (getSelectedBlockClientId() !== startClientId) {
181
+ selectBlock(startClientId);
182
+ }
169
183
  } else {
170
184
  multiSelect(startClientId, startClientId);
171
185
  }
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","useDispatch","useRefEffect","create","store","blockEditorStore","getBlockClientId","extractSelectionStartNode","selection","anchorNode","anchorOffset","nodeType","TEXT_NODE","childNodes","extractSelectionEndNode","focusNode","focusOffset","length","findDepth","a","b","depth","setContentEditableWrapper","node","value","contentEditable","String","focus","getRichTextElement","element","ELEMENT_NODE","parentElement","closest","useSelectionObserver","multiSelect","selectBlock","selectionChange","getBlockParents","getBlockSelectionStart","isMultiSelecting","ownerDocument","defaultView","onSelectionChange","event","getSelection","rangeCount","startNode","endNode","contains","isClickShift","shiftKey","type","isCollapsed","startClientId","endClientId","selectedClientId","clickedClientId","target","focusNodeIsNonSelectable","undefined","isSingularSelection","startPath","endPath","richTextElementStart","richTextElementEnd","_richTextDataStart$st","_richTextDataEnd$star","range","getRangeAt","richTextDataStart","__unstableIsEditableTree","richTextDataEnd","startOffset","start","end","endOffset","clientId","attributeKey","dataset","wpBlockAttributeKey","offset","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-selection-observer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { create } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getBlockClientId } from '../../utils/dom';\n\n/**\n * Extract the selection start node from the selection. When the anchor node is\n * not a text node, the selection offset is the index of a child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionStartNode( selection ) {\n\tconst { anchorNode, anchorOffset } = selection;\n\n\tif ( anchorNode.nodeType === anchorNode.TEXT_NODE ) {\n\t\treturn anchorNode;\n\t}\n\n\tif ( anchorOffset === 0 ) {\n\t\treturn anchorNode;\n\t}\n\n\treturn anchorNode.childNodes[ anchorOffset - 1 ];\n}\n\n/**\n * Extract the selection end node from the selection. When the focus node is not\n * a text node, the selection offset is the index of a child node. The selection\n * reaches up to but excluding that child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionEndNode( selection ) {\n\tconst { focusNode, focusOffset } = selection;\n\n\tif ( focusNode.nodeType === focusNode.TEXT_NODE ) {\n\t\treturn focusNode;\n\t}\n\n\tif ( focusOffset === focusNode.childNodes.length ) {\n\t\treturn focusNode;\n\t}\n\n\treturn focusNode.childNodes[ focusOffset ];\n}\n\nfunction findDepth( a, b ) {\n\tlet depth = 0;\n\n\twhile ( a[ depth ] === b[ depth ] ) {\n\t\tdepth++;\n\t}\n\n\treturn depth;\n}\n\n/**\n * Sets the `contenteditable` wrapper element to `value`.\n *\n * @param {HTMLElement} node Block element.\n * @param {boolean} value `contentEditable` value (true or false)\n */\nfunction setContentEditableWrapper( node, value ) {\n\t// Since we are calling this on every selection change, check if the value\n\t// needs to be updated first because it trigger the browser to recalculate\n\t// style.\n\tif ( node.contentEditable !== String( value ) ) {\n\t\tnode.contentEditable = value;\n\n\t\t// Firefox doesn't automatically move focus.\n\t\tif ( value ) {\n\t\t\tnode.focus();\n\t\t}\n\t}\n}\n\nfunction getRichTextElement( node ) {\n\tconst element =\n\t\tnode.nodeType === node.ELEMENT_NODE ? node : node.parentElement;\n\treturn element?.closest( '[data-wp-block-attribute-key]' );\n}\n\n/**\n * Sets a multi-selection based on the native selection across blocks.\n */\nexport default function useSelectionObserver() {\n\tconst { multiSelect, selectBlock, selectionChange } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { getBlockParents, getBlockSelectionStart, isMultiSelecting } =\n\t\tuseSelect( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tfunction onSelectionChange( event ) {\n\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\tif ( ! selection.rangeCount ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst startNode = extractSelectionStartNode( selection );\n\t\t\t\tconst endNode = extractSelectionEndNode( selection );\n\n\t\t\t\tif (\n\t\t\t\t\t! node.contains( startNode ) ||\n\t\t\t\t\t! node.contains( endNode )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If selection is collapsed and we haven't used `shift+click`,\n\t\t\t\t// end multi selection and disable the contentEditable wrapper.\n\t\t\t\t// We have to check about `shift+click` case because elements\n\t\t\t\t// that don't support text selection might be involved, and we might\n\t\t\t\t// update the clientIds to multi-select blocks.\n\t\t\t\t// For now we check if the event is a `mouse` event.\n\t\t\t\tconst isClickShift = event.shiftKey && event.type === 'mouseup';\n\t\t\t\tif ( selection.isCollapsed && ! isClickShift ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.contentEditable === 'true' &&\n\t\t\t\t\t\t! isMultiSelecting()\n\t\t\t\t\t) {\n\t\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\t\tlet element =\n\t\t\t\t\t\t\tstartNode.nodeType === startNode.ELEMENT_NODE\n\t\t\t\t\t\t\t\t? startNode\n\t\t\t\t\t\t\t\t: startNode.parentElement;\n\t\t\t\t\t\telement = element?.closest( '[contenteditable]' );\n\t\t\t\t\t\telement?.focus();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet startClientId = getBlockClientId( startNode );\n\t\t\t\tlet endClientId = getBlockClientId( endNode );\n\n\t\t\t\t// If the selection has changed and we had pressed `shift+click`,\n\t\t\t\t// we need to check if in an element that doesn't support\n\t\t\t\t// text selection has been clicked.\n\t\t\t\tif ( isClickShift ) {\n\t\t\t\t\tconst selectedClientId = getBlockSelectionStart();\n\t\t\t\t\tconst clickedClientId = getBlockClientId( event.target );\n\t\t\t\t\t// `endClientId` is not defined if we end the selection by clicking a non-selectable block.\n\t\t\t\t\t// We need to check if there was already a selection with a non-selectable focusNode.\n\t\t\t\t\tconst focusNodeIsNonSelectable =\n\t\t\t\t\t\tclickedClientId !== endClientId;\n\t\t\t\t\tif (\n\t\t\t\t\t\t( startClientId === endClientId &&\n\t\t\t\t\t\t\tselection.isCollapsed ) ||\n\t\t\t\t\t\t! endClientId ||\n\t\t\t\t\t\tfocusNodeIsNonSelectable\n\t\t\t\t\t) {\n\t\t\t\t\t\tendClientId = clickedClientId;\n\t\t\t\t\t}\n\t\t\t\t\t// Handle the case when we have a non-selectable block\n\t\t\t\t\t// selected and click another one.\n\t\t\t\t\tif ( startClientId !== selectedClientId ) {\n\t\t\t\t\t\tstartClientId = selectedClientId;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If the selection did not involve a block, return.\n\t\t\t\tif (\n\t\t\t\t\tstartClientId === undefined &&\n\t\t\t\t\tendClientId === undefined\n\t\t\t\t) {\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst isSingularSelection = startClientId === endClientId;\n\t\t\t\tif ( isSingularSelection ) {\n\t\t\t\t\tif ( ! isMultiSelecting() ) {\n\t\t\t\t\t\tselectBlock( startClientId );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmultiSelect( startClientId, startClientId );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst startPath = [\n\t\t\t\t\t\t...getBlockParents( startClientId ),\n\t\t\t\t\t\tstartClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst endPath = [\n\t\t\t\t\t\t...getBlockParents( endClientId ),\n\t\t\t\t\t\tendClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst depth = findDepth( startPath, endPath );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tstartPath[ depth ] !== startClientId ||\n\t\t\t\t\t\tendPath[ depth ] !== endClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\tmultiSelect( startPath[ depth ], endPath[ depth ] );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst richTextElementStart =\n\t\t\t\t\t\tgetRichTextElement( startNode );\n\t\t\t\t\tconst richTextElementEnd = getRichTextElement( endNode );\n\n\t\t\t\t\tif ( richTextElementStart && richTextElementEnd ) {\n\t\t\t\t\t\tconst range = selection.getRangeAt( 0 );\n\t\t\t\t\t\tconst richTextDataStart = create( {\n\t\t\t\t\t\t\telement: richTextElementStart,\n\t\t\t\t\t\t\trange,\n\t\t\t\t\t\t\t__unstableIsEditableTree: true,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tconst richTextDataEnd = create( {\n\t\t\t\t\t\t\telement: richTextElementEnd,\n\t\t\t\t\t\t\trange,\n\t\t\t\t\t\t\t__unstableIsEditableTree: true,\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\tconst startOffset =\n\t\t\t\t\t\t\trichTextDataStart.start ?? richTextDataStart.end;\n\t\t\t\t\t\tconst endOffset =\n\t\t\t\t\t\t\trichTextDataEnd.start ?? richTextDataEnd.end;\n\t\t\t\t\t\tselectionChange( {\n\t\t\t\t\t\t\tstart: {\n\t\t\t\t\t\t\t\tclientId: startClientId,\n\t\t\t\t\t\t\t\tattributeKey:\n\t\t\t\t\t\t\t\t\trichTextElementStart.dataset\n\t\t\t\t\t\t\t\t\t\t.wpBlockAttributeKey,\n\t\t\t\t\t\t\t\toffset: startOffset,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tend: {\n\t\t\t\t\t\t\t\tclientId: endClientId,\n\t\t\t\t\t\t\t\tattributeKey:\n\t\t\t\t\t\t\t\t\trichTextElementEnd.dataset\n\t\t\t\t\t\t\t\t\t\t.wpBlockAttributeKey,\n\t\t\t\t\t\t\t\toffset: endOffset,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmultiSelect( startClientId, endClientId );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\townerDocument.addEventListener(\n\t\t\t\t'selectionchange',\n\t\t\t\tonSelectionChange\n\t\t\t);\n\t\t\tdefaultView.addEventListener( 'mouseup', onSelectionChange );\n\t\t\treturn () => {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tonSelectionChange\n\t\t\t\t);\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onSelectionChange );\n\t\t\t};\n\t\t},\n\t\t[ multiSelect, selectBlock, selectionChange, getBlockParents ]\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,MAAM,QAAQ,sBAAsB;;AAE7C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,gBAAgB,QAAQ,iBAAiB;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,yBAAyBA,CAAEC,SAAS,EAAG;EAC/C,MAAM;IAAEC,UAAU;IAAEC;EAAa,CAAC,GAAGF,SAAS;EAE9C,IAAKC,UAAU,CAACE,QAAQ,KAAKF,UAAU,CAACG,SAAS,EAAG;IACnD,OAAOH,UAAU;EAClB;EAEA,IAAKC,YAAY,KAAK,CAAC,EAAG;IACzB,OAAOD,UAAU;EAClB;EAEA,OAAOA,UAAU,CAACI,UAAU,CAAEH,YAAY,GAAG,CAAC,CAAE;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASI,uBAAuBA,CAAEN,SAAS,EAAG;EAC7C,MAAM;IAAEO,SAAS;IAAEC;EAAY,CAAC,GAAGR,SAAS;EAE5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aAAa,CAAC0C,mBAAmB,CAChC,iBAAiB,EACjBxC,iBACD,CAAC;MACDD,WAAW,CAACyC,mBAAmB,CAAE,SAAS,EAAExC,iBAAkB,CAAC;IAChE,CAAC;EACF,CAAC,EACD,CAAER,WAAW,EAAEC,WAAW,EAAEC,eAAe,EAAEC,eAAe,CAC7D,CAAC;AACF","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","useDispatch","useRefEffect","create","isSelectionForward","store","blockEditorStore","getBlockClientId","extractSelectionStartNode","selection","anchorNode","anchorOffset","nodeType","TEXT_NODE","childNodes","extractSelectionEndNode","focusNode","focusOffset","length","_focusNode$previousSi","previousSibling","parentElement","findDepth","a","b","depth","setContentEditableWrapper","node","value","contentEditable","String","focus","getRichTextElement","element","ELEMENT_NODE","closest","useSelectionObserver","multiSelect","selectBlock","selectionChange","getBlockParents","getBlockSelectionStart","isMultiSelecting","getSelectedBlockClientId","ownerDocument","defaultView","onSelectionChange","event","getSelection","rangeCount","startNode","endNode","contains","isClickShift","shiftKey","type","isCollapsed","startClientId","endClientId","selectedClientId","clickedClientId","target","focusNodeIsNonSelectable","undefined","isSingularSelection","startPath","endPath","richTextElementStart","richTextElementEnd","_richTextDataStart$st","_richTextDataEnd$star","range","getRangeAt","richTextDataStart","__unstableIsEditableTree","richTextDataEnd","startOffset","start","end","endOffset","clientId","attributeKey","dataset","wpBlockAttributeKey","offset","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-selection-observer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { create } from '@wordpress/rich-text';\nimport { isSelectionForward } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getBlockClientId } from '../../utils/dom';\n\n/**\n * Extract the selection start node from the selection. When the anchor node is\n * not a text node, the selection offset is the index of a child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionStartNode( selection ) {\n\tconst { anchorNode, anchorOffset } = selection;\n\n\tif ( anchorNode.nodeType === anchorNode.TEXT_NODE ) {\n\t\treturn anchorNode;\n\t}\n\n\tif ( anchorOffset === 0 ) {\n\t\treturn anchorNode;\n\t}\n\n\treturn anchorNode.childNodes[ anchorOffset - 1 ];\n}\n\n/**\n * Extract the selection end node from the selection. When the focus node is not\n * a text node, the selection offset is the index of a child node. The selection\n * reaches up to but excluding that child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionEndNode( selection ) {\n\tconst { focusNode, focusOffset } = selection;\n\n\tif ( focusNode.nodeType === focusNode.TEXT_NODE ) {\n\t\treturn focusNode;\n\t}\n\n\tif ( focusOffset === focusNode.childNodes.length ) {\n\t\treturn focusNode;\n\t}\n\n\t// When the selection is forward (the selection ends with the focus node),\n\t// the selection may extend into the next element with an offset of 0. This\n\t// may trigger multi selection even though the selection does not visually\n\t// end in the next block.\n\tif ( focusOffset === 0 && isSelectionForward( selection ) ) {\n\t\treturn focusNode.previousSibling ?? focusNode.parentElement;\n\t}\n\n\treturn focusNode.childNodes[ focusOffset ];\n}\n\nfunction findDepth( a, b ) {\n\tlet depth = 0;\n\n\twhile ( a[ depth ] === b[ depth ] ) {\n\t\tdepth++;\n\t}\n\n\treturn depth;\n}\n\n/**\n * Sets the `contenteditable` wrapper element to `value`.\n *\n * @param {HTMLElement} node Block element.\n * @param {boolean} value `contentEditable` value (true or false)\n */\nfunction setContentEditableWrapper( node, value ) {\n\t// Since we are calling this on every selection change, check if the value\n\t// needs to be updated first because it trigger the browser to recalculate\n\t// style.\n\tif ( node.contentEditable !== String( value ) ) {\n\t\tnode.contentEditable = value;\n\n\t\t// Firefox doesn't automatically move focus.\n\t\tif ( value ) {\n\t\t\tnode.focus();\n\t\t}\n\t}\n}\n\nfunction getRichTextElement( node ) {\n\tconst element =\n\t\tnode.nodeType === node.ELEMENT_NODE ? node : node.parentElement;\n\treturn element?.closest( '[data-wp-block-attribute-key]' );\n}\n\n/**\n * Sets a multi-selection based on the native selection across blocks.\n */\nexport default function useSelectionObserver() {\n\tconst { multiSelect, selectBlock, selectionChange } =\n\t\tuseDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlockParents,\n\t\tgetBlockSelectionStart,\n\t\tisMultiSelecting,\n\t\tgetSelectedBlockClientId,\n\t} = useSelect( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tfunction onSelectionChange( event ) {\n\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\tif ( ! selection.rangeCount ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst startNode = extractSelectionStartNode( selection );\n\t\t\t\tconst endNode = extractSelectionEndNode( selection );\n\n\t\t\t\tif (\n\t\t\t\t\t! node.contains( startNode ) ||\n\t\t\t\t\t! node.contains( endNode )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If selection is collapsed and we haven't used `shift+click`,\n\t\t\t\t// end multi selection and disable the contentEditable wrapper.\n\t\t\t\t// We have to check about `shift+click` case because elements\n\t\t\t\t// that don't support text selection might be involved, and we might\n\t\t\t\t// update the clientIds to multi-select blocks.\n\t\t\t\t// For now we check if the event is a `mouse` event.\n\t\t\t\tconst isClickShift = event.shiftKey && event.type === 'mouseup';\n\t\t\t\tif ( selection.isCollapsed && ! isClickShift ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.contentEditable === 'true' &&\n\t\t\t\t\t\t! isMultiSelecting()\n\t\t\t\t\t) {\n\t\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\t\tlet element =\n\t\t\t\t\t\t\tstartNode.nodeType === startNode.ELEMENT_NODE\n\t\t\t\t\t\t\t\t? startNode\n\t\t\t\t\t\t\t\t: startNode.parentElement;\n\t\t\t\t\t\telement = element?.closest( '[contenteditable]' );\n\t\t\t\t\t\telement?.focus();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet startClientId = getBlockClientId( startNode );\n\t\t\t\tlet endClientId = getBlockClientId( endNode );\n\n\t\t\t\t// If the selection has changed and we had pressed `shift+click`,\n\t\t\t\t// we need to check if in an element that doesn't support\n\t\t\t\t// text selection has been clicked.\n\t\t\t\tif ( isClickShift ) {\n\t\t\t\t\tconst selectedClientId = getBlockSelectionStart();\n\t\t\t\t\tconst clickedClientId = getBlockClientId( event.target );\n\t\t\t\t\t// `endClientId` is not defined if we end the selection by clicking a non-selectable block.\n\t\t\t\t\t// We need to check if there was already a selection with a non-selectable focusNode.\n\t\t\t\t\tconst focusNodeIsNonSelectable =\n\t\t\t\t\t\tclickedClientId !== endClientId;\n\t\t\t\t\tif (\n\t\t\t\t\t\t( startClientId === endClientId &&\n\t\t\t\t\t\t\tselection.isCollapsed ) ||\n\t\t\t\t\t\t! endClientId ||\n\t\t\t\t\t\tfocusNodeIsNonSelectable\n\t\t\t\t\t) {\n\t\t\t\t\t\tendClientId = clickedClientId;\n\t\t\t\t\t}\n\t\t\t\t\t// Handle the case when we have a non-selectable block\n\t\t\t\t\t// selected and click another one.\n\t\t\t\t\tif ( startClientId !== selectedClientId ) {\n\t\t\t\t\t\tstartClientId = selectedClientId;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If the selection did not involve a block, return.\n\t\t\t\tif (\n\t\t\t\t\tstartClientId === undefined &&\n\t\t\t\t\tendClientId === undefined\n\t\t\t\t) {\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetContentEditableWrapper(\n\t\t\t\t\tnode,\n\t\t\t\t\t!! ( startClientId && endClientId )\n\t\t\t\t);\n\n\t\t\t\tconst isSingularSelection = startClientId === endClientId;\n\t\t\t\tif ( isSingularSelection ) {\n\t\t\t\t\tif ( ! isMultiSelecting() ) {\n\t\t\t\t\t\tif ( getSelectedBlockClientId() !== startClientId ) {\n\t\t\t\t\t\t\tselectBlock( startClientId );\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmultiSelect( startClientId, startClientId );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst startPath = [\n\t\t\t\t\t\t...getBlockParents( startClientId ),\n\t\t\t\t\t\tstartClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst endPath = [\n\t\t\t\t\t\t...getBlockParents( endClientId ),\n\t\t\t\t\t\tendClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst depth = findDepth( startPath, endPath );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tstartPath[ depth ] !== startClientId ||\n\t\t\t\t\t\tendPath[ depth ] !== endClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\tmultiSelect( startPath[ depth ], endPath[ depth ] );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst richTextElementStart =\n\t\t\t\t\t\tgetRichTextElement( startNode );\n\t\t\t\t\tconst richTextElementEnd = getRichTextElement( endNode );\n\n\t\t\t\t\tif ( richTextElementStart && richTextElementEnd ) {\n\t\t\t\t\t\tconst range = selection.getRangeAt( 0 );\n\t\t\t\t\t\tconst richTextDataStart = create( {\n\t\t\t\t\t\t\telement: richTextElementStart,\n\t\t\t\t\t\t\trange,\n\t\t\t\t\t\t\t__unstableIsEditableTree: true,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tconst richTextDataEnd = create( {\n\t\t\t\t\t\t\telement: richTextElementEnd,\n\t\t\t\t\t\t\trange,\n\t\t\t\t\t\t\t__unstableIsEditableTree: true,\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\tconst startOffset =\n\t\t\t\t\t\t\trichTextDataStart.start ?? richTextDataStart.end;\n\t\t\t\t\t\tconst endOffset =\n\t\t\t\t\t\t\trichTextDataEnd.start ?? richTextDataEnd.end;\n\t\t\t\t\t\tselectionChange( {\n\t\t\t\t\t\t\tstart: {\n\t\t\t\t\t\t\t\tclientId: startClientId,\n\t\t\t\t\t\t\t\tattributeKey:\n\t\t\t\t\t\t\t\t\trichTextElementStart.dataset\n\t\t\t\t\t\t\t\t\t\t.wpBlockAttributeKey,\n\t\t\t\t\t\t\t\toffset: startOffset,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tend: {\n\t\t\t\t\t\t\t\tclientId: endClientId,\n\t\t\t\t\t\t\t\tattributeKey:\n\t\t\t\t\t\t\t\t\trichTextElementEnd.dataset\n\t\t\t\t\t\t\t\t\t\t.wpBlockAttributeKey,\n\t\t\t\t\t\t\t\toffset: endOffset,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmultiSelect( startClientId, endClientId );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\townerDocument.addEventListener(\n\t\t\t\t'selectionchange',\n\t\t\t\tonSelectionChange\n\t\t\t);\n\t\t\tdefaultView.addEventListener( 'mouseup', onSelectionChange );\n\t\t\treturn () => {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tonSelectionChange\n\t\t\t\t);\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onSelectionChange );\n\t\t\t};\n\t\t},\n\t\t[ multiSelect, selectBlock, selectionChange, getBlockParents ]\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,MAAM,QAAQ,sBAAsB;AAC7C,SAASC,kBAAkB,QAAQ,gBAAgB;;AAEnD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,gBAAgB,QAAQ,iBAAiB;;AAElD;AACA;AACA;AACA;A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CAAE;YAC/B8B,OAAO,EAAEmC,kBAAkB;YAC3BG,KAAK;YACLG,wBAAwB,EAAE;UAC3B,CAAE,CAAC;UAEH,MAAME,WAAW,IAAAP,qBAAA,GAChBI,iBAAiB,CAACI,KAAK,cAAAR,qBAAA,cAAAA,qBAAA,GAAII,iBAAiB,CAACK,GAAG;UACjD,MAAMC,SAAS,IAAAT,qBAAA,GACdK,eAAe,CAACE,KAAK,cAAAP,qBAAA,cAAAA,qBAAA,GAAIK,eAAe,CAACG,GAAG;UAC7CvC,eAAe,CAAE;YAChBsC,KAAK,EAAE;cACNG,QAAQ,EAAEvB,aAAa;cACvBwB,YAAY,EACXd,oBAAoB,CAACe,OAAO,CAC1BC,mBAAmB;cACtBC,MAAM,EAAER;YACT,CAAC;YACDE,GAAG,EAAE;cACJE,QAAQ,EAAEtB,WAAW;cACrBuB,YAAY,EACXb,kBAAkB,CAACc,OAAO,CACxBC,mBAAmB;cACtBC,MAAM,EAAEL;YACT;UACD,CAAE,CAAC;QACJ,CAAC,MAAM;UACN1C,WAAW,CAAEoB,aAAa,EAAEC,WAAY,CAAC;QAC1C;MACD;IACD;IAEAd,aAAa,CAACyC,gBAAgB,CAC7B,iBAAiB,EACjBvC,iBACD,CAAC;IACDD,WAAW,CAACwC,gBAAgB,CAAE,SAAS,EAAEvC,iBAAkB,CAAC;IAC5D,OAAO,MAAM;MACZF,aAAa,CAAC0C,mBAAmB,CAChC,iBAAiB,EACjBxC,iBACD,CAAC;MACDD,WAAW,CAACyC,mBAAmB,CAAE,SAAS,EAAExC,iBAAkB,CAAC;IAChE,CAAC;EACF,CAAC,EACD,CAAET,WAAW,EAAEC,WAAW,EAAEC,eAAe,EAAEC,eAAe,CAC7D,CAAC;AACF","ignoreList":[]}
@@ -37,11 +37,11 @@ export default function useTabNav() {
37
37
 
38
38
  // Reference that holds the a flag for enabling or disabling
39
39
  // capturing on the focus capture elements.
40
- const noCapture = useRef();
40
+ const noCaptureRef = useRef();
41
41
  function onFocusCapture(event) {
42
42
  // Do not capture incoming focus if set by us in WritingFlow.
43
- if (noCapture.current) {
44
- noCapture.current = null;
43
+ if (noCaptureRef.current) {
44
+ noCaptureRef.current = null;
45
45
  } else if (hasMultiSelection()) {
46
46
  container.current.focus();
47
47
  } else if (getSelectedBlockClientId()) {
@@ -132,7 +132,7 @@ export default function useTabNav() {
132
132
  // Disable focus capturing on the focus capture element, so it
133
133
  // doesn't refocus this block and so it allows default behaviour
134
134
  // (moving focus to the next tabbable element).
135
- noCapture.current = true;
135
+ noCaptureRef.current = true;
136
136
 
137
137
  // Focusing the focus capture element, which is located above and
138
138
  // below the editor, should not scroll the page all the way up or
@@ -1 +1 @@
1
- {"version":3,"names":["focus","isFormElement","TAB","ESCAPE","useSelect","useDispatch","useRefEffect","useMergeRefs","useRef","store","blockEditorStore","isInSameBlock","isInsideRootBlock","unlock","jsx","_jsx","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","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;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE3C,eAAe,SAASC,SAASA,CAAA,EAAG;EACnC,MAAMC,SAAS,GAAGT,MAAM,CAAC,CAAC;EAC1B,MAAMU,qBAAqB,GAAGV,MAAM,CAAC,CAAC;EACtC,MAAMW,oBAAoB,GAAGX,MAAM,CAAC,CAAC;EAErC,MAAM;IAAEY,iBAAiB;IAAEC,wBAAwB;IAAEC;EAAc,CAAC,GACnElB,SAAS,CAAEM,gBAAiB,CAAC;EAC9B,MAAM;IAAEa,iBAAiB;IAAEC;EAAa,CAAC,GAAGX,MAAM,CACjDR,WAAW,CAAEK,gBAAiB,CAC/B,CAAC;EACD,MAAMe,gBAAgB,GAAGrB,SAAS,CAC/BsB,MAAM,IAAMA,MAAM,CAAEhB,gBAAiB,CAAC,CAACe,gBAAgB,CAAC,CAAC,EAC3D,EACD,CAAC;EAED,MAAM;IAAEE;EAAa,CAAC,GAAGd,MAAM,C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focus","isFormElement","TAB","ESCAPE","useSelect","useDispatch","useRefEffect","useMergeRefs","useRef","store","blockEditorStore","isInSameBlock","isInsideRootBlock","unlock","jsx","_jsx","useTabNav","container","focusCaptureBeforeRef","focusCaptureAfterRef","hasMultiSelection","getSelectedBlockClientId","getBlockCount","setNavigationMode","setLastFocus","isNavigationMode","select","getLastFocus","focusCaptureTabIndex","undefined","noCaptureRef","onFocusCapture","event","current","querySelector","canvasElement","ownerDocument","target","defaultView","frameElement","isBefore","compareDocumentPosition","DOCUMENT_POSITION_FOLLOWING","tabbables","tabbable","find","length","next","before","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 noCaptureRef = useRef();\n\n\tfunction onFocusCapture( event ) {\n\t\t// Do not capture incoming focus if set by us in WritingFlow.\n\t\tif ( noCaptureRef.current ) {\n\t\t\tnoCaptureRef.current = null;\n\t\t} else if ( hasMultiSelection() ) {\n\t\t\tcontainer.current.focus();\n\t\t} else if ( getSelectedBlockClientId() ) {\n\t\t\tif ( getLastFocus()?.current ) {\n\t\t\t\tgetLastFocus().current.focus();\n\t\t\t} else {\n\t\t\t\t// Handles when the last focus has not been set yet, or has been cleared by new blocks being added via the inserter.\n\t\t\t\tcontainer.current\n\t\t\t\t\t.querySelector(\n\t\t\t\t\t\t`[data-block=\"${ getSelectedBlockClientId() }\"]`\n\t\t\t\t\t)\n\t\t\t\t\t.focus();\n\t\t\t}\n\t\t} else {\n\t\t\tsetNavigationMode( true );\n\n\t\t\tconst canvasElement =\n\t\t\t\tcontainer.current.ownerDocument === event.target.ownerDocument\n\t\t\t\t\t? container.current\n\t\t\t\t\t: container.current.ownerDocument.defaultView.frameElement;\n\n\t\t\tconst isBefore =\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tevent.target.compareDocumentPosition( canvasElement ) &\n\t\t\t\tevent.target.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tconst tabbables = focus.tabbable.find( container.current );\n\n\t\t\tif ( tabbables.length ) {\n\t\t\t\tconst next = isBefore\n\t\t\t\t\t? tabbables[ 0 ]\n\t\t\t\t\t: tabbables[ tabbables.length - 1 ];\n\n\t\t\t\tnext.focus();\n\t\t\t}\n\t\t}\n\t}\n\n\tconst before = (\n\t\t<div\n\t\t\tref={ focusCaptureBeforeRef }\n\t\t\ttabIndex={ focusCaptureTabIndex }\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst after = (\n\t\t<div\n\t\t\tref={ focusCaptureAfterRef }\n\t\t\ttabIndex={ focusCaptureTabIndex }\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst ref = useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ESCAPE && ! hasMultiSelection() ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetNavigationMode( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// In Edit mode, Tab should focus the first tabbable element after\n\t\t\t// the content, which is normally the sidebar (with block controls)\n\t\t\t// and Shift+Tab should focus the first tabbable element before the\n\t\t\t// content, which is normally the block toolbar.\n\t\t\t// Arrow keys can be used, and Tab and arrow keys can be used in\n\t\t\t// Navigation mode (press Esc), to navigate through blocks.\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\n\t\t\tif ( ! hasMultiSelection() && ! getSelectedBlockClientId() ) {\n\t\t\t\t// Preserve the behaviour of entering navigation mode when\n\t\t\t\t// tabbing into the content without a block selection.\n\t\t\t\t// `onFocusCapture` already did this previously, but we need to\n\t\t\t\t// do it again here because after clearing block selection,\n\t\t\t\t// focus land on the writing flow container and pressing Tab\n\t\t\t\t// will no longer send focus through the focus capture element.\n\t\t\t\tif ( event.target === node ) {\n\t\t\t\t\tsetNavigationMode( true );\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nextTabbable = focus.tabbable[ direction ]( event.target );\n\n\t\t\t// We want to constrain the tabbing to the block and its child blocks.\n\t\t\t// If the preceding form element is within a different block,\n\t\t\t// such as two sibling image blocks in the placeholder state,\n\t\t\t// we want shift + tab from the first form element to move to the image\n\t\t\t// block toolbar and not the previous image block's form element.\n\t\t\tconst currentBlock = event.target.closest( '[data-block]' );\n\t\t\tconst isElementPartOfSelectedBlock =\n\t\t\t\tcurrentBlock &&\n\t\t\t\tnextTabbable &&\n\t\t\t\t( isInSameBlock( currentBlock, nextTabbable ) ||\n\t\t\t\t\tisInsideRootBlock( currentBlock, nextTabbable ) );\n\n\t\t\t// Allow tabbing from the block wrapper to a form element,\n\t\t\t// and between form elements rendered in a block and its child blocks,\n\t\t\t// such as inside a placeholder. Form elements are generally\n\t\t\t// meant to be UI rather than part of the content. Ideally\n\t\t\t// these are not rendered in the content and perhaps in the\n\t\t\t// future they can be rendered in an iframe or shadow DOM.\n\t\t\tif (\n\t\t\t\tisFormElement( nextTabbable ) &&\n\t\t\t\tisElementPartOfSelectedBlock\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef;\n\n\t\t\t// Disable focus capturing on the focus capture element, so it\n\t\t\t// doesn't refocus this block and so it allows default behaviour\n\t\t\t// (moving focus to the next tabbable element).\n\t\t\tnoCaptureRef.current = true;\n\n\t\t\t// Focusing the focus capture element, which is located above and\n\t\t\t// below the editor, should not scroll the page all the way up or\n\t\t\t// down.\n\t\t\tnext.current.focus( { preventScroll: true } );\n\t\t}\n\n\t\tfunction onFocusOut( event ) {\n\t\t\tsetLastFocus( { ...getLastFocus(), current: event.target } );\n\n\t\t\tconst { ownerDocument } = node;\n\n\t\t\t// If focus disappears due to there being no blocks, move focus to\n\t\t\t// the writing flow wrapper.\n\t\t\tif (\n\t\t\t\t! event.relatedTarget &&\n\t\t\t\townerDocument.activeElement === ownerDocument.body &&\n\t\t\t\tgetBlockCount() === 0\n\t\t\t) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t}\n\n\t\t// When tabbing back to an element in block list, this event handler prevents scrolling if the\n\t\t// focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph\n\t\t// when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the\n\t\t// top or bottom of the document.\n\t\t//\n\t\t// Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this\n\t\t// earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters\n\t\tfunction preventScrollOnTab( event ) {\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.target?.getAttribute( 'role' ) === 'region' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( container.current === event.target ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst target = focus.tabbable[ direction ]( event.target );\n\t\t\t// Only do something when the next tabbable is a focus capture div (before/after)\n\t\t\tif (\n\t\t\t\ttarget === focusCaptureBeforeRef.current ||\n\t\t\t\ttarget === focusCaptureAfterRef.current\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\ttarget.focus( { preventScroll: true } );\n\t\t\t}\n\t\t}\n\n\t\tconst { ownerDocument } = node;\n\t\tconst { defaultView } = ownerDocument;\n\t\tdefaultView.addEventListener( 'keydown', preventScrollOnTab );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'focusout', onFocusOut );\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'keydown', preventScrollOnTab );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'focusout', onFocusOut );\n\t\t};\n\t}, [] );\n\n\tconst mergedRefs = useMergeRefs( [ container, ref ] );\n\n\treturn [ before, mergedRefs, after ];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,EAAEC,aAAa,QAAQ,gBAAgB;AACrD,SAASC,GAAG,EAAEC,MAAM,QAAQ,qBAAqB;AACjD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB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ACDD,KAAK,CAACyB,cAAc,CAAC,CAAC;QACtBpB,MAAM,CAACrC,KAAK,CAAE;UAAEiE,aAAa,EAAE;QAAK,CAAE,CAAC;MACxC;IACD;IAEA,MAAM;MAAE7B;IAAc,CAAC,GAAGiB,IAAI;IAC9B,MAAM;MAAEf;IAAY,CAAC,GAAGF,aAAa;IACrCE,WAAW,CAACkC,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;MACZ5B,WAAW,CAACmC,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,GAAGnE,YAAY,CAAE,CAAEU,SAAS,EAAEgC,GAAG,CAAG,CAAC;EAErD,OAAO,CAAED,MAAM,EAAE0B,UAAU,EAAEtB,KAAK,CAAE;AACrC","ignoreList":[]}
@@ -91,4 +91,30 @@ function toPlainText(html) {
91
91
  // Merge any consecutive line breaks
92
92
  return plainText.replace(/\n\n+/g, '\n\n');
93
93
  }
94
+
95
+ /**
96
+ * Gets the current content editable root element based on the selection.
97
+ * @param {Document} ownerDocument
98
+ * @return {Element|undefined} The content editable root element.
99
+ */
100
+ export function getSelectionRoot(ownerDocument) {
101
+ const {
102
+ defaultView
103
+ } = ownerDocument;
104
+ const {
105
+ anchorNode,
106
+ focusNode
107
+ } = defaultView.getSelection();
108
+ if (!anchorNode || !focusNode) {
109
+ return;
110
+ }
111
+ const anchorElement = (anchorNode.nodeType === anchorNode.ELEMENT_NODE ? anchorNode : anchorNode.parentElement).closest('[contenteditable]');
112
+ if (!anchorElement) {
113
+ return;
114
+ }
115
+ if (!anchorElement.contains(focusNode)) {
116
+ return;
117
+ }
118
+ return anchorElement;
119
+ }
94
120
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__unstableStripHTML","stripHTML","serialize","createBlock","pasteHandler","findTransform","getBlockTransforms","store","blocksStore","getPasteEventData","blockEditorStore","requiresWrapperOnCopy","Symbol","setClipboardBlocks","event","blocks","registry","_blocks","firstBlock","firstBlockType","select","getBlockType","name","getBlockRootClientId","getBlockName","getBlockAttributes","wrapperBlockClientId","clientId","wrapperBlockName","serialized","clipboardData","setData","toPlainText","getPasteBlocks","canUserUseUnfilteredHTML","plainText","html","files","length","fromTransforms","reduce","accumulator","file","transformation","transform","type","isMatch","push","flat","HTML","mode","replace","trim"],"sources":["@wordpress/block-editor/src/components/writing-flow/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport {\n\tserialize,\n\tcreateBlock,\n\tpasteHandler,\n\tfindTransform,\n\tgetBlockTransforms,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { getPasteEventData } from '../../utils/pasting';\nimport { store as blockEditorStore } from '../../store';\n\nexport const requiresWrapperOnCopy = Symbol( 'requiresWrapperOnCopy' );\n\n/**\n * Sets the clipboard data for the provided blocks, with both HTML and plain\n * text representations.\n *\n * @param {ClipboardEvent} event Clipboard event.\n * @param {WPBlock[]} blocks Blocks to set as clipboard data.\n * @param {Object} registry The registry to select from.\n */\nexport function setClipboardBlocks( event, blocks, registry ) {\n\tlet _blocks = blocks;\n\n\tconst [ firstBlock ] = blocks;\n\n\tif ( firstBlock ) {\n\t\tconst firstBlockType = registry\n\t\t\t.select( blocksStore )\n\t\t\t.getBlockType( firstBlock.name );\n\n\t\tif ( firstBlockType[ requiresWrapperOnCopy ] ) {\n\t\t\tconst { getBlockRootClientId, getBlockName, getBlockAttributes } =\n\t\t\t\tregistry.select( blockEditorStore );\n\t\t\tconst wrapperBlockClientId = getBlockRootClientId(\n\t\t\t\tfirstBlock.clientId\n\t\t\t);\n\t\t\tconst wrapperBlockName = getBlockName( wrapperBlockClientId );\n\n\t\t\tif ( wrapperBlockName ) {\n\t\t\t\t_blocks = createBlock(\n\t\t\t\t\twrapperBlockName,\n\t\t\t\t\tgetBlockAttributes( wrapperBlockClientId ),\n\t\t\t\t\t_blocks\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst serialized = serialize( _blocks );\n\n\tevent.clipboardData.setData( 'text/plain', toPlainText( serialized ) );\n\tevent.clipboardData.setData( 'text/html', serialized );\n}\n\n/**\n * Returns the blocks to be pasted from the clipboard event.\n *\n * @param {ClipboardEvent} event The clipboard event.\n * @param {boolean} canUserUseUnfilteredHTML Whether the user can or can't post unfiltered HTML.\n * @return {Array|string} A list of blocks or a string, depending on `handlerMode`.\n */\nexport function getPasteBlocks( event, canUserUseUnfilteredHTML ) {\n\tconst { plainText, html, files } = getPasteEventData( event );\n\tlet blocks = [];\n\n\tif ( files.length ) {\n\t\tconst fromTransforms = getBlockTransforms( 'from' );\n\t\tblocks = files\n\t\t\t.reduce( ( accumulator, file ) => {\n\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\tfromTransforms,\n\t\t\t\t\t( transform ) =>\n\t\t\t\t\t\ttransform.type === 'files' &&\n\t\t\t\t\t\ttransform.isMatch( [ file ] )\n\t\t\t\t);\n\t\t\t\tif ( transformation ) {\n\t\t\t\t\taccumulator.push( transformation.transform( [ file ] ) );\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t}, [] )\n\t\t\t.flat();\n\t} else {\n\t\tblocks = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t\tmode: 'BLOCKS',\n\t\t\tcanUserUseUnfilteredHTML,\n\t\t} );\n\t}\n\n\treturn blocks;\n}\n\n/**\n * Given a string of HTML representing serialized blocks, returns the plain\n * text extracted after stripping the HTML of any tags and fixing line breaks.\n *\n * @param {string} html Serialized blocks.\n * @return {string} The plain-text content with any html removed.\n */\nfunction toPlainText( html ) {\n\t// Manually handle BR tags as line breaks prior to `stripHTML` call\n\thtml = html.replace( /<br>/g, '\\n' );\n\n\tconst plainText = stripHTML( html ).trim();\n\n\t// Merge any consecutive line breaks\n\treturn plainText.replace( /\\n\\n+/g, '\\n\\n' );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,mBAAmB,IAAIC,SAAS,QAAQ,gBAAgB;AACjE,SACCC,SAAS,EACTC,WAAW,EACXC,YAAY,EACZC,aAAa,EACbC,kBAAkB,EAClBC,KAAK,IAAIC,WAAW,QACd,mBAAmB;;AAE1B;AACA;AACA;AACA,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASF,KAAK,IAAIG,gBAAgB,QAAQ,aAAa;AAEvD,OAAO,MAAMC,qBAAqB,GAAGC,MAAM,CAAE,uBAAwB,CAAC;;AAEtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAEC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,EAAG;EAC7D,IAAIC,OAAO,GAAGF,MAAM;EAEpB,MAAM,CAAEG,UAAU,CAAE,GAAGH,MAAM;EAE7B,IAAKG,UAAU,EAAG;IACjB,MAAMC,cAAc,GAAGH,QAAQ,CAC7BI,MAAM,CAAEZ,WAAY,CAAC,CACrBa,YAAY,CAAEH,UAAU,CAACI,IAAK,CAAC;IAEjC,IAAKH,cAAc,CAAER,qBAAqB,CAAE,EAAG;MAC9C,MAAM;QAAEY,oBAAoB;QAAEC,YAAY;QAAEC;MAAmB,CAAC,GAC/DT,QAAQ,CAACI,MAAM,CAAEV,gBAAiB,CAAC;MACpC,MAAMgB,oBAAoB,GAAGH,oBAAoB,CAChDL,UAAU,CAACS,QACZ,CAAC;MACD,MAAMC,gBAAgB,GAAGJ,YAAY,CAAEE,oBAA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;MACdhB;IACD,CAAE,CAAC;EACJ;EAEA,OAAOnB,MAAM;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASiB,WAAWA,CAAEI,IAAI,EAAG;EAC5B;EACAA,IAAI,GAAGA,IAAI,CAACe,OAAO,CAAE,OAAO,EAAE,IAAK,CAAC;EAEpC,MAAMhB,SAAS,GAAGlC,SAAS,CAAEmC,IAAK,CAAC,CAACgB,IAAI,CAAC,CAAC;;EAE1C;EACA,OAAOjB,SAAS,CAACgB,OAAO,CAAE,QAAQ,EAAE,MAAO,CAAC;AAC7C","ignoreList":[]}
1
+ {"version":3,"names":["__unstableStripHTML","stripHTML","serialize","createBlock","pasteHandler","findTransform","getBlockTransforms","store","blocksStore","getPasteEventData","blockEditorStore","requiresWrapperOnCopy","Symbol","setClipboardBlocks","event","blocks","registry","_blocks","firstBlock","firstBlockType","select","getBlockType","name","getBlockRootClientId","getBlockName","getBlockAttributes","wrapperBlockClientId","clientId","wrapperBlockName","serialized","clipboardData","setData","toPlainText","getPasteBlocks","canUserUseUnfilteredHTML","plainText","html","files","length","fromTransforms","reduce","accumulator","file","transformation","transform","type","isMatch","push","flat","HTML","mode","replace","trim","getSelectionRoot","ownerDocument","defaultView","anchorNode","focusNode","getSelection","anchorElement","nodeType","ELEMENT_NODE","parentElement","closest","contains"],"sources":["@wordpress/block-editor/src/components/writing-flow/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport {\n\tserialize,\n\tcreateBlock,\n\tpasteHandler,\n\tfindTransform,\n\tgetBlockTransforms,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { getPasteEventData } from '../../utils/pasting';\nimport { store as blockEditorStore } from '../../store';\n\nexport const requiresWrapperOnCopy = Symbol( 'requiresWrapperOnCopy' );\n\n/**\n * Sets the clipboard data for the provided blocks, with both HTML and plain\n * text representations.\n *\n * @param {ClipboardEvent} event Clipboard event.\n * @param {WPBlock[]} blocks Blocks to set as clipboard data.\n * @param {Object} registry The registry to select from.\n */\nexport function setClipboardBlocks( event, blocks, registry ) {\n\tlet _blocks = blocks;\n\n\tconst [ firstBlock ] = blocks;\n\n\tif ( firstBlock ) {\n\t\tconst firstBlockType = registry\n\t\t\t.select( blocksStore )\n\t\t\t.getBlockType( firstBlock.name );\n\n\t\tif ( firstBlockType[ requiresWrapperOnCopy ] ) {\n\t\t\tconst { getBlockRootClientId, getBlockName, getBlockAttributes } =\n\t\t\t\tregistry.select( blockEditorStore );\n\t\t\tconst wrapperBlockClientId = getBlockRootClientId(\n\t\t\t\tfirstBlock.clientId\n\t\t\t);\n\t\t\tconst wrapperBlockName = getBlockName( wrapperBlockClientId );\n\n\t\t\tif ( wrapperBlockName ) {\n\t\t\t\t_blocks = createBlock(\n\t\t\t\t\twrapperBlockName,\n\t\t\t\t\tgetBlockAttributes( wrapperBlockClientId ),\n\t\t\t\t\t_blocks\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst serialized = serialize( _blocks );\n\n\tevent.clipboardData.setData( 'text/plain', toPlainText( serialized ) );\n\tevent.clipboardData.setData( 'text/html', serialized );\n}\n\n/**\n * Returns the blocks to be pasted from the clipboard event.\n *\n * @param {ClipboardEvent} event The clipboard event.\n * @param {boolean} canUserUseUnfilteredHTML Whether the user can or can't post unfiltered HTML.\n * @return {Array|string} A list of blocks or a string, depending on `handlerMode`.\n */\nexport function getPasteBlocks( event, canUserUseUnfilteredHTML ) {\n\tconst { plainText, html, files } = getPasteEventData( event );\n\tlet blocks = [];\n\n\tif ( files.length ) {\n\t\tconst fromTransforms = getBlockTransforms( 'from' );\n\t\tblocks = files\n\t\t\t.reduce( ( accumulator, file ) => {\n\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\tfromTransforms,\n\t\t\t\t\t( transform ) =>\n\t\t\t\t\t\ttransform.type === 'files' &&\n\t\t\t\t\t\ttransform.isMatch( [ file ] )\n\t\t\t\t);\n\t\t\t\tif ( transformation ) {\n\t\t\t\t\taccumulator.push( transformation.transform( [ file ] ) );\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t}, [] )\n\t\t\t.flat();\n\t} else {\n\t\tblocks = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t\tmode: 'BLOCKS',\n\t\t\tcanUserUseUnfilteredHTML,\n\t\t} );\n\t}\n\n\treturn blocks;\n}\n\n/**\n * Given a string of HTML representing serialized blocks, returns the plain\n * text extracted after stripping the HTML of any tags and fixing line breaks.\n *\n * @param {string} html Serialized blocks.\n * @return {string} The plain-text content with any html removed.\n */\nfunction toPlainText( html ) {\n\t// Manually handle BR tags as line breaks prior to `stripHTML` call\n\thtml = html.replace( /<br>/g, '\\n' );\n\n\tconst plainText = stripHTML( html ).trim();\n\n\t// Merge any consecutive line breaks\n\treturn plainText.replace( /\\n\\n+/g, '\\n\\n' );\n}\n\n/**\n * Gets the current content editable root element based on the selection.\n * @param {Document} ownerDocument\n * @return {Element|undefined} The content editable root element.\n */\nexport function getSelectionRoot( ownerDocument ) {\n\tconst { defaultView } = ownerDocument;\n\tconst { anchorNode, focusNode } = defaultView.getSelection();\n\n\tif ( ! anchorNode || ! focusNode ) {\n\t\treturn;\n\t}\n\n\tconst anchorElement = (\n\t\tanchorNode.nodeType === anchorNode.ELEMENT_NODE\n\t\t\t? anchorNode\n\t\t\t: anchorNode.parentElement\n\t).closest( '[contenteditable]' );\n\n\tif ( ! anchorElement ) {\n\t\treturn;\n\t}\n\n\tif ( ! anchorElement.contains( focusNode ) ) {\n\t\treturn;\n\t}\n\n\treturn anchorElement;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,mBAAmB,IAAIC,SAAS,QAAQ,gBAAgB;AACjE,SACCC,SAAS,EACTC,WAAW,EACXC,YAAY,EACZC,aAAa,EACbC,kBAAkB,EAClBC,KAAK,IAAIC,WAAW,QACd,mBAAmB;;AAE1B;AACA;AAC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GD,aAAa;EACrC,MAAM;IAAEE,UAAU;IAAEC;EAAU,CAAC,GAAGF,WAAW,CAACG,YAAY,CAAC,CAAC;EAE5D,IAAK,CAAEF,UAAU,IAAI,CAAEC,SAAS,EAAG;IAClC;EACD;EAEA,MAAME,aAAa,GAAG,CACrBH,UAAU,CAACI,QAAQ,KAAKJ,UAAU,CAACK,YAAY,GAC5CL,UAAU,GACVA,UAAU,CAACM,aAAa,EAC1BC,OAAO,CAAE,mBAAoB,CAAC;EAEhC,IAAK,CAAEJ,aAAa,EAAG;IACtB;EACD;EAEA,IAAK,CAAEA,aAAa,CAACK,QAAQ,CAAEP,SAAU,CAAC,EAAG;IAC5C;EACD;EAEA,OAAOE,aAAa;AACrB","ignoreList":[]}
@@ -8,11 +8,7 @@ import clsx from 'clsx';
8
8
  */
9
9
  import { __, isRTL } from '@wordpress/i18n';
10
10
  import { textHorizontal, textVertical } from '@wordpress/icons';
11
-
12
- /**
13
- * Internal dependencies
14
- */
15
- import SegmentedTextControl from '../segmented-text-control';
11
+ import { __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon } from '@wordpress/components';
16
12
  import { jsx as _jsx } from "react/jsx-runtime";
17
13
  const WRITING_MODES = [{
18
14
  label: __('Horizontal'),
@@ -39,14 +35,23 @@ export default function WritingModeControl({
39
35
  value,
40
36
  onChange
41
37
  }) {
42
- return /*#__PURE__*/_jsx(SegmentedTextControl, {
38
+ return /*#__PURE__*/_jsx(ToggleGroupControl, {
39
+ isDeselectable: true,
40
+ __nextHasNoMarginBottom: true,
41
+ __next40pxDefaultSize: true,
43
42
  label: __('Orientation'),
44
- options: WRITING_MODES,
45
43
  className: clsx('block-editor-writing-mode-control', className),
46
44
  value: value,
47
45
  onChange: newValue => {
48
46
  onChange(newValue === value ? undefined : newValue);
49
- }
47
+ },
48
+ children: WRITING_MODES.map(option => {
49
+ return /*#__PURE__*/_jsx(ToggleGroupControlOptionIcon, {
50
+ value: option.value,
51
+ icon: option.icon,
52
+ label: option.label
53
+ }, option.value);
54
+ })
50
55
  });
51
56
  }
52
57
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["clsx","__","isRTL","textHorizontal","textVertical","SegmentedTextControl","jsx","_jsx","WRITING_MODES","label","value","icon","WritingModeControl","className","onChange","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;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE7D,MAAMC,aAAa,GAAG,CACrB;EACCC,KAAK,EAAER,EAAE,CAAE,YAAa,CAAC;EACzBS,KAAK,EAAE,eAAe;EACtBC,IAAI,EAAER;AACP,CAAC,EACD;EACCM,KAAK,EAAER,EAAE,CAAE,UAAW,CAAC;EACvBS,KAAK,EAAER,KAAK,CAAC,CAAC,GAAG,aAAa,GAAG,aAAa;EAC9CS,IAAI,EAAEP;AACP,CAAC,CACD;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASQ,kBAAkBA,CAAE;EAAEC,SAAS;EAAEH,KAAK;EAAEI;AAAS,CAAC,EAAG;EAC5E,oBACCP,IAAA,CAACF,oBAAoB;IACpBI,KAAK,EAAGR,EAAE,CAAE,aAAc,CAAG;IAC7Bc,OAAO,EAAGP,aAAe;IACzBK,SAAS,EAAGb,IAAI,CAAE,mCAAmC,EAAEa,SAAU,CAAG;IACpEH,KAAK,EAAGA,KAAO;IACfI,QAAQ,EAAKE,QAAQ,IAAM;MAC1BF,QAAQ,CAAEE,QAAQ,KAAKN,KAAK,GAAGO,SAAS,GAAGD,QAAS,CAAC;IACtD;EAAG,CACH,CAAC;AAEJ","ignoreList":[]}
1
+ {"version":3,"names":["clsx","__","isRTL","textHorizontal","textVertical","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOptionIcon","ToggleGroupControlOptionIcon","jsx","_jsx","WRITING_MODES","label","value","icon","WritingModeControl","className","onChange","isDeselectable","__nextHasNoMarginBottom","__next40pxDefaultSize","newValue","undefined","children","map","option"],"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';\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n} from '@wordpress/components';\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<ToggleGroupControl\n\t\t\tisDeselectable\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Orientation' ) }\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\t\t{ WRITING_MODES.map( ( option ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\t\t\tkey={ option.value }\n\t\t\t\t\t\tvalue={ option.value }\n\t\t\t\t\t\ticon={ option.icon }\n\t\t\t\t\t\tlabel={ option.label }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ToggleGroupControl>\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;AAC/D,SACCC,gCAAgC,IAAIC,kBAAkB,EACtDC,0CAA0C,IAAIC,4BAA4B,QACpE,uBAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE/B,MAAMC,aAAa,GAAG,CACrB;EACCC,KAAK,EAAEX,EAAE,CAAE,YAAa,CAAC;EACzBY,KAAK,EAAE,eAAe;EACtBC,IAAI,EAAEX;AACP,CAAC,EACD;EACCS,KAAK,EAAEX,EAAE,CAAE,UAAW,CAAC;EACvBY,KAAK,EAAEX,KAAK,CAAC,CAAC,GAAG,aAAa,GAAG,aAAa;EAC9CY,IAAI,EAAEV;AACP,CAAC,CACD;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASW,kBAAkBA,CAAE;EAAEC,SAAS;EAAEH,KAAK;EAAEI;AAAS,CAAC,EAAG;EAC5E,oBACCP,IAAA,CAACJ,kBAAkB;IAClBY,cAAc;IACdC,uBAAuB;IACvBC,qBAAqB;IACrBR,KAAK,EAAGX,EAAE,CAAE,aAAc,CAAG;IAC7Be,SAAS,EAAGhB,IAAI,CAAE,mCAAmC,EAAEgB,SAAU,CAAG;IACpEH,KAAK,EAAGA,KAAO;IACfI,QAAQ,EAAKI,QAAQ,IAAM;MAC1BJ,QAAQ,CAAEI,QAAQ,KAAKR,KAAK,GAAGS,SAAS,GAAGD,QAAS,CAAC;IACtD,CAAG;IAAAE,QAAA,EAEDZ,aAAa,CAACa,GAAG,CAAIC,MAAM,IAAM;MAClC,oBACCf,IAAA,CAACF,4BAA4B;QAE5BK,KAAK,EAAGY,MAAM,CAACZ,KAAO;QACtBC,IAAI,EAAGW,MAAM,CAACX,IAAM;QACpBF,KAAK,EAAGa,MAAM,CAACb;MAAO,GAHhBa,MAAM,CAACZ,KAIb,CAAC;IAEJ,CAAE;EAAC,CACgB,CAAC;AAEvB","ignoreList":[]}
@@ -12,13 +12,14 @@ import InspectorControls from '../components/inspector-controls';
12
12
  import { cleanEmptyObject } from './utils';
13
13
  import { store as blockEditorStore } from '../store';
14
14
  import { default as StylesBackgroundPanel, useHasBackgroundPanel, hasBackgroundImageValue } from '../components/global-styles/background-panel';
15
- import { globalStylesDataKey, globalStylesLinksDataKey } from '../store/private-keys';
15
+ import { globalStylesDataKey } from '../store/private-keys';
16
16
  import { jsx as _jsx } from "react/jsx-runtime";
17
17
  export const BACKGROUND_SUPPORT_KEY = 'background';
18
18
 
19
- // Initial control values where no block style is set.
20
- const BACKGROUND_DEFAULT_VALUES = {
21
- backgroundSize: 'cover'
19
+ // Initial control values.
20
+ export const BACKGROUND_BLOCK_DEFAULT_VALUES = {
21
+ backgroundSize: 'cover',
22
+ backgroundPosition: '50% 50%' // used only when backgroundSize is 'contain'.
22
23
  };
23
24
 
24
25
  /**
@@ -40,24 +41,21 @@ export function hasBackgroundSupport(blockName, feature = 'any') {
40
41
  return !!support?.[feature];
41
42
  }
42
43
  export function setBackgroundStyleDefaults(backgroundStyle) {
43
- if (!backgroundStyle) {
44
+ if (!backgroundStyle || !backgroundStyle?.backgroundImage?.url) {
44
45
  return;
45
46
  }
46
- const backgroundImage = backgroundStyle?.backgroundImage;
47
47
  let backgroundStylesWithDefaults;
48
48
 
49
49
  // Set block background defaults.
50
- if (!!backgroundImage?.url) {
51
- if (!backgroundStyle?.backgroundSize) {
52
- backgroundStylesWithDefaults = {
53
- backgroundSize: 'cover'
54
- };
55
- }
56
- if ('contain' === backgroundStyle?.backgroundSize && !backgroundStyle?.backgroundPosition) {
57
- backgroundStylesWithDefaults = {
58
- backgroundPosition: 'center'
59
- };
60
- }
50
+ if (!backgroundStyle?.backgroundSize) {
51
+ backgroundStylesWithDefaults = {
52
+ backgroundSize: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundSize
53
+ };
54
+ }
55
+ if ('contain' === backgroundStyle?.backgroundSize && !backgroundStyle?.backgroundPosition) {
56
+ backgroundStylesWithDefaults = {
57
+ backgroundPosition: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundPosition
58
+ };
61
59
  }
62
60
  return backgroundStylesWithDefaults;
63
61
  }
@@ -115,8 +113,7 @@ export function BackgroundImagePanel({
115
113
  }) {
116
114
  const {
117
115
  style,
118
- inheritedValue,
119
- _links
116
+ inheritedValue
120
117
  } = useSelect(select => {
121
118
  const {
122
119
  getBlockAttributes,
@@ -125,8 +122,8 @@ export function BackgroundImagePanel({
125
122
  const _settings = getSettings();
126
123
  return {
127
124
  style: getBlockAttributes(clientId)?.style,
128
- _links: _settings[globalStylesLinksDataKey],
129
125
  /*
126
+ * To ensure we pass down the right inherited values:
130
127
  * @TODO 1. Pass inherited value down to all block style controls,
131
128
  * See: packages/block-editor/src/hooks/style.js
132
129
  * @TODO 2. Add support for block style variations,
@@ -154,11 +151,10 @@ export function BackgroundImagePanel({
154
151
  inheritedValue: inheritedValue,
155
152
  as: BackgroundInspectorControl,
156
153
  panelId: clientId,
157
- defaultValues: BACKGROUND_DEFAULT_VALUES,
154
+ defaultValues: BACKGROUND_BLOCK_DEFAULT_VALUES,
158
155
  settings: updatedSettings,
159
156
  onChange: onChange,
160
- value: style,
161
- themeFileURIs: _links?.['wp:theme-file']
157
+ value: style
162
158
  });
163
159
  }
164
160
  export default {
@@ -1 +1 @@
1
- {"version":3,"names":["getBlockSupport","useSelect","useCallback","InspectorControls","cleanEmptyObject","store","blockEditorStore","default","StylesBackgroundPanel","useHasBackgroundPanel","hasBackgroundImageValue","globalStylesDataKey","globalStylesLinksDataKey","jsx","_jsx","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","group","BackgroundImagePanel","clientId","setAttributes","settings","inheritedValue","_links","select","getBlockAttributes","getSettings","_settings","blocks","onChange","newStyle","updatedSettings","as","panelId","defaultValues","value","themeFileURIs","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';\nimport {\n\tglobalStylesDataKey,\n\tglobalStylesLinksDataKey,\n} from '../store/private-keys';\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, inheritedValue, _links } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst _settings = getSettings();\n\t\t\treturn {\n\t\t\t\tstyle: getBlockAttributes( clientId )?.style,\n\t\t\t\t_links: _settings[ globalStylesLinksDataKey ],\n\t\t\t\t/*\n\t\t\t\t * @TODO 1. Pass inherited value down to all block style controls,\n\t\t\t\t * See: packages/block-editor/src/hooks/style.js\n\t\t\t\t * @TODO 2. Add support for block style variations,\n\t\t\t\t * See implementation: packages/block-editor/src/hooks/block-style-variation.js\n\t\t\t\t */\n\t\t\t\tinheritedValue:\n\t\t\t\t\t_settings[ globalStylesDataKey ]?.blocks?.[ name ],\n\t\t\t};\n\t\t},\n\t\t[ clientId, name ]\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 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\tinheritedValue={ inheritedValue }\n\t\t\tas={ BackgroundInspectorControl }\n\t\t\tpanelId={ clientId }\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\tthemeFileURIs={ _links?.[ 'wp:theme-file' ] }\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;AACr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,CAAEtC,wBAAwB,CAAE;MAC7C;AACJ;AACA;AACA;AACA;AACA;MACIiC,cAAc,EACbK,SAAS,CAAEvC,mBAAmB,CAAE,EAAEwC,MAAM,GAAIrB,IAAI;IAClD,CAAC;EACF,CAAC,EACD,CAAEY,QAAQ,EAAEZ,IAAI,CACjB,CAAC;EAED,IACC,CAAErB,qBAAqB,CAAEmC,QAAS,CAAC,IACnC,CAAE1B,oBAAoB,CAAEY,IAAI,EAAE,iBAAkB,CAAC,EAChD;IACD,OAAO,IAAI;EACZ;EAEA,MAAMsB,QAAQ,GAAKC,QAAQ,IAAM;IAChCV,aAAa,CAAE;MACdZ,KAAK,EAAE3B,gBAAgB,CAAEiD,QAAS;IACnC,CAAE,CAAC;EACJ,CAAC;EAED,MAAMC,eAAe,GAAG;IACvB,GAAGV,QAAQ;IACXZ,UAAU,EAAE;MACX,GAAGY,QAAQ,CAACZ,UAAU;MACtBf,cAAc,EACb2B,QAAQ,EAAEZ,UAAU,EAAEf,cAAc,IACpCC,oBAAoB,CAAEY,IAAI,EAAE,gBAAiB;IAC/C;EACD,CAAC;EAED,oBACChB,IAAA,CAACN,qBAAqB;IACrBqC,cAAc,EAAGA,cAAgB;IACjCU,EAAE,EAAGpB,0BAA4B;IACjCqB,OAAO,EAAGd,QAAU;IACpBe,aAAa,EAAGzC,yBAA2B;IAC3C4B,QAAQ,EAAGU,eAAiB;IAC5BF,QAAQ,EAAGA,QAAU;IACrBM,KAAK,EAAG3B,KAAO;IACf4B,aAAa,EAAGb,MAAM,GAAI,eAAe;EAAI,CAC7C,CAAC;AAEJ;AAEA,eAAe;EACdjB,aAAa;EACb+B,aAAa,EAAE,CAAE,OAAO,CAAE;EAC1BC,UAAU,EAAE3C;AACb,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["getBlockSupport","useSelect","useCallback","InspectorControls","cleanEmptyObject","store","blockEditorStore","default","StylesBackgroundPanel","useHasBackgroundPanel","hasBackgroundImageValue","globalStylesDataKey","jsx","_jsx","BACKGROUND_SUPPORT_KEY","BACKGROUND_BLOCK_DEFAULT_VALUES","backgroundSize","backgroundPosition","hasBackgroundSupport","blockName","feature","support","backgroundImage","backgroundRepeat","setBackgroundStyleDefaults","backgroundStyle","url","backgroundStylesWithDefaults","useBlockProps","name","style","background","backgroundStyles","getBackgroundImageClasses","BackgroundInspectorControl","children","resetAllFilter","attributes","undefined","group","BackgroundImagePanel","clientId","setAttributes","settings","inheritedValue","select","getBlockAttributes","getSettings","_settings","blocks","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';\nimport { globalStylesDataKey } from '../store/private-keys';\n\nexport const BACKGROUND_SUPPORT_KEY = 'background';\n\n// Initial control values.\nexport const BACKGROUND_BLOCK_DEFAULT_VALUES = {\n\tbackgroundSize: 'cover',\n\tbackgroundPosition: '50% 50%', // used only when backgroundSize is 'contain'.\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 || ! backgroundStyle?.backgroundImage?.url ) {\n\t\treturn;\n\t}\n\n\tlet backgroundStylesWithDefaults;\n\n\t// Set block background defaults.\n\tif ( ! backgroundStyle?.backgroundSize ) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundSize: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundSize,\n\t\t};\n\t}\n\n\tif (\n\t\t'contain' === backgroundStyle?.backgroundSize &&\n\t\t! backgroundStyle?.backgroundPosition\n\t) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundPosition:\n\t\t\t\tBACKGROUND_BLOCK_DEFAULT_VALUES.backgroundPosition,\n\t\t};\n\t}\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, inheritedValue } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst _settings = getSettings();\n\t\t\treturn {\n\t\t\t\tstyle: getBlockAttributes( clientId )?.style,\n\t\t\t\t/*\n\t\t\t\t * To ensure we pass down the right inherited values:\n\t\t\t\t * @TODO 1. Pass inherited value down to all block style controls,\n\t\t\t\t * See: packages/block-editor/src/hooks/style.js\n\t\t\t\t * @TODO 2. Add support for block style variations,\n\t\t\t\t * See implementation: packages/block-editor/src/hooks/block-style-variation.js\n\t\t\t\t */\n\t\t\t\tinheritedValue:\n\t\t\t\t\t_settings[ globalStylesDataKey ]?.blocks?.[ name ],\n\t\t\t};\n\t\t},\n\t\t[ clientId, name ]\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 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\tinheritedValue={ inheritedValue }\n\t\t\tas={ BackgroundInspectorControl }\n\t\t\tpanelId={ clientId }\n\t\t\tdefaultValues={ BACKGROUND_BLOCK_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,e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