@wordpress/block-editor 17.0.2-next.v.202608281122.0 → 17.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (382) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/build/components/background-image-control/index.cjs +18 -1
  3. package/build/components/background-image-control/index.cjs.map +2 -2
  4. package/build/components/block-allowed-blocks/modal.cjs +2 -1
  5. package/build/components/block-allowed-blocks/modal.cjs.map +3 -3
  6. package/build/components/block-edit/edit.cjs.map +1 -1
  7. package/build/components/block-inspector/index.cjs +3 -12
  8. package/build/components/block-inspector/index.cjs.map +2 -2
  9. package/build/components/block-list/use-block-props/use-is-hovered.cjs +17 -4
  10. package/build/components/block-list/use-block-props/use-is-hovered.cjs.map +2 -2
  11. package/build/components/block-preview/index.cjs +1 -2
  12. package/build/components/block-preview/index.cjs.map +2 -2
  13. package/build/components/block-switcher/index.cjs +2 -1
  14. package/build/components/block-switcher/index.cjs.map +3 -3
  15. package/build/components/block-toolbar/pattern-overrides-dropdown.cjs +2 -1
  16. package/build/components/block-toolbar/pattern-overrides-dropdown.cjs.map +3 -3
  17. package/build/components/global-styles/border-panel.cjs +19 -42
  18. package/build/components/global-styles/border-panel.cjs.map +2 -2
  19. package/build/components/global-styles/image-settings-panel.cjs.map +1 -1
  20. package/build/components/iframe/index.cjs.map +1 -1
  21. package/build/components/inserter/hooks/use-patterns-paging.cjs.map +1 -1
  22. package/build/components/inserter-draggable-blocks/index.cjs.map +1 -1
  23. package/build/components/inspector-controls-tabs/content-tab.cjs +2 -3
  24. package/build/components/inspector-controls-tabs/content-tab.cjs.map +2 -2
  25. package/build/components/inspector-controls-tabs/styles-tab.cjs +1 -3
  26. package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
  27. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs +1 -2
  28. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs.map +2 -2
  29. package/build/components/inspector-popover-header/index.cjs +5 -4
  30. package/build/components/inspector-popover-header/index.cjs.map +3 -3
  31. package/build/components/link-control/index.cjs.map +2 -2
  32. package/build/components/link-control/search-input.cjs.map +1 -1
  33. package/build/components/list-view/block-select-button.cjs +9 -1
  34. package/build/components/list-view/block-select-button.cjs.map +2 -2
  35. package/build/components/list-view/block.cjs +2 -1
  36. package/build/components/list-view/block.cjs.map +2 -2
  37. package/build/components/list-view/use-list-view-drop-zone.cjs.map +1 -1
  38. package/build/components/media-replace-flow/index.cjs +4 -1
  39. package/build/components/media-replace-flow/index.cjs.map +2 -2
  40. package/build/components/navigable-toolbar/index.cjs +3 -0
  41. package/build/components/navigable-toolbar/index.cjs.map +2 -2
  42. package/build/components/rich-text/event-listeners/enter.cjs +23 -11
  43. package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
  44. package/build/components/rich-text/event-listeners/index.cjs +0 -2
  45. package/build/components/rich-text/event-listeners/index.cjs.map +3 -3
  46. package/build/components/rich-text/event-listeners/input-rules.cjs +4 -2
  47. package/build/components/rich-text/event-listeners/input-rules.cjs.map +2 -2
  48. package/build/components/use-block-drop-zone/index.cjs.map +1 -1
  49. package/build/components/writing-flow/index.cjs +5 -0
  50. package/build/components/writing-flow/index.cjs.map +3 -3
  51. package/build/components/writing-flow/use-arrow-nav.cjs.map +1 -1
  52. package/build/components/writing-flow/use-input.cjs +12 -2
  53. package/build/components/writing-flow/use-input.cjs.map +2 -2
  54. package/build/components/writing-flow/use-tab-nav.cjs +84 -41
  55. package/build/components/writing-flow/use-tab-nav.cjs.map +3 -3
  56. package/build/components/{rich-text/event-listeners/undo-automatic-change.cjs → writing-flow/use-undo-automatic-change.cjs} +18 -15
  57. package/build/components/writing-flow/use-undo-automatic-change.cjs.map +7 -0
  58. package/build/hooks/border.cjs +2 -46
  59. package/build/hooks/border.cjs.map +2 -2
  60. package/build/hooks/generate-fields-from-attributes.cjs.map +1 -1
  61. package/build/hooks/index.cjs +0 -2
  62. package/build/hooks/index.cjs.map +3 -3
  63. package/build/hooks/style.cjs +2 -2
  64. package/build/hooks/style.cjs.map +2 -2
  65. package/build/layouts/flex.cjs +3 -0
  66. package/build/layouts/flex.cjs.map +2 -2
  67. package/build/store/actions.cjs +12 -9
  68. package/build/store/actions.cjs.map +3 -3
  69. package/build-module/components/background-image-control/index.mjs +18 -1
  70. package/build-module/components/background-image-control/index.mjs.map +2 -2
  71. package/build-module/components/block-allowed-blocks/modal.mjs +2 -2
  72. package/build-module/components/block-allowed-blocks/modal.mjs.map +2 -2
  73. package/build-module/components/block-edit/edit.mjs.map +1 -1
  74. package/build-module/components/block-inspector/index.mjs +3 -12
  75. package/build-module/components/block-inspector/index.mjs.map +2 -2
  76. package/build-module/components/block-list/use-block-props/use-is-hovered.mjs +17 -4
  77. package/build-module/components/block-list/use-block-props/use-is-hovered.mjs.map +2 -2
  78. package/build-module/components/block-preview/index.mjs +1 -2
  79. package/build-module/components/block-preview/index.mjs.map +2 -2
  80. package/build-module/components/block-switcher/index.mjs +2 -2
  81. package/build-module/components/block-switcher/index.mjs.map +2 -2
  82. package/build-module/components/block-toolbar/pattern-overrides-dropdown.mjs +3 -6
  83. package/build-module/components/block-toolbar/pattern-overrides-dropdown.mjs.map +2 -2
  84. package/build-module/components/global-styles/border-panel.mjs +19 -42
  85. package/build-module/components/global-styles/border-panel.mjs.map +2 -2
  86. package/build-module/components/global-styles/image-settings-panel.mjs.map +1 -1
  87. package/build-module/components/iframe/index.mjs.map +1 -1
  88. package/build-module/components/inserter/hooks/use-patterns-paging.mjs.map +1 -1
  89. package/build-module/components/inserter-draggable-blocks/index.mjs.map +1 -1
  90. package/build-module/components/inspector-controls-tabs/content-tab.mjs +3 -4
  91. package/build-module/components/inspector-controls-tabs/content-tab.mjs.map +2 -2
  92. package/build-module/components/inspector-controls-tabs/styles-tab.mjs +1 -3
  93. package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
  94. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs +1 -2
  95. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs.map +2 -2
  96. package/build-module/components/inspector-popover-header/index.mjs +6 -7
  97. package/build-module/components/inspector-popover-header/index.mjs.map +2 -2
  98. package/build-module/components/link-control/index.mjs.map +2 -2
  99. package/build-module/components/link-control/search-input.mjs.map +1 -1
  100. package/build-module/components/list-view/block-select-button.mjs +9 -1
  101. package/build-module/components/list-view/block-select-button.mjs.map +2 -2
  102. package/build-module/components/list-view/block.mjs +2 -1
  103. package/build-module/components/list-view/block.mjs.map +2 -2
  104. package/build-module/components/list-view/use-list-view-drop-zone.mjs.map +1 -1
  105. package/build-module/components/media-replace-flow/index.mjs +4 -1
  106. package/build-module/components/media-replace-flow/index.mjs.map +2 -2
  107. package/build-module/components/navigable-toolbar/index.mjs +3 -0
  108. package/build-module/components/navigable-toolbar/index.mjs.map +2 -2
  109. package/build-module/components/rich-text/event-listeners/enter.mjs +23 -11
  110. package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
  111. package/build-module/components/rich-text/event-listeners/index.mjs +0 -2
  112. package/build-module/components/rich-text/event-listeners/index.mjs.map +2 -2
  113. package/build-module/components/rich-text/event-listeners/input-rules.mjs +4 -2
  114. package/build-module/components/rich-text/event-listeners/input-rules.mjs.map +2 -2
  115. package/build-module/components/use-block-drop-zone/index.mjs.map +1 -1
  116. package/build-module/components/writing-flow/index.mjs +5 -0
  117. package/build-module/components/writing-flow/index.mjs.map +2 -2
  118. package/build-module/components/writing-flow/use-arrow-nav.mjs.map +1 -1
  119. package/build-module/components/writing-flow/use-input.mjs +12 -2
  120. package/build-module/components/writing-flow/use-input.mjs.map +2 -2
  121. package/build-module/components/writing-flow/use-tab-nav.mjs +86 -43
  122. package/build-module/components/writing-flow/use-tab-nav.mjs.map +3 -3
  123. package/build-module/components/writing-flow/use-undo-automatic-change.mjs +36 -0
  124. package/build-module/components/writing-flow/use-undo-automatic-change.mjs.map +7 -0
  125. package/build-module/hooks/border.mjs +1 -45
  126. package/build-module/hooks/border.mjs.map +2 -2
  127. package/build-module/hooks/generate-fields-from-attributes.mjs.map +1 -1
  128. package/build-module/hooks/index.mjs +0 -2
  129. package/build-module/hooks/index.mjs.map +2 -2
  130. package/build-module/hooks/style.mjs +3 -2
  131. package/build-module/hooks/style.mjs.map +2 -2
  132. package/build-module/layouts/flex.mjs +3 -0
  133. package/build-module/layouts/flex.mjs.map +2 -2
  134. package/build-module/store/actions.mjs +12 -9
  135. package/build-module/store/actions.mjs.map +2 -2
  136. package/build-style/content-rtl.css +9 -20
  137. package/build-style/content.css +9 -20
  138. package/build-style/style-rtl.css +100 -221
  139. package/build-style/style.css +100 -221
  140. package/package.json +42 -41
  141. package/src/autocompleters/test/block.js +1 -0
  142. package/src/components/alignment-control/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +34 -16
  143. package/src/components/alignment-control/test/{index.jsx → index.jsdom.test.jsx} +2 -1
  144. package/src/components/background-image-control/index.jsx +32 -1
  145. package/src/components/background-image-control/style.scss +5 -3
  146. package/src/components/background-image-control/test/{index.js → index.jsdom.test.js} +1 -0
  147. package/src/components/block-alignment-control/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +68 -13
  148. package/src/components/block-alignment-control/test/{index.jsx → index.jsdom.test.jsx} +2 -1
  149. package/src/components/block-allowed-blocks/modal.jsx +3 -3
  150. package/src/components/block-bindings/test/{use-block-bindings-utils.js → use-block-bindings-utils.jsdom.test.js} +2 -1
  151. package/src/components/block-breadcrumb/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +2 -2
  152. package/src/components/block-breadcrumb/test/{index.jsx → index.jsdom.test.jsx} +1 -0
  153. package/src/components/block-compare/test/__snapshots__/{block-view.jsx.snap → block-view.jsdom.test.jsx.snap} +2 -2
  154. package/src/components/block-compare/test/{block-view.jsx → block-view.jsdom.test.jsx} +1 -0
  155. package/src/components/block-controls/test/{index.jsx → index.jsdom.test.jsx} +1 -0
  156. package/src/components/block-edit/edit.jsx +1 -1
  157. package/src/components/block-edit/test/{edit.jsx → edit.jsdom.test.jsx} +1 -0
  158. package/src/components/block-icon/content.scss +0 -6
  159. package/src/components/block-icon/style.scss +0 -6
  160. package/src/components/block-icon/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +6 -2
  161. package/src/components/block-inspector/index.jsx +3 -11
  162. package/src/components/block-list/content.scss +4 -1
  163. package/src/components/block-list/use-block-props/use-is-hovered.js +24 -5
  164. package/src/components/block-manager/style.scss +2 -0
  165. package/src/components/block-mover/test/mover-description.js +1 -0
  166. package/src/components/block-preview/index.jsx +1 -2
  167. package/src/components/block-preview/test/{index.jsx → index.jsdom.test.jsx} +10 -6
  168. package/src/components/block-selection-clearer/test/{index.jsx → index.jsdom.test.jsx} +24 -19
  169. package/src/components/block-settings-menu/test/{block-mode-toggle.jsx → block-mode-toggle.jsdom.test.jsx} +5 -1
  170. package/src/components/block-styles/test/utils.js +1 -0
  171. package/src/components/block-switcher/index.jsx +3 -3
  172. package/src/components/block-switcher/test/{index.jsx → index.jsdom.test.jsx} +8 -4
  173. package/src/components/block-switcher/test/use-transformed.patterns.js +1 -0
  174. package/src/components/block-switcher/test/utils.js +1 -0
  175. package/src/components/block-title/test/{index.jsx → index.jsdom.test.jsx} +7 -3
  176. package/src/components/block-toolbar/pattern-overrides-dropdown.jsx +3 -6
  177. package/src/components/block-toolbar/style.scss +1 -1
  178. package/src/components/block-toolbar/test/{block-toolbar-icon.jsx → block-toolbar-icon.jsdom.test.jsx} +25 -21
  179. package/src/components/block-variation-picker/content.scss +5 -3
  180. package/src/components/block-vertical-alignment-control/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +55 -11
  181. package/src/components/block-vertical-alignment-control/test/{index.jsx → index.jsdom.test.jsx} +2 -1
  182. package/src/components/block-visibility/test/{use-block-visibility.js → use-block-visibility.jsdom.test.js} +6 -5
  183. package/src/components/block-visibility/test/utils.js +2 -1
  184. package/src/components/border-radius-control/test/{index.jsx → index.jsdom.test.jsx} +8 -1
  185. package/src/components/border-radius-control/test/utils.js +1 -0
  186. package/src/components/button-block-appender/content.scss +1 -1
  187. package/src/components/child-layout-control/test/{index.jsx → index.jsdom.test.jsx} +18 -15
  188. package/src/components/color-palette/test/{control.jsx → control.jsdom.test.jsx} +15 -4
  189. package/src/components/colors/test/utils.js +1 -0
  190. package/src/components/colors/test/{with-colors.jsx → with-colors.jsdom.test.jsx} +4 -3
  191. package/src/components/colors-gradients/test/{control.jsx → control.jsdom.test.jsx} +8 -3
  192. package/src/components/contrast-checker/test/{index.jsx → index.jsdom.test.jsx} +2 -1
  193. package/src/components/default-block-appender/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +4 -4
  194. package/src/components/default-block-appender/test/{index.jsx → index.jsdom.test.jsx} +8 -7
  195. package/src/components/dimensions-tool/test/{index.jsx → index.jsdom.test.jsx} +27 -22
  196. package/src/components/dimensions-tool/test/utils.js +1 -0
  197. package/src/components/duotone-control/test/{index.jsx → index.jsdom.test.jsx} +6 -3
  198. package/src/components/font-sizes/test/fluid-utils.js +1 -0
  199. package/src/components/font-sizes/test/utils.js +1 -0
  200. package/src/components/global-styles/border-panel.jsx +17 -40
  201. package/src/components/global-styles/image-settings-panel.jsx +1 -1
  202. package/src/components/global-styles/inheritance/test/{index.jsx → index.jsdom.test.jsx} +5 -2
  203. package/src/components/global-styles/test/{background-panel.jsx → background-panel.jsdom.test.jsx} +10 -5
  204. package/src/components/global-styles/test/{border-panel.jsx → border-panel.jsdom.test.jsx} +113 -13
  205. package/src/components/global-styles/test/{color-panel.jsx → color-panel.jsdom.test.jsx} +5 -0
  206. package/src/components/global-styles/test/{dimensions-panel.jsx → dimensions-panel.jsdom.test.jsx} +14 -14
  207. package/src/components/global-styles/test/{filters-panel.jsx → filters-panel.jsdom.test.jsx} +7 -4
  208. package/src/components/global-styles/test/{inherited-value-context-core.js → inherited-value-context-core.jsdom.test.js} +10 -9
  209. package/src/components/global-styles/test/{inherited-value-context.jsx → inherited-value-context.jsdom.test.jsx} +18 -17
  210. package/src/components/global-styles/test/{state-control-badges.jsx → state-control-badges.jsdom.test.jsx} +3 -2
  211. package/src/components/global-styles/test/{typography-panel-core.jsx → typography-panel-core.jsdom.test.jsx} +5 -2
  212. package/src/components/global-styles/test/{typography-panel.jsx → typography-panel.jsdom.test.jsx} +17 -12
  213. package/src/components/global-styles/test/typography-utils.js +1 -0
  214. package/src/components/global-styles/test/utils.js +1 -0
  215. package/src/components/grid/style.scss +0 -10
  216. package/src/components/iframe/index.jsx +3 -3
  217. package/src/components/image-editor/test/index.js +1 -0
  218. package/src/components/image-size-control/test/{index.jsx → index.jsdom.test.jsx} +8 -3
  219. package/src/components/inner-blocks/test/__snapshots__/index.jsdom.test.jsx.snap +15 -0
  220. package/src/components/inner-blocks/test/{index.jsx → index.jsdom.test.jsx} +2 -0
  221. package/src/components/inner-content/test/{index.jsx → index.jsdom.test.jsx} +1 -0
  222. package/src/components/inserter/hooks/use-patterns-paging.js +1 -1
  223. package/src/components/inserter/media-tab/test/{hooks.js → hooks.jsdom.test.js} +12 -11
  224. package/src/components/inserter/media-tab/test/{media-panel.jsx → media-panel.jsdom.test.jsx} +15 -12
  225. package/src/components/inserter/style.scss +2 -2
  226. package/src/components/inserter/test/get-appender-label.js +12 -11
  227. package/src/components/inserter/test/search-items.js +1 -0
  228. package/src/components/inserter-draggable-blocks/index.jsx +1 -1
  229. package/src/components/inserter-list-item/style.scss +1 -0
  230. package/src/components/inspector-controls-tabs/content-tab.jsx +7 -14
  231. package/src/components/inspector-controls-tabs/styles-tab.jsx +1 -4
  232. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -8
  233. package/src/components/inspector-popover-header/index.jsx +6 -7
  234. package/src/components/line-height-control/test/{index.jsx → index.jsdom.test.jsx} +3 -0
  235. package/src/components/link-control/index.jsx +3 -0
  236. package/src/components/link-control/search-input.jsx +1 -1
  237. package/src/components/link-control/style.scss +1 -1
  238. package/src/components/link-control/test/{index.jsx → index.jsdom.test.jsx} +52 -42
  239. package/src/components/link-control/test/is-url-like.js +1 -0
  240. package/src/components/link-control/test/{url-normalization.test.jsx → url-normalization.jsdom.test.jsx} +21 -20
  241. package/src/components/link-picker/test/{index.jsx → index.jsdom.test.jsx} +31 -30
  242. package/src/components/list-view/block-select-button.jsx +6 -1
  243. package/src/components/list-view/block.jsx +6 -4
  244. package/src/components/list-view/style.scss +55 -35
  245. package/src/components/list-view/test/use-list-view-drop-zone.js +1 -0
  246. package/src/components/list-view/test/utils.js +1 -0
  247. package/src/components/list-view/use-list-view-drop-zone.js +1 -1
  248. package/src/components/media-placeholder/test/get-computed-accept-attribute.js +1 -0
  249. package/src/components/media-placeholder/test/{index.jsx → index.jsdom.test.jsx} +8 -2
  250. package/src/components/media-replace-flow/index.jsx +6 -1
  251. package/src/components/media-replace-flow/test/{index.jsx → index.jsdom.test.jsx} +3 -0
  252. package/src/components/navigable-toolbar/index.jsx +4 -0
  253. package/src/components/navigable-toolbar/test/index.browser.test.js +50 -0
  254. package/src/components/panel-color-settings/test/{index.jsx → index.jsdom.test.jsx} +3 -0
  255. package/src/components/preset-input-control/test/{index.jsx → index.jsdom.test.jsx} +8 -2
  256. package/src/components/preset-input-control/test/utils.js +1 -0
  257. package/src/components/provider/test/{experimental-provider.jsx → experimental-provider.jsdom.test.jsx} +3 -2
  258. package/src/components/provider/test/{use-block-sync.jsx → use-block-sync.jsdom.test.jsx} +45 -44
  259. package/src/components/recursion-provider/test/{index.jsx → index.jsdom.test.jsx} +1 -0
  260. package/src/components/responsive-block-control/style.scss +1 -0
  261. package/src/components/responsive-block-control/test/{index.jsx → index.jsdom.test.jsx} +6 -3
  262. package/src/components/rich-text/event-listeners/enter.js +29 -14
  263. package/src/components/rich-text/event-listeners/index.js +0 -2
  264. package/src/components/rich-text/event-listeners/input-rules.js +7 -2
  265. package/src/components/spacing-sizes-control/test/{index.jsx → index.jsdom.test.jsx} +23 -20
  266. package/src/components/spacing-sizes-control/test/utils.js +1 -0
  267. package/src/components/url-input/test/{button.jsx → button.jsdom.test.jsx} +4 -1
  268. package/src/components/url-input/test/fixtures/validated-input-control-deprecation.js +2 -0
  269. package/src/components/url-input/test/{index.jsx → index.jsdom.test.jsx} +23 -13
  270. package/src/components/use-block-display-information/test/{index.jsx → index.jsdom.test.jsx} +14 -10
  271. package/src/components/use-block-drop-zone/index.js +2 -2
  272. package/src/components/use-block-drop-zone/test/index.js +1 -0
  273. package/src/components/use-on-block-drop/test/index.js +28 -31
  274. package/src/components/warning/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +2 -2
  275. package/src/components/warning/test/{index.jsx → index.jsdom.test.jsx} +1 -0
  276. package/src/components/writing-flow/index.jsx +5 -0
  277. package/src/components/writing-flow/style.scss +48 -0
  278. package/src/components/writing-flow/test/{index.js → index.jsdom.test.js} +1 -0
  279. package/src/components/writing-flow/use-arrow-nav.js +2 -2
  280. package/src/components/writing-flow/use-input.js +29 -2
  281. package/src/components/writing-flow/use-tab-nav.jsx +155 -70
  282. package/src/components/writing-flow/use-undo-automatic-change.js +40 -0
  283. package/src/elements/test/{index.js → index.jsdom.test.js} +1 -0
  284. package/src/hooks/border.jsx +0 -53
  285. package/src/hooks/generate-fields-from-attributes.js +1 -1
  286. package/src/hooks/index.js +0 -2
  287. package/src/hooks/style.jsx +3 -2
  288. package/src/hooks/test/{align.jsx → align.jsdom.test.jsx} +1 -0
  289. package/src/hooks/test/allowed-blocks.js +1 -0
  290. package/src/hooks/test/{anchor.js → anchor.jsdom.test.js} +1 -0
  291. package/src/hooks/test/{auto-inspector-controls.js → auto-inspector-controls.jsdom.test.js} +1 -0
  292. package/src/hooks/test/{background.jsx → background.jsdom.test.jsx} +5 -2
  293. package/src/hooks/test/{block-style-state.js → block-style-state.jsdom.test.js} +4 -3
  294. package/src/hooks/test/{cross-origin-isolation.js → cross-origin-isolation.jsdom.test.js} +18 -25
  295. package/src/hooks/test/{custom-class-name.jsx → custom-class-name.jsdom.test.jsx} +1 -0
  296. package/src/hooks/test/{dimensions.js → dimensions.jsdom.test.js} +1 -0
  297. package/src/hooks/test/{duotone.js → duotone.jsdom.test.js} +1 -0
  298. package/src/hooks/test/{font-size.js → font-size.jsdom.test.js} +1 -0
  299. package/src/hooks/test/gap.js +1 -0
  300. package/src/hooks/test/generate-fields-from-attributes.js +1 -0
  301. package/src/hooks/test/generated-class-name.js +1 -0
  302. package/src/hooks/test/{inherited-value-wiring.jsx → inherited-value-wiring.jsdom.test.jsx} +49 -51
  303. package/src/hooks/test/{layout-child.js → layout-child.jsdom.test.js} +1 -0
  304. package/src/hooks/test/{layout.js → layout.jsdom.test.js} +1 -0
  305. package/src/hooks/test/metadata.js +1 -0
  306. package/src/hooks/test/preset-round-trip.js +2 -0
  307. package/src/hooks/test/settings.jsx +1 -0
  308. package/src/hooks/test/state-utils.js +1 -0
  309. package/src/hooks/test/{style.jsx → style.jsdom.test.jsx} +1 -0
  310. package/src/hooks/test/{text-align.jsx → text-align.jsdom.test.jsx} +1 -0
  311. package/src/hooks/test/{use-typography-props.js → use-typography-props.jsdom.test.js} +1 -0
  312. package/src/hooks/test/{utils.js → utils.jsdom.test.js} +1 -0
  313. package/src/layouts/flex.jsx +7 -0
  314. package/src/layouts/test/{constrained.jsx → constrained.jsdom.test.jsx} +6 -3
  315. package/src/layouts/test/{flex.jsx → flex.jsdom.test.jsx} +52 -2
  316. package/src/layouts/test/{flow.js → flow.jsdom.test.js} +1 -0
  317. package/src/layouts/test/{grid.jsx → grid.jsdom.test.jsx} +5 -2
  318. package/src/layouts/test/utils.js +1 -0
  319. package/src/store/actions.js +14 -12
  320. package/src/store/test/{actions.js → actions.jsdom.test.js} +50 -49
  321. package/src/store/test/array.js +1 -0
  322. package/src/store/test/get-block-settings.js +1 -0
  323. package/src/store/test/performance.js +2 -1
  324. package/src/store/test/private-actions.js +1 -0
  325. package/src/store/test/private-selectors.js +13 -3
  326. package/src/store/test/reducer.js +37 -8
  327. package/src/store/test/{registry-selectors.js → registry-selectors.jsdom.test.js} +9 -0
  328. package/src/store/test/{selectors.jsx → selectors.jsdom.test.jsx} +13 -3
  329. package/src/style.scss +1 -1
  330. package/src/utils/test/block-bindings.js +1 -0
  331. package/src/utils/test/color-values.js +1 -0
  332. package/src/utils/test/{dom.jsx → dom.jsdom.test.jsx} +38 -43
  333. package/src/utils/test/format-font-style.js +1 -0
  334. package/src/utils/test/format-font-weight.js +1 -0
  335. package/src/utils/test/get-font-styles-and-weights.js +1 -0
  336. package/src/utils/test/math.js +1 -0
  337. package/src/utils/test/object.js +1 -0
  338. package/src/utils/test/pasting.js +1 -0
  339. package/src/utils/test/selection.js +1 -0
  340. package/src/utils/test/sorting.js +1 -0
  341. package/src/utils/test/transform-styles.js +2 -1
  342. package/build/components/rich-text/event-listeners/undo-automatic-change.cjs.map +0 -7
  343. package/build/hooks/block-fields/fields-dropdown-menu.cjs +0 -67
  344. package/build/hooks/block-fields/fields-dropdown-menu.cjs.map +0 -7
  345. package/build/hooks/block-fields/index.cjs +0 -238
  346. package/build/hooks/block-fields/index.cjs.map +0 -7
  347. package/build/hooks/block-fields/link/index.cjs +0 -174
  348. package/build/hooks/block-fields/link/index.cjs.map +0 -7
  349. package/build/hooks/block-fields/media/index.cjs +0 -262
  350. package/build/hooks/block-fields/media/index.cjs.map +0 -7
  351. package/build/hooks/block-fields/rich-text/index.cjs +0 -146
  352. package/build/hooks/block-fields/rich-text/index.cjs.map +0 -7
  353. package/build/hooks/block-fields/use-inspector-popover-placement.cjs +0 -41
  354. package/build/hooks/block-fields/use-inspector-popover-placement.cjs.map +0 -7
  355. package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs +0 -33
  356. package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs.map +0 -7
  357. package/build-module/hooks/block-fields/fields-dropdown-menu.mjs +0 -46
  358. package/build-module/hooks/block-fields/fields-dropdown-menu.mjs.map +0 -7
  359. package/build-module/hooks/block-fields/index.mjs +0 -210
  360. package/build-module/hooks/block-fields/index.mjs.map +0 -7
  361. package/build-module/hooks/block-fields/link/index.mjs +0 -141
  362. package/build-module/hooks/block-fields/link/index.mjs.map +0 -7
  363. package/build-module/hooks/block-fields/media/index.mjs +0 -241
  364. package/build-module/hooks/block-fields/media/index.mjs.map +0 -7
  365. package/build-module/hooks/block-fields/rich-text/index.mjs +0 -115
  366. package/build-module/hooks/block-fields/rich-text/index.mjs.map +0 -7
  367. package/build-module/hooks/block-fields/use-inspector-popover-placement.mjs +0 -16
  368. package/build-module/hooks/block-fields/use-inspector-popover-placement.mjs.map +0 -7
  369. package/src/components/color-palette/test/__snapshots__/control.jsx.snap +0 -143
  370. package/src/components/inner-blocks/test/__snapshots__/index.jsx.snap +0 -15
  371. package/src/components/rich-text/event-listeners/undo-automatic-change.js +0 -39
  372. package/src/hooks/block-fields/fields-dropdown-menu.jsx +0 -47
  373. package/src/hooks/block-fields/index.jsx +0 -302
  374. package/src/hooks/block-fields/link/index.jsx +0 -155
  375. package/src/hooks/block-fields/link/styles.scss +0 -18
  376. package/src/hooks/block-fields/media/index.jsx +0 -269
  377. package/src/hooks/block-fields/media/styles.scss +0 -77
  378. package/src/hooks/block-fields/rich-text/index.jsx +0 -123
  379. package/src/hooks/block-fields/rich-text/styles.scss +0 -24
  380. package/src/hooks/block-fields/styles.scss +0 -33
  381. package/src/hooks/block-fields/use-inspector-popover-placement.js +0 -16
  382. /package/src/components/block-icon/test/{index.jsx → index.jsdom.test.jsx} +0 -0
@@ -0,0 +1,48 @@
1
+ @use "@wordpress/base-styles/colors" as *;
2
+ @use "@wordpress/base-styles/variables" as *;
3
+
4
+ /* The stop element is invisible, so its focus indication is drawn around the
5
+ canvas it stands for. For the iframed canvas it is an overlay instead of
6
+ an outline, because Safari paints an outline on an iframe element
7
+ underneath the iframe's content. */
8
+ .block-editor-iframe__scale-container > .block-editor-writing-flow__canvas-stop:focus::after {
9
+ content: "";
10
+ position: absolute;
11
+ inset: 0;
12
+ z-index: 1;
13
+ pointer-events: none;
14
+ border: var(--wp-admin-border-width-focus) solid var(--wp-admin-theme-color);
15
+ }
16
+
17
+ .block-editor-writing-flow__canvas-stop:focus + .block-editor-writing-flow {
18
+ outline: var(--wp-admin-border-width-focus) solid var(--wp-admin-theme-color);
19
+ outline-offset: calc(-1 * var(--wp-admin-border-width-focus));
20
+ }
21
+
22
+ /* Looks like a tooltip. Shown at the top of the canvas while the stop is
23
+ focused. Sticky, because on the widgets screen the stop spans scrolling
24
+ content and the hint must stay in view; anywhere else there is nothing
25
+ to scroll and it stays at the top of the canvas. */
26
+ .block-editor-writing-flow__canvas-stop-hint {
27
+ display: none;
28
+ position: sticky;
29
+ top: $grid-unit-20;
30
+ margin-inline: auto;
31
+ width: fit-content;
32
+ z-index: 2;
33
+ background: $black;
34
+ font-family: $default-font;
35
+ border-radius: $radius-medium;
36
+ color: $gray-100;
37
+ text-align: center;
38
+ line-height: 1.4;
39
+ font-size: 12px;
40
+ padding: $grid-unit-05 $grid-unit-10;
41
+ box-shadow: $elevation-small;
42
+ white-space: nowrap;
43
+ pointer-events: none;
44
+ }
45
+
46
+ .block-editor-writing-flow__canvas-stop:focus > .block-editor-writing-flow__canvas-stop-hint {
47
+ display: block;
48
+ }
@@ -1,3 +1,4 @@
1
+ import { beforeAll, describe, expect, it } from 'vitest';
1
2
  import { UP, DOWN, LEFT, RIGHT } from '@wordpress/keycodes';
2
3
  import { isNavigationCandidate } from '../use-arrow-nav';
3
4
 
@@ -327,9 +327,9 @@ export default function useArrowNav() {
327
327
  return;
328
328
  }
329
329
 
330
- // When presing any key other than up or down, the initial vertical
330
+ // When pressing any key other than up or down, the initial vertical
331
331
  // position must ALWAYS be reset. The vertical position is saved so
332
- // it can be restored as well as possible on sebsequent vertical
332
+ // it can be restored as well as possible on subsequent vertical
333
333
  // arrow key presses. It may not always be possible to restore the
334
334
  // exact same position (such as at an empty line), so it wouldn't be
335
335
  // good to compute the position right before any vertical arrow key
@@ -47,6 +47,20 @@ export default function useInput() {
47
47
 
48
48
  return useRefEffect( ( node ) => {
49
49
  function onBeforeInput( event ) {
50
+ // Enter in an editable is handled here instead of on keydown:
51
+ // moving focus while the keydown is still being handled leaves
52
+ // the iOS keyboard's auto-capitalization stale.
53
+ if (
54
+ event.inputType === 'insertParagraph' &&
55
+ ! event.defaultPrevented &&
56
+ ! hasMultiSelection()
57
+ ) {
58
+ onKeyDown( event );
59
+ if ( event.defaultPrevented ) {
60
+ return;
61
+ }
62
+ }
63
+
50
64
  // If writing flow is editable, never allow the browser to alter
51
65
  // the DOM outside of an editable element within a block. This
52
66
  // will cause React errors (and the DOM should only be altered in
@@ -76,12 +90,25 @@ export default function useInput() {
76
90
  }
77
91
 
78
92
  if ( ! hasMultiSelection() ) {
79
- if ( event.keyCode === ENTER ) {
80
- if ( event.shiftKey ) {
93
+ if (
94
+ event.keyCode === ENTER ||
95
+ event.inputType === 'insertParagraph'
96
+ ) {
97
+ if (
98
+ event.shiftKey ||
99
+ // Editables are handled on beforeinput.
100
+ ( event.type === 'keydown' &&
101
+ event.target.ownerDocument.activeElement
102
+ .isContentEditable )
103
+ ) {
81
104
  return;
82
105
  }
83
106
 
84
107
  const clientId = getSelectedBlockClientId();
108
+ if ( ! clientId ) {
109
+ return;
110
+ }
111
+
85
112
  const blockName = getBlockName( clientId );
86
113
  const selectionStart = getSelectionStart();
87
114
  const selectionEnd = getSelectionEnd();
@@ -1,16 +1,37 @@
1
1
  import { focus, isFormElement } from '@wordpress/dom';
2
- import { TAB } from '@wordpress/keycodes';
2
+ import { TAB, withIgnoreIMEEvents } from '@wordpress/keycodes';
3
+ import { __ } from '@wordpress/i18n';
3
4
  import { useSelect, useDispatch } from '@wordpress/data';
4
- import { useRefEffect, useMergeRefs } from '@wordpress/compose';
5
+ import { useRefEffect, useMergeRefs, useInstanceId } from '@wordpress/compose';
5
6
  import { useRef } from '@wordpress/element';
6
7
  import { store as blockEditorStore } from '../../store';
7
8
  import { isInSameBlock, isInsideRootBlock } from '../../utils/dom';
8
9
  import { unlock } from '../../lock-unlock';
9
10
 
11
+ /**
12
+ * Spans the element over the canvas, so it is always at least partially in
13
+ * view and focussing it never scrolls the content. Fixed positioning would
14
+ * achieve that too, but makes Safari composite the scrollable canvas on a
15
+ * layer sized to the whole document instead of the visible pane.
16
+ */
17
+ const PREVENT_SCROLL_ON_FOCUS = {
18
+ position: 'absolute',
19
+ inset: 0,
20
+ pointerEvents: 'none',
21
+ outline: 'none',
22
+ };
23
+
24
+ // Keys that move focus from the canvas stop into the canvas.
25
+ const ENTRY_KEYS = [ 'Enter', ' ', 'F2', 'Escape' ];
26
+
10
27
  export default function useTabNav() {
11
28
  const containerRef = /** @type {typeof useRef<HTMLElement>} */ ( useRef )();
12
29
  const focusCaptureBeforeRef = useRef();
13
30
  const focusCaptureAfterRef = useRef();
31
+ const hintId = useInstanceId(
32
+ useTabNav,
33
+ 'block-editor-writing-flow__canvas-stop-hint'
34
+ );
14
35
 
15
36
  const {
16
37
  hasMultiSelection,
@@ -19,6 +40,7 @@ export default function useTabNav() {
19
40
  getBlockOrder,
20
41
  getLastFocus,
21
42
  getSectionRootClientId,
43
+ getEditedContentOnlySection,
22
44
  isZoomOut,
23
45
  } = unlock( useSelect( blockEditorStore ) );
24
46
  const { setLastFocus } = unlock( useDispatch( blockEditorStore ) );
@@ -27,16 +49,17 @@ export default function useTabNav() {
27
49
  // capturing on the focus capture elements.
28
50
  const noCaptureRef = useRef();
29
51
 
30
- function onFocusCapture( event ) {
31
- const canvasElement =
32
- containerRef.current.ownerDocument === event.target.ownerDocument
33
- ? containerRef.current
34
- : containerRef.current.ownerDocument.defaultView.frameElement;
52
+ // The canvas is a single stop in the page's tab order, and going in is
53
+ // an explicit action on it. Focus returns to the place it last left the
54
+ // canvas from.
55
+ function enterCanvas() {
56
+ // Focus the canvas window first. The stop is in the parent document,
57
+ // and when Firefox focuses an element in another document, it does
58
+ // not move window focus, so the caret would be restored but key
59
+ // presses would keep going to the parent page.
60
+ containerRef.current.ownerDocument.defaultView.focus();
35
61
 
36
- // Do not capture incoming focus if set by us in WritingFlow.
37
- if ( noCaptureRef.current ) {
38
- noCaptureRef.current = null;
39
- } else if ( hasMultiSelection() ) {
62
+ if ( hasMultiSelection() ) {
40
63
  containerRef.current.focus();
41
64
  } else if ( getSelectedBlockClientId() ) {
42
65
  if ( getLastFocus()?.current ) {
@@ -68,36 +91,107 @@ export default function useTabNav() {
68
91
  .focus();
69
92
  } else {
70
93
  // If we don't have any section root, focus the canvas.
71
- canvasElement.focus();
94
+ containerRef.current.focus();
72
95
  }
73
96
  } else {
74
- const isBefore =
75
- // eslint-disable-next-line no-bitwise
76
- event.target.compareDocumentPosition( canvasElement ) &
77
- event.target.DOCUMENT_POSITION_FOLLOWING;
78
97
  const tabbables = focus.tabbable.find( containerRef.current );
79
98
  if ( tabbables.length ) {
80
- const next = isBefore
81
- ? tabbables[ 0 ]
82
- : tabbables[ tabbables.length - 1 ];
83
- next.focus();
99
+ tabbables[ 0 ].focus();
100
+ } else {
101
+ // Nothing in the canvas is tabbable. Entering still enters:
102
+ // keys go to the canvas, and a block can be selected with
103
+ // the arrow keys or a click.
104
+ containerRef.current.focus();
84
105
  }
85
106
  }
86
107
  }
87
108
 
109
+ function onStopKeyDown( event ) {
110
+ if (
111
+ event.defaultPrevented ||
112
+ event.ctrlKey ||
113
+ event.metaKey ||
114
+ event.altKey
115
+ ) {
116
+ return;
117
+ }
118
+
119
+ const { key } = event;
120
+
121
+ if ( ! event.shiftKey && ENTRY_KEYS.includes( key ) ) {
122
+ event.preventDefault();
123
+ enterCanvas();
124
+ return;
125
+ }
126
+
127
+ // Shift+Tab leaves the canvas on its own, because the stop is the
128
+ // first element before it. Plain Tab would move into the content,
129
+ // so move focus to the first tabbable element past the canvas.
130
+ if ( key === 'Tab' && ! event.shiftKey ) {
131
+ event.preventDefault();
132
+ focus.tabbable.findNext( focusCaptureAfterRef.current )?.focus();
133
+ }
134
+ }
135
+
136
+ // Focus arriving on the stop engages the canvas right away, like a
137
+ // text field that starts editing when focused. Only Escape parks
138
+ // focus on the stop, giving Tab traction again: from a parked stop,
139
+ // Tab moves to the interface around the canvas, not the content.
140
+ function onStopFocus() {
141
+ if ( noCaptureRef.current ) {
142
+ noCaptureRef.current = null;
143
+ return;
144
+ }
145
+ enterCanvas();
146
+ }
147
+
88
148
  const before = (
89
149
  <div
90
150
  ref={ focusCaptureBeforeRef }
91
151
  tabIndex="0"
92
- onFocus={ onFocusCapture }
93
- />
152
+ role="button"
153
+ aria-label={ __( 'Editor canvas' ) }
154
+ aria-describedby={ hintId }
155
+ className="block-editor-writing-flow__canvas-stop"
156
+ style={ PREVENT_SCROLL_ON_FOCUS }
157
+ onFocus={ onStopFocus }
158
+ onKeyDown={ onStopKeyDown }
159
+ // Assistive technology activates a button with a click event,
160
+ // not a key press. Pointer clicks pass through the element, so
161
+ // a click can only come from such an activation.
162
+ onClick={ enterCanvas }
163
+ >
164
+ { /* The hint is also the button's description for assistive
165
+ technology. Content hidden with `display: none` still
166
+ works for `aria-describedby`. */ }
167
+ <div
168
+ className="block-editor-writing-flow__canvas-stop-hint"
169
+ id={ hintId }
170
+ >
171
+ { __( 'Press Enter to edit the document' ) }
172
+ </div>
173
+ </div>
94
174
  );
95
175
 
176
+ // Focus landing on the element after the canvas enters it, the same
177
+ // as focus landing on the stop before it.
178
+ function onFocusCapture() {
179
+ // Do not act on focus set by the tab handler below, which moves
180
+ // focus here so that the default behaviour (moving focus to the
181
+ // next tabbable element) continues from this element.
182
+ if ( noCaptureRef.current ) {
183
+ noCaptureRef.current = null;
184
+ return;
185
+ }
186
+ enterCanvas();
187
+ }
188
+
96
189
  const after = (
97
190
  <div
98
191
  ref={ focusCaptureAfterRef }
99
192
  tabIndex="0"
100
193
  onFocus={ onFocusCapture }
194
+ style={ PREVENT_SCROLL_ON_FOCUS }
101
195
  />
102
196
  );
103
197
 
@@ -107,12 +201,39 @@ export default function useTabNav() {
107
201
  return;
108
202
  }
109
203
 
204
+ // Escape steps out of the canvas onto its stop. Everything with
205
+ // a stronger claim on the key runs first: handlers deeper in
206
+ // the tree, capture handlers, and listeners registered earlier
207
+ // on this node, like the automatic change undo. If the key is
208
+ // still unclaimed here, nothing else wants it.
209
+ if (
210
+ event.key === 'Escape' &&
211
+ ! event.shiftKey &&
212
+ ! event.ctrlKey &&
213
+ ! event.metaKey &&
214
+ ! event.altKey
215
+ ) {
216
+ // While a content-only section is being edited, Escape first
217
+ // stops editing it. That handler lives in the parent
218
+ // document and runs after this one, so leave the key to it.
219
+ if ( getEditedContentOnlySection() ) {
220
+ return;
221
+ }
222
+ if ( focusCaptureBeforeRef.current ) {
223
+ event.preventDefault();
224
+ // Park on the stop instead of engaging the canvas,
225
+ // which is what focus arriving on it normally does.
226
+ noCaptureRef.current = true;
227
+ focusCaptureBeforeRef.current.focus();
228
+ }
229
+ return;
230
+ }
231
+
110
232
  // In Edit mode, Tab should focus the first tabbable element after
111
233
  // the content, which is normally the sidebar (with block controls)
112
234
  // and Shift+Tab should focus the first tabbable element before the
113
235
  // content, which is normally the block toolbar.
114
- // Arrow keys can be used, and Tab and arrow keys can be used in
115
- // Navigation mode (press Esc), to navigate through blocks.
236
+ // Arrow keys can be used to navigate through blocks.
116
237
  if ( event.keyCode !== TAB ) {
117
238
  return;
118
239
  }
@@ -155,17 +276,15 @@ export default function useTabNav() {
155
276
  ) {
156
277
  return;
157
278
  }
279
+
158
280
  const next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef;
159
281
 
160
- // Disable focus capturing on the focus capture element, so it
161
- // doesn't refocus this block and so it allows default behaviour
162
- // (moving focus to the next tabbable element).
282
+ // Disable the focus forwarding on the focus capture element, so
283
+ // it allows default behaviour (moving focus to the next tabbable
284
+ // element).
163
285
  noCaptureRef.current = true;
164
286
 
165
- // Focusing the focus capture element, which is located above and
166
- // below the editor, should not scroll the page all the way up or
167
- // down.
168
- next.current.focus( { preventScroll: true } );
287
+ next.current.focus();
169
288
  }
170
289
 
171
290
  function onFocusOut( event ) {
@@ -191,48 +310,14 @@ export default function useTabNav() {
191
310
  }
192
311
  }
193
312
 
194
- // When tabbing back to an element in block list, this event handler prevents scrolling if the
195
- // focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph
196
- // when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the
197
- // top or bottom of the document.
198
- //
199
- // Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this
200
- // earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.
201
- // https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters
202
- function preventScrollOnTab( event ) {
203
- if ( event.keyCode !== TAB ) {
204
- return;
205
- }
206
-
207
- if ( event.target?.getAttribute( 'role' ) === 'region' ) {
208
- return;
209
- }
210
-
211
- if ( containerRef.current === event.target ) {
212
- return;
213
- }
214
-
215
- const isShift = event.shiftKey;
216
- const direction = isShift ? 'findPrevious' : 'findNext';
217
- const target = focus.tabbable[ direction ]( event.target );
218
- // Only do something when the next tabbable is a focus capture div (before/after)
219
- if (
220
- target === focusCaptureBeforeRef.current ||
221
- target === focusCaptureAfterRef.current
222
- ) {
223
- event.preventDefault();
224
- target.focus( { preventScroll: true } );
225
- }
226
- }
313
+ // During an IME composition, Escape and Tab control the input
314
+ // method, not the editor.
315
+ const onKeyDownOutsideIME = withIgnoreIMEEvents( onKeyDown );
227
316
 
228
- const { ownerDocument } = node;
229
- const { defaultView } = ownerDocument;
230
- defaultView.addEventListener( 'keydown', preventScrollOnTab );
231
- node.addEventListener( 'keydown', onKeyDown );
317
+ node.addEventListener( 'keydown', onKeyDownOutsideIME );
232
318
  node.addEventListener( 'focusout', onFocusOut );
233
319
  return () => {
234
- defaultView.removeEventListener( 'keydown', preventScrollOnTab );
235
- node.removeEventListener( 'keydown', onKeyDown );
320
+ node.removeEventListener( 'keydown', onKeyDownOutsideIME );
236
321
  node.removeEventListener( 'focusout', onFocusOut );
237
322
  };
238
323
  }, [] );
@@ -0,0 +1,40 @@
1
+ import { BACKSPACE, ESCAPE } from '@wordpress/keycodes';
2
+ import { useSelect } from '@wordpress/data';
3
+ import { useRefEffect } from '@wordpress/compose';
4
+ import { store as blockEditorStore } from '../../store';
5
+
6
+ export default function useUndoAutomaticChange() {
7
+ const { didAutomaticChange, getSettings } = useSelect( blockEditorStore );
8
+
9
+ function onKeyDown( event ) {
10
+ const { keyCode } = event;
11
+
12
+ if ( event.defaultPrevented ) {
13
+ return;
14
+ }
15
+
16
+ if ( keyCode !== BACKSPACE && keyCode !== ESCAPE ) {
17
+ return;
18
+ }
19
+
20
+ const { __experimentalUndo } = getSettings();
21
+
22
+ if ( ! __experimentalUndo ) {
23
+ return;
24
+ }
25
+
26
+ if ( ! didAutomaticChange() ) {
27
+ return;
28
+ }
29
+
30
+ event.preventDefault();
31
+ __experimentalUndo();
32
+ }
33
+
34
+ return useRefEffect( ( element ) => {
35
+ element.addEventListener( 'keydown', onKeyDown );
36
+ return () => {
37
+ element.removeEventListener( 'keydown', onKeyDown );
38
+ };
39
+ }, [] );
40
+ }
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it } from 'vitest';
1
2
  import { __experimentalGetElementClassName } from '@wordpress/block-editor';
2
3
 
3
4
  describe( 'element class names', () => {
@@ -4,14 +4,12 @@ import { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/com
4
4
  import { useCallback, useMemo } from '@wordpress/element';
5
5
  import { addFilter } from '@wordpress/hooks';
6
6
  import { useSelect } from '@wordpress/data';
7
- import { __ } from '@wordpress/i18n';
8
7
  import { getColorClassName } from '../components/colors';
9
8
  import InspectorControls from '../components/inspector-controls';
10
9
  import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
11
10
  import { cleanEmptyObject, shouldSkipSerialization } from './utils';
12
11
  import {
13
12
  useHasBorderPanel,
14
- useHasBorderPanelControls,
15
13
  BorderPanel as StylesBorderPanel,
16
14
  } from '../components/global-styles';
17
15
  import { useResolvedStyle } from '../components/global-styles/inherited-value-context';
@@ -22,13 +20,10 @@ import {
22
20
  setStyleForState,
23
21
  useBlockStyleState,
24
22
  } from './block-style-state';
25
- import { unlock } from '../lock-unlock';
26
23
 
27
24
  export const BORDER_SUPPORT_KEY = '__experimentalBorder';
28
25
  export const SHADOW_SUPPORT_KEY = 'shadow';
29
26
 
30
- const EMPTY_ARRAY = [];
31
-
32
27
  const getColorByProperty = ( colors, property, value ) => {
33
28
  let matchedColor;
34
29
 
@@ -249,54 +244,6 @@ export function hasShadowSupport( blockName ) {
249
244
  return hasBlockSupport( blockName, SHADOW_SUPPORT_KEY );
250
245
  }
251
246
 
252
- export function useBorderPanelLabel( {
253
- clientId,
254
- hasBorderControl,
255
- hasShadowControl,
256
- } = {} ) {
257
- const [ color, radius, style, width, shadow ] = useSelect(
258
- ( select ) => {
259
- if ( ! clientId ) {
260
- return EMPTY_ARRAY;
261
- }
262
- const { getBlockSettings } = unlock( select( blockEditorStore ) );
263
- return getBlockSettings(
264
- clientId,
265
- 'border.color',
266
- 'border.radius',
267
- 'border.style',
268
- 'border.width',
269
- 'shadow'
270
- );
271
- },
272
- [ clientId ]
273
- );
274
- const settings = useMemo(
275
- () => ( { border: { color, radius, style, width }, shadow } ),
276
- [ color, radius, style, width, shadow ]
277
- );
278
- const controls = useHasBorderPanelControls( settings );
279
-
280
- if ( ! hasBorderControl && ! hasShadowControl && clientId ) {
281
- hasBorderControl =
282
- controls?.hasBorderColor ||
283
- controls?.hasBorderStyle ||
284
- controls?.hasBorderWidth ||
285
- controls?.hasBorderRadius;
286
- hasShadowControl = controls?.hasShadow;
287
- }
288
-
289
- if ( hasBorderControl && hasShadowControl ) {
290
- return __( 'Border & Shadow' );
291
- }
292
-
293
- if ( hasShadowControl ) {
294
- return __( 'Shadow' );
295
- }
296
-
297
- return __( 'Border' );
298
- }
299
-
300
247
  /**
301
248
  * Returns a new style object where the specified border attribute has been
302
249
  * removed.
@@ -10,7 +10,7 @@
10
10
  * See https://github.com/WordPress/wordpress-develop/blob/8f6d31266deecd7eea258bd3d45597355cce13d0/src/wp-includes/block-supports/auto-register.php#L30
11
11
  *
12
12
  * @param {Object} attributes - Block type attributes from block registration
13
- * @return {{ fields: Array, form: Object }} fieldsKey and formKey values
13
+ * @return {{ fields: Array, form: Object }} DataForm fields and form definitions
14
14
  */
15
15
  export function generateFieldsFromAttributes( attributes ) {
16
16
  const fields = [];
@@ -11,7 +11,6 @@ import './lock';
11
11
  import allowedBlocks from './allowed-blocks';
12
12
  import anchor from './anchor';
13
13
  import ariaLabel from './aria-label';
14
- import blockFields from './block-fields';
15
14
  import customClassName from './custom-class-name';
16
15
  import './generated-class-name';
17
16
  import style from './style';
@@ -53,7 +52,6 @@ createBlockEditFilter(
53
52
  blockBindingsPanel,
54
53
  childLayout,
55
54
  allowedBlocks,
56
- blockFields,
57
55
  listView,
58
56
  AutoRegisterControls,
59
57
  ].filter( Boolean )
@@ -36,6 +36,7 @@ import {
36
36
  cleanEmptyObject,
37
37
  shouldSkipSerialization,
38
38
  useStyleOverride,
39
+ usePrivateStyleOverride,
39
40
  useBlockSettings,
40
41
  } from './utils';
41
42
  import {
@@ -993,7 +994,7 @@ function getElementCSSRules( blockElementStyles, blockName, baseSelector ) {
993
994
  return rules.length > 0 ? rules.join( '' ) : undefined;
994
995
  }
995
996
 
996
- function useBlockProps( { name, style } ) {
997
+ function useBlockProps( { clientId, name, style } ) {
997
998
  const blockElementsContainerIdentifier = useInstanceId(
998
999
  STYLE_BLOCK_PROPS_REFERENCE,
999
1000
  'wp-elements'
@@ -1037,7 +1038,7 @@ function useBlockProps( { name, style } ) {
1037
1038
  viewportSettings,
1038
1039
  ] );
1039
1040
 
1040
- useStyleOverride( { css: styles } );
1041
+ usePrivateStyleOverride( { css: styles, clientId } );
1041
1042
 
1042
1043
  return addSaveProps(
1043
1044
  { className: blockElementsContainerIdentifier },
@@ -1,3 +1,4 @@
1
+ import { afterEach, describe, expect, it } from 'vitest';
1
2
  import { applyFilters } from '@wordpress/hooks';
2
3
  import {
3
4
  getBlockTypes,
@@ -1,3 +1,4 @@
1
+ import { afterEach, describe, expect, it } from 'vitest';
1
2
  import {
2
3
  getBlockTypes,
3
4
  registerBlockType,
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it } from 'vitest';
1
2
  import { applyFilters } from '@wordpress/hooks';
2
3
  import anchor from '../anchor';
3
4
 
@@ -1,3 +1,4 @@
1
+ import { afterEach, describe, expect, it } from 'vitest';
1
2
  import {
2
3
  registerBlockType,
3
4
  unregisterBlockType,
@@ -1,3 +1,4 @@
1
+ import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';
1
2
  import { render, screen } from '@testing-library/react';
2
3
  import userEvent from '@testing-library/user-event';
3
4
  import { registerBlockType, unregisterBlockType } from '@wordpress/blocks';
@@ -9,6 +10,8 @@ import {
9
10
  } from '../background';
10
11
  import { BackgroundToolsPanel } from '../../components/global-styles/background-panel';
11
12
 
13
+ globalThis.wpVitest.mockMatchMedia();
14
+
12
15
  describe( 'background', () => {
13
16
  describe( 'backgroundResetAllFilter', () => {
14
17
  it( 'clears every background-owned value, including a custom legacy color.gradient', () => {
@@ -164,7 +167,7 @@ describe( 'background', () => {
164
167
  background: { gradient: true },
165
168
  };
166
169
  const user = userEvent.setup();
167
- const setAttributes = jest.fn();
170
+ const setAttributes = vi.fn();
168
171
 
169
172
  render(
170
173
  <BackgroundImagePanel
@@ -201,7 +204,7 @@ describe( 'background', () => {
201
204
  background: { gradient: false },
202
205
  };
203
206
  const user = userEvent.setup();
204
- const setAttributes = jest.fn();
207
+ const setAttributes = vi.fn();
205
208
 
206
209
  render(
207
210
  <BackgroundImagePanel