@wordpress/block-editor 8.6.0 → 9.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 (466) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +5 -2
  3. package/build/components/block-alignment-control/constants.js +48 -0
  4. package/build/components/block-alignment-control/constants.js.map +1 -0
  5. package/build/components/block-alignment-control/ui.js +9 -40
  6. package/build/components/block-alignment-control/ui.js.map +1 -1
  7. package/build/components/block-alignment-control/ui.native.js +92 -0
  8. package/build/components/block-alignment-control/ui.native.js.map +1 -0
  9. package/build/components/block-alignment-matrix-control/index.js +1 -6
  10. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  11. package/build/components/block-content-overlay/index.js +4 -82
  12. package/build/components/block-content-overlay/index.js.map +1 -1
  13. package/build/components/block-draggable/draggable-chip.native.js +65 -0
  14. package/build/components/block-draggable/draggable-chip.native.js.map +1 -0
  15. package/build/components/block-draggable/dropping-insertion-point.native.js +157 -0
  16. package/build/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
  17. package/build/components/block-draggable/index.native.js +488 -0
  18. package/build/components/block-draggable/index.native.js.map +1 -0
  19. package/build/components/block-draggable/use-scroll-when-dragging.native.js +130 -0
  20. package/build/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
  21. package/build/components/block-list/block-list-context.native.js +195 -0
  22. package/build/components/block-list/block-list-context.native.js.map +1 -0
  23. package/build/components/block-list/block-list-item-cell.native.js +67 -0
  24. package/build/components/block-list/block-list-item-cell.native.js.map +1 -0
  25. package/build/components/block-list/block-list-item.native.js +12 -9
  26. package/build/components/block-list/block-list-item.native.js.map +1 -1
  27. package/build/components/block-list/block.native.js +27 -5
  28. package/build/components/block-list/block.native.js.map +1 -1
  29. package/build/components/block-list/index.js +34 -32
  30. package/build/components/block-list/index.js.map +1 -1
  31. package/build/components/block-list/index.native.js +75 -23
  32. package/build/components/block-list/index.native.js.map +1 -1
  33. package/build/components/block-list/use-block-props/index.js +8 -4
  34. package/build/components/block-list/use-block-props/index.js.map +1 -1
  35. package/build/components/block-list/use-block-props/use-block-class-names.js +1 -7
  36. package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  37. package/build/components/block-list/use-in-between-inserter.js +1 -1
  38. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  39. package/build/components/block-mobile-toolbar/index.native.js +10 -3
  40. package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
  41. package/build/components/block-mover/index.native.js +17 -4
  42. package/build/components/block-mover/index.native.js.map +1 -1
  43. package/build/components/block-navigation/dropdown.js +11 -5
  44. package/build/components/block-navigation/dropdown.js.map +1 -1
  45. package/build/components/block-popover/inbetween.js +19 -8
  46. package/build/components/block-popover/inbetween.js.map +1 -1
  47. package/build/components/block-popover/index.js +20 -16
  48. package/build/components/block-popover/index.js.map +1 -1
  49. package/build/components/block-preview/index.js +1 -1
  50. package/build/components/block-preview/index.js.map +1 -1
  51. package/build/components/block-tools/block-selection-button.js +1 -0
  52. package/build/components/block-tools/block-selection-button.js.map +1 -1
  53. package/build/components/block-tools/selected-block-popover.js +1 -29
  54. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  55. package/build/components/block-variation-transforms/index.js +16 -2
  56. package/build/components/block-variation-transforms/index.js.map +1 -1
  57. package/build/components/border-radius-control/input-controls.js +10 -3
  58. package/build/components/border-radius-control/input-controls.js.map +1 -1
  59. package/build/components/color-style-selector/index.js +9 -0
  60. package/build/components/color-style-selector/index.js.map +1 -1
  61. package/build/components/colors-gradients/dropdown.js +122 -41
  62. package/build/components/colors-gradients/dropdown.js.map +1 -1
  63. package/build/components/colors-gradients/panel-color-gradient-settings.js +35 -60
  64. package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  65. package/build/components/convert-to-group-buttons/toolbar.js +22 -5
  66. package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
  67. package/build/components/iframe/index.js +51 -50
  68. package/build/components/iframe/index.js.map +1 -1
  69. package/build/components/image-editor/use-save-image.js +3 -1
  70. package/build/components/image-editor/use-save-image.js.map +1 -1
  71. package/build/components/index.js +14 -23
  72. package/build/components/index.js.map +1 -1
  73. package/build/components/inserter/index.js +21 -7
  74. package/build/components/inserter/index.js.map +1 -1
  75. package/build/components/inserter/index.native.js +2 -2
  76. package/build/components/inserter/index.native.js.map +1 -1
  77. package/build/components/inserter/quick-inserter.js +4 -5
  78. package/build/components/inserter/quick-inserter.js.map +1 -1
  79. package/build/components/link-control/constants.js +11 -1
  80. package/build/components/link-control/constants.js.map +1 -1
  81. package/build/components/link-control/search-results.js +4 -3
  82. package/build/components/link-control/search-results.js.map +1 -1
  83. package/build/components/link-control/use-search-handler.js +4 -4
  84. package/build/components/link-control/use-search-handler.js.map +1 -1
  85. package/build/components/list-view/block.js +15 -15
  86. package/build/components/list-view/block.js.map +1 -1
  87. package/build/components/list-view/branch.js +9 -13
  88. package/build/components/list-view/branch.js.map +1 -1
  89. package/build/components/list-view/context.js +1 -4
  90. package/build/components/list-view/context.js.map +1 -1
  91. package/build/components/list-view/drop-indicator.js +0 -1
  92. package/build/components/list-view/drop-indicator.js.map +1 -1
  93. package/build/components/list-view/index.js +15 -32
  94. package/build/components/list-view/index.js.map +1 -1
  95. package/build/components/media-placeholder/index.js +0 -2
  96. package/build/components/media-placeholder/index.js.map +1 -1
  97. package/build/components/media-replace-flow/index.js +0 -2
  98. package/build/components/media-replace-flow/index.js.map +1 -1
  99. package/build/components/media-upload/index.native.js +10 -4
  100. package/build/components/media-upload/index.native.js.map +1 -1
  101. package/build/components/navigable-toolbar/index.js +12 -2
  102. package/build/components/navigable-toolbar/index.js.map +1 -1
  103. package/build/components/plain-text/index.native.js +62 -7
  104. package/build/components/plain-text/index.native.js.map +1 -1
  105. package/build/components/publish-date-time-picker/index.js +55 -0
  106. package/build/components/publish-date-time-picker/index.js.map +1 -0
  107. package/build/components/rich-text/format-toolbar-container.js +0 -1
  108. package/build/components/rich-text/format-toolbar-container.js.map +1 -1
  109. package/build/components/rich-text/index.js +2 -2
  110. package/build/components/rich-text/index.js.map +1 -1
  111. package/build/components/rich-text/index.native.js +5 -1
  112. package/build/components/rich-text/index.native.js.map +1 -1
  113. package/build/components/url-input/index.js +11 -4
  114. package/build/components/url-input/index.js.map +1 -1
  115. package/build/components/use-block-drop-zone/index.native.js +167 -0
  116. package/build/components/use-block-drop-zone/index.native.js.map +1 -0
  117. package/build/components/use-on-block-drop/index.native.js +95 -0
  118. package/build/components/use-on-block-drop/index.native.js.map +1 -0
  119. package/build/components/use-setting/index.js +42 -18
  120. package/build/components/use-setting/index.js.map +1 -1
  121. package/build/components/warning/index.js +6 -1
  122. package/build/components/warning/index.js.map +1 -1
  123. package/build/components/writing-flow/use-click-selection.js +1 -3
  124. package/build/components/writing-flow/use-click-selection.js.map +1 -1
  125. package/build/components/writing-flow/use-input.js +15 -0
  126. package/build/components/writing-flow/use-input.js.map +1 -1
  127. package/build/components/writing-flow/use-selection-observer.js +49 -8
  128. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  129. package/build/elements/index.js +9 -0
  130. package/build/elements/index.js.map +1 -0
  131. package/build/hooks/anchor.js.map +1 -1
  132. package/build/hooks/border.js +2 -7
  133. package/build/hooks/border.js.map +1 -1
  134. package/build/hooks/color-panel.js +14 -7
  135. package/build/hooks/color-panel.js.map +1 -1
  136. package/build/hooks/color.js +8 -88
  137. package/build/hooks/color.js.map +1 -1
  138. package/build/hooks/dimensions.js +16 -6
  139. package/build/hooks/dimensions.js.map +1 -1
  140. package/build/hooks/index.js +2 -0
  141. package/build/hooks/index.js.map +1 -1
  142. package/build/hooks/margin.js +64 -12
  143. package/build/hooks/margin.js.map +1 -1
  144. package/build/hooks/padding.js +60 -12
  145. package/build/hooks/padding.js.map +1 -1
  146. package/build/hooks/settings.js +32 -0
  147. package/build/hooks/settings.js.map +1 -0
  148. package/build/hooks/style.js +14 -13
  149. package/build/hooks/style.js.map +1 -1
  150. package/build/hooks/typography.js +6 -2
  151. package/build/hooks/typography.js.map +1 -1
  152. package/build/index.js +14 -0
  153. package/build/index.js.map +1 -1
  154. package/build/layouts/flex.js +5 -2
  155. package/build/layouts/flex.js.map +1 -1
  156. package/build/store/actions.js +14 -0
  157. package/build/store/actions.js.map +1 -1
  158. package/build/store/defaults.js +0 -1
  159. package/build/store/defaults.js.map +1 -1
  160. package/build/store/reducer.js +17 -2
  161. package/build/store/reducer.js.map +1 -1
  162. package/build/store/selectors.js +43 -13
  163. package/build/store/selectors.js.map +1 -1
  164. package/build-module/components/block-alignment-control/constants.js +36 -0
  165. package/build-module/components/block-alignment-control/constants.js.map +1 -0
  166. package/build-module/components/block-alignment-control/ui.js +4 -35
  167. package/build-module/components/block-alignment-control/ui.js.map +1 -1
  168. package/build-module/components/block-alignment-control/ui.native.js +78 -0
  169. package/build-module/components/block-alignment-control/ui.native.js.map +1 -0
  170. package/build-module/components/block-alignment-matrix-control/index.js +1 -6
  171. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  172. package/build-module/components/block-content-overlay/index.js +3 -78
  173. package/build-module/components/block-content-overlay/index.js.map +1 -1
  174. package/build-module/components/block-draggable/draggable-chip.native.js +51 -0
  175. package/build-module/components/block-draggable/draggable-chip.native.js.map +1 -0
  176. package/build-module/components/block-draggable/dropping-insertion-point.native.js +137 -0
  177. package/build-module/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
  178. package/build-module/components/block-draggable/index.native.js +453 -0
  179. package/build-module/components/block-draggable/index.native.js.map +1 -0
  180. package/build-module/components/block-draggable/use-scroll-when-dragging.native.js +120 -0
  181. package/build-module/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
  182. package/build-module/components/block-list/block-list-context.native.js +179 -0
  183. package/build-module/components/block-list/block-list-context.native.js.map +1 -0
  184. package/build-module/components/block-list/block-list-item-cell.native.js +59 -0
  185. package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -0
  186. package/build-module/components/block-list/block-list-item.native.js +12 -9
  187. package/build-module/components/block-list/block-list-item.native.js.map +1 -1
  188. package/build-module/components/block-list/block.native.js +26 -5
  189. package/build-module/components/block-list/block.native.js.map +1 -1
  190. package/build-module/components/block-list/index.js +35 -33
  191. package/build-module/components/block-list/index.js.map +1 -1
  192. package/build-module/components/block-list/index.native.js +72 -23
  193. package/build-module/components/block-list/index.native.js.map +1 -1
  194. package/build-module/components/block-list/use-block-props/index.js +9 -5
  195. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  196. package/build-module/components/block-list/use-block-props/use-block-class-names.js +1 -7
  197. package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  198. package/build-module/components/block-list/use-in-between-inserter.js +1 -1
  199. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  200. package/build-module/components/block-mobile-toolbar/index.native.js +9 -3
  201. package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
  202. package/build-module/components/block-mover/index.native.js +18 -5
  203. package/build-module/components/block-mover/index.native.js.map +1 -1
  204. package/build-module/components/block-navigation/dropdown.js +10 -5
  205. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  206. package/build-module/components/block-popover/inbetween.js +19 -8
  207. package/build-module/components/block-popover/inbetween.js.map +1 -1
  208. package/build-module/components/block-popover/index.js +21 -15
  209. package/build-module/components/block-popover/index.js.map +1 -1
  210. package/build-module/components/block-preview/index.js +1 -1
  211. package/build-module/components/block-preview/index.js.map +1 -1
  212. package/build-module/components/block-tools/block-selection-button.js +1 -0
  213. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  214. package/build-module/components/block-tools/selected-block-popover.js +2 -29
  215. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  216. package/build-module/components/block-variation-transforms/index.js +13 -2
  217. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  218. package/build-module/components/border-radius-control/input-controls.js +11 -4
  219. package/build-module/components/border-radius-control/input-controls.js.map +1 -1
  220. package/build-module/components/color-style-selector/index.js +6 -0
  221. package/build-module/components/color-style-selector/index.js.map +1 -1
  222. package/build-module/components/colors-gradients/dropdown.js +124 -43
  223. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  224. package/build-module/components/colors-gradients/panel-color-gradient-settings.js +36 -64
  225. package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  226. package/build-module/components/convert-to-group-buttons/toolbar.js +23 -6
  227. package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
  228. package/build-module/components/iframe/index.js +52 -51
  229. package/build-module/components/iframe/index.js.map +1 -1
  230. package/build-module/components/image-editor/use-save-image.js +2 -1
  231. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  232. package/build-module/components/index.js +2 -3
  233. package/build-module/components/index.js.map +1 -1
  234. package/build-module/components/inserter/index.js +21 -7
  235. package/build-module/components/inserter/index.js.map +1 -1
  236. package/build-module/components/inserter/index.native.js +2 -2
  237. package/build-module/components/inserter/index.native.js.map +1 -1
  238. package/build-module/components/inserter/quick-inserter.js +4 -5
  239. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  240. package/build-module/components/link-control/constants.js +5 -0
  241. package/build-module/components/link-control/constants.js.map +1 -1
  242. package/build-module/components/link-control/search-results.js +3 -4
  243. package/build-module/components/link-control/search-results.js.map +1 -1
  244. package/build-module/components/link-control/use-search-handler.js +5 -5
  245. package/build-module/components/link-control/use-search-handler.js.map +1 -1
  246. package/build-module/components/list-view/block.js +15 -16
  247. package/build-module/components/list-view/block.js.map +1 -1
  248. package/build-module/components/list-view/branch.js +9 -13
  249. package/build-module/components/list-view/branch.js.map +1 -1
  250. package/build-module/components/list-view/context.js +1 -4
  251. package/build-module/components/list-view/context.js.map +1 -1
  252. package/build-module/components/list-view/drop-indicator.js +0 -1
  253. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  254. package/build-module/components/list-view/index.js +15 -31
  255. package/build-module/components/list-view/index.js.map +1 -1
  256. package/build-module/components/media-placeholder/index.js +0 -2
  257. package/build-module/components/media-placeholder/index.js.map +1 -1
  258. package/build-module/components/media-replace-flow/index.js +0 -2
  259. package/build-module/components/media-replace-flow/index.js.map +1 -1
  260. package/build-module/components/media-upload/index.native.js +8 -3
  261. package/build-module/components/media-upload/index.native.js.map +1 -1
  262. package/build-module/components/navigable-toolbar/index.js +12 -2
  263. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  264. package/build-module/components/plain-text/index.native.js +63 -8
  265. package/build-module/components/plain-text/index.native.js.map +1 -1
  266. package/build-module/components/publish-date-time-picker/index.js +42 -0
  267. package/build-module/components/publish-date-time-picker/index.js.map +1 -0
  268. package/build-module/components/rich-text/format-toolbar-container.js +0 -1
  269. package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
  270. package/build-module/components/rich-text/index.js +2 -2
  271. package/build-module/components/rich-text/index.js.map +1 -1
  272. package/build-module/components/rich-text/index.native.js +5 -1
  273. package/build-module/components/rich-text/index.native.js.map +1 -1
  274. package/build-module/components/url-input/index.js +11 -4
  275. package/build-module/components/url-input/index.js.map +1 -1
  276. package/build-module/components/use-block-drop-zone/index.native.js +148 -0
  277. package/build-module/components/use-block-drop-zone/index.native.js.map +1 -0
  278. package/build-module/components/use-on-block-drop/index.native.js +83 -0
  279. package/build-module/components/use-on-block-drop/index.native.js.map +1 -0
  280. package/build-module/components/use-setting/index.js +43 -19
  281. package/build-module/components/use-setting/index.js.map +1 -1
  282. package/build-module/components/warning/index.js +6 -1
  283. package/build-module/components/warning/index.js.map +1 -1
  284. package/build-module/components/writing-flow/use-click-selection.js +1 -3
  285. package/build-module/components/writing-flow/use-click-selection.js.map +1 -1
  286. package/build-module/components/writing-flow/use-input.js +15 -0
  287. package/build-module/components/writing-flow/use-input.js.map +1 -1
  288. package/build-module/components/writing-flow/use-selection-observer.js +49 -8
  289. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  290. package/build-module/elements/index.js +2 -0
  291. package/build-module/elements/index.js.map +1 -0
  292. package/build-module/hooks/anchor.js.map +1 -1
  293. package/build-module/hooks/border.js +2 -7
  294. package/build-module/hooks/border.js.map +1 -1
  295. package/build-module/hooks/color-panel.js +11 -6
  296. package/build-module/hooks/color-panel.js.map +1 -1
  297. package/build-module/hooks/color.js +8 -88
  298. package/build-module/hooks/color.js.map +1 -1
  299. package/build-module/hooks/dimensions.js +19 -9
  300. package/build-module/hooks/dimensions.js.map +1 -1
  301. package/build-module/hooks/index.js +1 -0
  302. package/build-module/hooks/index.js.map +1 -1
  303. package/build-module/hooks/margin.js +61 -13
  304. package/build-module/hooks/margin.js.map +1 -1
  305. package/build-module/hooks/padding.js +57 -13
  306. package/build-module/hooks/padding.js.map +1 -1
  307. package/build-module/hooks/settings.js +29 -0
  308. package/build-module/hooks/settings.js.map +1 -0
  309. package/build-module/hooks/style.js +15 -14
  310. package/build-module/hooks/style.js.map +1 -1
  311. package/build-module/hooks/typography.js +6 -2
  312. package/build-module/hooks/typography.js.map +1 -1
  313. package/build-module/index.js +1 -0
  314. package/build-module/index.js.map +1 -1
  315. package/build-module/layouts/flex.js +4 -2
  316. package/build-module/layouts/flex.js.map +1 -1
  317. package/build-module/store/actions.js +12 -0
  318. package/build-module/store/actions.js.map +1 -1
  319. package/build-module/store/defaults.js +0 -1
  320. package/build-module/store/defaults.js.map +1 -1
  321. package/build-module/store/reducer.js +17 -2
  322. package/build-module/store/reducer.js.map +1 -1
  323. package/build-module/store/selectors.js +37 -12
  324. package/build-module/store/selectors.js.map +1 -1
  325. package/build-style/style-rtl.css +100 -225
  326. package/build-style/style.css +100 -225
  327. package/package.json +30 -30
  328. package/src/components/block-alignment-control/constants.js +45 -0
  329. package/src/components/block-alignment-control/ui.js +69 -109
  330. package/src/components/block-alignment-control/ui.native.js +86 -0
  331. package/src/components/block-alignment-matrix-control/index.js +1 -5
  332. package/src/components/block-content-overlay/index.js +8 -95
  333. package/src/components/block-content-overlay/style.scss +2 -12
  334. package/src/components/block-draggable/draggable-chip.native.js +49 -0
  335. package/src/components/block-draggable/dropping-insertion-point.native.js +181 -0
  336. package/src/components/block-draggable/dropping-insertion-point.native.scss +8 -0
  337. package/src/components/block-draggable/index.native.js +462 -0
  338. package/src/components/block-draggable/style.native.scss +19 -0
  339. package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +73 -0
  340. package/src/components/block-draggable/test/helpers.native.js +183 -0
  341. package/src/components/block-draggable/test/index.native.js +496 -0
  342. package/src/components/block-draggable/use-scroll-when-dragging.native.js +135 -0
  343. package/src/components/block-list/block-list-context.native.js +175 -0
  344. package/src/components/block-list/block-list-item-cell.native.js +49 -0
  345. package/src/components/block-list/block-list-item.native.js +7 -11
  346. package/src/components/block-list/block.native.js +37 -8
  347. package/src/components/block-list/index.js +44 -44
  348. package/src/components/block-list/index.native.js +54 -13
  349. package/src/components/block-list/style.scss +7 -18
  350. package/src/components/block-list/test/block-list-context.native.js +253 -0
  351. package/src/components/block-list/test/fixtures/block-list-context.native.js +79 -0
  352. package/src/components/block-list/use-block-props/index.js +10 -5
  353. package/src/components/block-list/use-block-props/use-block-class-names.js +1 -11
  354. package/src/components/block-list/use-in-between-inserter.js +1 -1
  355. package/src/components/block-mobile-toolbar/index.native.js +9 -1
  356. package/src/components/block-mover/index.native.js +22 -6
  357. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +10 -0
  358. package/src/components/block-navigation/dropdown.js +12 -8
  359. package/src/components/block-popover/inbetween.js +21 -8
  360. package/src/components/block-popover/index.js +18 -15
  361. package/src/components/block-popover/style.scss +4 -0
  362. package/src/components/block-preview/index.js +1 -4
  363. package/src/components/block-switcher/style.scss +2 -39
  364. package/src/components/block-tools/block-selection-button.js +1 -0
  365. package/src/components/block-tools/selected-block-popover.js +1 -36
  366. package/src/components/block-tools/style.scss +1 -12
  367. package/src/components/block-variation-transforms/index.js +6 -2
  368. package/src/components/border-radius-control/input-controls.js +16 -8
  369. package/src/components/border-radius-control/style.scss +3 -2
  370. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
  371. package/src/components/color-style-selector/index.js +18 -9
  372. package/src/components/colors-gradients/dropdown.js +130 -62
  373. package/src/components/colors-gradients/panel-color-gradient-settings.js +30 -76
  374. package/src/components/colors-gradients/style.scss +52 -50
  375. package/src/components/convert-to-group-buttons/toolbar.js +30 -13
  376. package/src/components/duotone-control/style.scss +1 -7
  377. package/src/components/iframe/index.js +62 -54
  378. package/src/components/image-editor/use-save-image.js +2 -1
  379. package/src/components/image-size-control/README.md +1 -1
  380. package/src/components/index.js +2 -3
  381. package/src/components/inserter/index.js +20 -0
  382. package/src/components/inserter/index.native.js +2 -2
  383. package/src/components/inserter/quick-inserter.js +3 -11
  384. package/src/components/inserter/style.native.scss +1 -0
  385. package/src/components/inserter/style.scss +2 -1
  386. package/src/components/link-control/constants.js +11 -0
  387. package/src/components/link-control/search-results.js +4 -5
  388. package/src/components/link-control/use-search-handler.js +11 -5
  389. package/src/components/list-view/block.js +24 -34
  390. package/src/components/list-view/branch.js +10 -20
  391. package/src/components/list-view/context.js +1 -4
  392. package/src/components/list-view/drop-indicator.js +0 -1
  393. package/src/components/list-view/index.js +11 -41
  394. package/src/components/list-view/style.scss +2 -1
  395. package/src/components/media-placeholder/index.js +0 -2
  396. package/src/components/media-replace-flow/index.js +0 -2
  397. package/src/components/media-upload/index.native.js +6 -2
  398. package/src/components/media-upload/test/index.native.js +31 -6
  399. package/src/components/navigable-toolbar/index.js +12 -2
  400. package/src/components/plain-text/index.native.js +64 -8
  401. package/src/components/preview-options/style.scss +0 -4
  402. package/src/components/publish-date-time-picker/README.md +52 -0
  403. package/src/components/publish-date-time-picker/index.js +50 -0
  404. package/src/components/publish-date-time-picker/style.scss +20 -0
  405. package/src/components/rich-text/format-toolbar-container.js +0 -1
  406. package/src/components/rich-text/index.js +3 -1
  407. package/src/components/rich-text/index.native.js +4 -0
  408. package/src/components/rich-text/style.scss +2 -8
  409. package/src/components/url-input/index.js +9 -4
  410. package/src/components/use-block-drop-zone/index.native.js +173 -0
  411. package/src/components/use-on-block-drop/index.native.js +119 -0
  412. package/src/components/use-setting/index.js +57 -21
  413. package/src/components/warning/index.js +47 -42
  414. package/src/components/warning/test/__snapshots__/index.js.snap +15 -6
  415. package/src/components/warning/test/index.js +1 -1
  416. package/src/components/writing-flow/use-click-selection.js +1 -4
  417. package/src/components/writing-flow/use-input.js +12 -0
  418. package/src/components/writing-flow/use-selection-observer.js +55 -10
  419. package/src/elements/index.js +1 -0
  420. package/src/hooks/anchor.js +1 -1
  421. package/src/hooks/border.js +2 -11
  422. package/src/hooks/border.scss +0 -48
  423. package/src/hooks/color-panel.js +13 -9
  424. package/src/hooks/color.js +5 -74
  425. package/src/hooks/color.scss +5 -58
  426. package/src/hooks/dimensions.js +55 -41
  427. package/src/hooks/index.js +1 -0
  428. package/src/hooks/margin.js +64 -15
  429. package/src/hooks/padding.js +60 -15
  430. package/src/hooks/padding.scss +12 -0
  431. package/src/hooks/settings.js +32 -0
  432. package/src/hooks/style.js +25 -39
  433. package/src/hooks/test/settings.js +48 -0
  434. package/src/hooks/typography.js +2 -0
  435. package/src/index.js +1 -0
  436. package/src/layouts/flex.js +11 -3
  437. package/src/store/actions.js +12 -0
  438. package/src/store/defaults.js +0 -1
  439. package/src/store/reducer.js +14 -1
  440. package/src/store/selectors.js +42 -12
  441. package/src/store/test/reducer.js +5 -0
  442. package/src/store/test/selectors.js +17 -0
  443. package/src/style.scss +2 -2
  444. package/tsconfig.tsbuildinfo +1 -1
  445. package/build/components/border-style-control/index.js +0 -60
  446. package/build/components/border-style-control/index.js.map +0 -1
  447. package/build/components/colors/color-panel.js +0 -82
  448. package/build/components/colors/color-panel.js.map +0 -1
  449. package/build/components/colors/color-panel.native.js +0 -11
  450. package/build/components/colors/color-panel.native.js.map +0 -1
  451. package/build/components/colors-gradients/tools-panel-color-dropdown.js +0 -89
  452. package/build/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
  453. package/build-module/components/border-style-control/index.js +0 -50
  454. package/build-module/components/border-style-control/index.js.map +0 -1
  455. package/build-module/components/colors/color-panel.js +0 -70
  456. package/build-module/components/colors/color-panel.js.map +0 -1
  457. package/build-module/components/colors/color-panel.native.js +0 -4
  458. package/build-module/components/colors/color-panel.native.js.map +0 -1
  459. package/build-module/components/colors-gradients/tools-panel-color-dropdown.js +0 -75
  460. package/build-module/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
  461. package/src/components/block-alignment-matrix-control/style.scss +0 -10
  462. package/src/components/border-style-control/index.js +0 -47
  463. package/src/components/border-style-control/style.scss +0 -18
  464. package/src/components/colors/color-panel.js +0 -91
  465. package/src/components/colors/color-panel.native.js +0 -3
  466. package/src/components/colors-gradients/tools-panel-color-dropdown.js +0 -85
@@ -0,0 +1,173 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { useSharedValue } from 'react-native-reanimated';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { useSelect } from '@wordpress/data';
10
+ import { useCallback } from '@wordpress/element';
11
+ import { useThrottle } from '@wordpress/compose';
12
+
13
+ /**
14
+ * Internal dependencies
15
+ */
16
+ import { store as blockEditorStore } from '../../store';
17
+ import { useBlockListContext } from '../block-list/block-list-context';
18
+ import { getDistanceToNearestEdge } from '../../utils/math';
19
+ import useOnBlockDrop from '../use-on-block-drop';
20
+
21
+ /** @typedef {import('../../utils/math').WPPoint} WPPoint */
22
+
23
+ /**
24
+ * The orientation of a block list.
25
+ *
26
+ * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation
27
+ */
28
+
29
+ /**
30
+ * Given a list of blocks layouts finds the index that a block should be dropped at.
31
+ *
32
+ * @param {Object} blocksLayouts Blocks layouts object.
33
+ * @param {WPPoint} position The position of the item being dragged.
34
+ * @param {WPBlockListOrientation} orientation The orientation of a block list.
35
+ * @param {boolean} isRTL Check if current locale is RTL.
36
+ *
37
+ * @return {number|undefined} The block index that's closest to the drag position.
38
+ */
39
+ export function getNearestBlockIndex(
40
+ blocksLayouts,
41
+ position,
42
+ orientation,
43
+ isRTL
44
+ ) {
45
+ const allowedEdges =
46
+ orientation === 'horizontal'
47
+ ? [ 'left', 'right' ]
48
+ : [ 'top', 'bottom' ];
49
+
50
+ const isRightToLeft = isRTL;
51
+
52
+ let candidateIndex;
53
+ let candidateDistance;
54
+
55
+ // Only enabled for root level blocks.
56
+ blocksLayouts.forEach( ( element, index ) => {
57
+ const { x, y, width, height } = element;
58
+ const rect = {
59
+ x: element.x,
60
+ y: element.y,
61
+ top: y,
62
+ right: x + width,
63
+ bottom: y + height,
64
+ left: x,
65
+ width,
66
+ height,
67
+ };
68
+ const [ distance, edge ] = getDistanceToNearestEdge(
69
+ position,
70
+ rect,
71
+ allowedEdges
72
+ );
73
+
74
+ if ( candidateDistance === undefined || distance < candidateDistance ) {
75
+ // If the user is dropping to the trailing edge of the block
76
+ // add 1 to the index to represent dragging after.
77
+ // Take RTL languages into account where the left edge is
78
+ // the trailing edge.
79
+ const isTrailingEdge =
80
+ edge === 'bottom' ||
81
+ ( ! isRightToLeft && edge === 'right' ) ||
82
+ ( isRightToLeft && edge === 'left' );
83
+ const offset = isTrailingEdge ? 1 : 0;
84
+
85
+ // Update the currently known best candidate.
86
+ candidateDistance = distance;
87
+ candidateIndex = index + offset;
88
+ }
89
+ } );
90
+ return candidateIndex;
91
+ }
92
+
93
+ /**
94
+ * @typedef {Object} WPBlockDropZoneConfig
95
+ * @property {string} rootClientId The root client id for the block list.
96
+ */
97
+
98
+ /**
99
+ * A React hook that can be used to make a block list handle drag and drop.
100
+ *
101
+ * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.
102
+ *
103
+ * @return {Object} An object that contains `targetBlockIndex` and the event
104
+ * handlers `onBlockDragOver`, `onBlockDragEnd` and `onBlockDrop`.
105
+ */
106
+ export default function useBlockDropZone( {
107
+ // An undefined value represents a top-level block. Default to an empty
108
+ // string for this so that `targetRootClientId` can be easily compared to
109
+ // values returned by the `getRootBlockClientId` selector, which also uses
110
+ // an empty string to represent top-level blocks.
111
+ rootClientId: targetRootClientId = '',
112
+ } = {} ) {
113
+ const targetBlockIndex = useSharedValue( null );
114
+
115
+ const { getBlockListSettings, getSettings } = useSelect( blockEditorStore );
116
+ const {
117
+ blocksLayouts,
118
+ getBlockLayoutsOrderedByYCoord,
119
+ } = useBlockListContext();
120
+
121
+ const getSortedBlocksLayouts = useCallback( () => {
122
+ return getBlockLayoutsOrderedByYCoord( blocksLayouts.current );
123
+ }, [ blocksLayouts.current ] );
124
+
125
+ const isRTL = getSettings().isRTL;
126
+
127
+ const onBlockDrop = useOnBlockDrop();
128
+
129
+ const throttled = useThrottle(
130
+ useCallback(
131
+ ( event ) => {
132
+ const sortedBlockLayouts = getSortedBlocksLayouts();
133
+
134
+ const targetIndex = getNearestBlockIndex(
135
+ sortedBlockLayouts,
136
+ { x: event.x, y: event.y },
137
+ getBlockListSettings( targetRootClientId )?.orientation,
138
+ isRTL
139
+ );
140
+ if ( targetIndex !== null ) {
141
+ targetBlockIndex.value = targetIndex ?? 0;
142
+ }
143
+ },
144
+ [
145
+ getSortedBlocksLayouts,
146
+ getNearestBlockIndex,
147
+ getBlockListSettings,
148
+ targetBlockIndex,
149
+ ]
150
+ ),
151
+ 200
152
+ );
153
+
154
+ return {
155
+ onBlockDragOver( event ) {
156
+ throttled( event );
157
+ },
158
+ onBlockDragEnd() {
159
+ throttled.cancel();
160
+ targetBlockIndex.value = null;
161
+ },
162
+ onBlockDrop: ( event ) => {
163
+ if ( targetBlockIndex.value !== null ) {
164
+ onBlockDrop( {
165
+ ...event,
166
+ targetRootClientId,
167
+ targetBlockIndex: targetBlockIndex.value,
168
+ } );
169
+ }
170
+ },
171
+ targetBlockIndex,
172
+ };
173
+ }
@@ -0,0 +1,119 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { cloneBlock } from '@wordpress/blocks';
5
+ import { useDispatch, useSelect } from '@wordpress/data';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { store as blockEditorStore } from '../../store';
11
+
12
+ /**
13
+ * A function that returns an event handler function for block drop events.
14
+ *
15
+ * @param {Function} getBlockIndex A function that gets the index of a block.
16
+ * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.
17
+ * @param {Function} moveBlocksToPosition A function that moves blocks.
18
+ * @param {Function} insertBlocks A function that inserts blocks.
19
+ * @param {Function} clearSelectedBlock A function that clears block selection.
20
+ * @return {Function} The event handler for a block drop event.
21
+ */
22
+ export function onBlockDrop(
23
+ getBlockIndex,
24
+ getClientIdsOfDescendants,
25
+ moveBlocksToPosition,
26
+ insertBlocks,
27
+ clearSelectedBlock
28
+ ) {
29
+ return ( {
30
+ blocks,
31
+ srcClientIds: sourceClientIds,
32
+ srcRootClientId: sourceRootClientId,
33
+ targetBlockIndex,
34
+ targetRootClientId,
35
+ type: dropType,
36
+ } ) => {
37
+ // If the user is inserting a block.
38
+ if ( dropType === 'inserter' ) {
39
+ clearSelectedBlock();
40
+ const blocksToInsert = blocks.map( ( block ) =>
41
+ cloneBlock( block )
42
+ );
43
+ insertBlocks(
44
+ blocksToInsert,
45
+ targetBlockIndex,
46
+ targetRootClientId,
47
+ true,
48
+ null
49
+ );
50
+ }
51
+
52
+ // If the user is moving a block.
53
+ if ( dropType === 'block' ) {
54
+ const sourceBlockIndex = getBlockIndex( sourceClientIds[ 0 ] );
55
+
56
+ // If the user is dropping to the same position, return early.
57
+ if (
58
+ sourceRootClientId === targetRootClientId &&
59
+ sourceBlockIndex === targetBlockIndex
60
+ ) {
61
+ return;
62
+ }
63
+
64
+ // If the user is attempting to drop a block within its own
65
+ // nested blocks, return early as this would create infinite
66
+ // recursion.
67
+ if (
68
+ sourceClientIds.includes( targetRootClientId ) ||
69
+ getClientIdsOfDescendants( sourceClientIds ).some(
70
+ ( id ) => id === targetRootClientId
71
+ )
72
+ ) {
73
+ return;
74
+ }
75
+
76
+ const isAtSameLevel = sourceRootClientId === targetRootClientId;
77
+ const draggedBlockCount = sourceClientIds.length;
78
+
79
+ // If the block is kept at the same level and moved downwards,
80
+ // subtract to take into account that the blocks being dragged
81
+ // were removed from the block list above the insertion point.
82
+ const insertIndex =
83
+ isAtSameLevel && sourceBlockIndex < targetBlockIndex
84
+ ? targetBlockIndex - draggedBlockCount
85
+ : targetBlockIndex;
86
+
87
+ moveBlocksToPosition(
88
+ sourceClientIds,
89
+ sourceRootClientId,
90
+ targetRootClientId,
91
+ insertIndex
92
+ );
93
+ }
94
+ };
95
+ }
96
+
97
+ /**
98
+ * A React hook for handling block drop events.
99
+ *
100
+ * @return {Function} The event handler for a block drop event.
101
+ */
102
+ export default function useOnBlockDrop() {
103
+ const { getBlockIndex, getClientIdsOfDescendants } = useSelect(
104
+ blockEditorStore
105
+ );
106
+ const {
107
+ insertBlocks,
108
+ moveBlocksToPosition,
109
+ clearSelectedBlock,
110
+ } = useDispatch( blockEditorStore );
111
+
112
+ return onBlockDrop(
113
+ getBlockIndex,
114
+ getClientIdsOfDescendants,
115
+ moveBlocksToPosition,
116
+ insertBlocks,
117
+ clearSelectedBlock
118
+ );
119
+ }
@@ -7,7 +7,10 @@ import { get } from 'lodash';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { useSelect } from '@wordpress/data';
10
- import { __EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE } from '@wordpress/blocks';
10
+ import {
11
+ __EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE,
12
+ hasBlockSupport,
13
+ } from '@wordpress/blocks';
11
14
 
12
15
  /**
13
16
  * Internal dependencies
@@ -91,8 +94,10 @@ const removeCustomPrefixes = ( path ) => {
91
94
  };
92
95
 
93
96
  /**
94
- * Hook that retrieves the editor setting.
95
- * It works with nested objects using by finding the value at path.
97
+ * Hook that retrieves the given setting for the block instance in use.
98
+ *
99
+ * It looks up the settings first in the block instance hierarchy.
100
+ * If none is found, it'll look it up in the block editor store.
96
101
  *
97
102
  * @param {string} path The path to the setting.
98
103
  * @return {any} Returns the value defined for the setting.
@@ -102,7 +107,7 @@ const removeCustomPrefixes = ( path ) => {
102
107
  * ```
103
108
  */
104
109
  export default function useSetting( path ) {
105
- const { name: blockName } = useBlockEditContext();
110
+ const { name: blockName, clientId } = useBlockEditContext();
106
111
 
107
112
  const setting = useSelect(
108
113
  ( select ) => {
@@ -113,28 +118,59 @@ export default function useSetting( path ) {
113
118
  );
114
119
  return undefined;
115
120
  }
116
- const settings = select( blockEditorStore ).getSettings();
117
121
 
118
- // 1 - Use __experimental features, if available.
119
- // We cascade to the all value if the block one is not available.
122
+ let result;
120
123
  const normalizedPath = removeCustomPrefixes( path );
121
- const defaultsPath = `__experimentalFeatures.${ normalizedPath }`;
122
- const blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;
123
- const experimentalFeaturesResult =
124
- get( settings, blockPath ) ?? get( settings, defaultsPath );
125
124
 
126
- if ( experimentalFeaturesResult !== undefined ) {
125
+ // 1. Take settings from the block instance or its ancestors.
126
+ const candidates = [
127
+ ...select( blockEditorStore ).getBlockParents( clientId ),
128
+ clientId, // The current block is added last, so it overwrites any ancestor.
129
+ ];
130
+ candidates.forEach( ( candidateClientId ) => {
131
+ const candidateBlockName = select(
132
+ blockEditorStore
133
+ ).getBlockName( candidateClientId );
134
+ if (
135
+ hasBlockSupport(
136
+ candidateBlockName,
137
+ '__experimentalSettings',
138
+ false
139
+ )
140
+ ) {
141
+ const candidateAtts = select(
142
+ blockEditorStore
143
+ ).getBlockAttributes( candidateClientId );
144
+ const candidateResult =
145
+ get(
146
+ candidateAtts,
147
+ `settings.blocks.${ blockName }.${ normalizedPath }`
148
+ ) ??
149
+ get( candidateAtts, `settings.${ normalizedPath }` );
150
+ if ( candidateResult !== undefined ) {
151
+ result = candidateResult;
152
+ }
153
+ }
154
+ } );
155
+
156
+ // 2. Fall back to the settings from the block editor store (__experimentalFeatures).
157
+ const settings = select( blockEditorStore ).getSettings();
158
+ if ( result === undefined ) {
159
+ const defaultsPath = `__experimentalFeatures.${ normalizedPath }`;
160
+ const blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;
161
+ result =
162
+ get( settings, blockPath ) ?? get( settings, defaultsPath );
163
+ }
164
+
165
+ // Return if the setting was found in either the block instance or the store.
166
+ if ( result !== undefined ) {
127
167
  if ( PATHS_WITH_MERGE[ normalizedPath ] ) {
128
- return (
129
- experimentalFeaturesResult.custom ??
130
- experimentalFeaturesResult.theme ??
131
- experimentalFeaturesResult.default
132
- );
168
+ return result.custom ?? result.theme ?? result.default;
133
169
  }
134
- return experimentalFeaturesResult;
170
+ return result;
135
171
  }
136
172
 
137
- // 2 - Use deprecated settings, otherwise.
173
+ // 3. Otherwise, use deprecated settings.
138
174
  const deprecatedSettingsValue = deprecatedFlags[ normalizedPath ]
139
175
  ? deprecatedFlags[ normalizedPath ]( settings )
140
176
  : undefined;
@@ -142,13 +178,13 @@ export default function useSetting( path ) {
142
178
  return deprecatedSettingsValue;
143
179
  }
144
180
 
145
- // 3 - Fall back for typography.dropCap:
181
+ // 4. Fallback for typography.dropCap:
146
182
  // This is only necessary to support typography.dropCap.
147
183
  // when __experimentalFeatures are not present (core without plugin).
148
184
  // To remove when __experimentalFeatures are ported to core.
149
185
  return normalizedPath === 'typography.dropCap' ? true : undefined;
150
186
  },
151
- [ blockName, path ]
187
+ [ blockName, clientId, path ]
152
188
  );
153
189
 
154
190
  return setting;
@@ -13,50 +13,55 @@ import { moreHorizontal } from '@wordpress/icons';
13
13
 
14
14
  function Warning( { className, actions, children, secondaryActions } ) {
15
15
  return (
16
- <div className={ classnames( className, 'block-editor-warning' ) }>
17
- <div className="block-editor-warning__contents">
18
- <p className="block-editor-warning__message">{ children }</p>
16
+ <div style={ { display: 'contents', all: 'initial' } }>
17
+ <div className={ classnames( className, 'block-editor-warning' ) }>
18
+ <div className="block-editor-warning__contents">
19
+ <p className="block-editor-warning__message">
20
+ { children }
21
+ </p>
19
22
 
20
- { ( Children.count( actions ) > 0 || secondaryActions ) && (
21
- <div className="block-editor-warning__actions">
22
- { Children.count( actions ) > 0 &&
23
- Children.map( actions, ( action, i ) => (
24
- <span
25
- key={ i }
26
- className="block-editor-warning__action"
23
+ { ( Children.count( actions ) > 0 || secondaryActions ) && (
24
+ <div className="block-editor-warning__actions">
25
+ { Children.count( actions ) > 0 &&
26
+ Children.map( actions, ( action, i ) => (
27
+ <span
28
+ key={ i }
29
+ className="block-editor-warning__action"
30
+ >
31
+ { action }
32
+ </span>
33
+ ) ) }
34
+ { secondaryActions && (
35
+ <DropdownMenu
36
+ className="block-editor-warning__secondary"
37
+ icon={ moreHorizontal }
38
+ label={ __( 'More options' ) }
39
+ popoverProps={ {
40
+ position: 'bottom left',
41
+ className:
42
+ 'block-editor-warning__dropdown',
43
+ } }
44
+ noIcons
27
45
  >
28
- { action }
29
- </span>
30
- ) ) }
31
- { secondaryActions && (
32
- <DropdownMenu
33
- className="block-editor-warning__secondary"
34
- icon={ moreHorizontal }
35
- label={ __( 'More options' ) }
36
- popoverProps={ {
37
- position: 'bottom left',
38
- className: 'block-editor-warning__dropdown',
39
- } }
40
- noIcons
41
- >
42
- { () => (
43
- <MenuGroup>
44
- { secondaryActions.map(
45
- ( item, pos ) => (
46
- <MenuItem
47
- onClick={ item.onClick }
48
- key={ pos }
49
- >
50
- { item.title }
51
- </MenuItem>
52
- )
53
- ) }
54
- </MenuGroup>
55
- ) }
56
- </DropdownMenu>
57
- ) }
58
- </div>
59
- ) }
46
+ { () => (
47
+ <MenuGroup>
48
+ { secondaryActions.map(
49
+ ( item, pos ) => (
50
+ <MenuItem
51
+ onClick={ item.onClick }
52
+ key={ pos }
53
+ >
54
+ { item.title }
55
+ </MenuItem>
56
+ )
57
+ ) }
58
+ </MenuGroup>
59
+ ) }
60
+ </DropdownMenu>
61
+ ) }
62
+ </div>
63
+ ) }
64
+ </div>
60
65
  </div>
61
66
  </div>
62
67
  );
@@ -2,16 +2,25 @@
2
2
 
3
3
  exports[`Warning should match snapshot 1`] = `
4
4
  <div
5
- className="block-editor-warning"
5
+ style={
6
+ Object {
7
+ "all": "initial",
8
+ "display": "contents",
9
+ }
10
+ }
6
11
  >
7
12
  <div
8
- className="block-editor-warning__contents"
13
+ className="block-editor-warning"
9
14
  >
10
- <p
11
- className="block-editor-warning__message"
15
+ <div
16
+ className="block-editor-warning__contents"
12
17
  >
13
- error
14
- </p>
18
+ <p
19
+ className="block-editor-warning__message"
20
+ >
21
+ error
22
+ </p>
23
+ </div>
15
24
  </div>
16
25
  </div>
17
26
  `;
@@ -18,7 +18,7 @@ describe( 'Warning', () => {
18
18
  it( 'should have valid class', () => {
19
19
  const wrapper = shallow( <Warning /> );
20
20
 
21
- expect( wrapper.hasClass( 'block-editor-warning' ) ).toBe( true );
21
+ expect( wrapper.find( '.block-editor-warning' ) ).toHaveLength( 1 );
22
22
  expect( wrapper.find( '.block-editor-warning__actions' ) ).toHaveLength(
23
23
  0
24
24
  );
@@ -11,10 +11,9 @@ import { store as blockEditorStore } from '../../store';
11
11
  import { getBlockClientId } from '../../utils/dom';
12
12
 
13
13
  export default function useClickSelection() {
14
- const { multiSelect, selectBlock } = useDispatch( blockEditorStore );
14
+ const { selectBlock } = useDispatch( blockEditorStore );
15
15
  const {
16
16
  isSelectionEnabled,
17
- getBlockParents,
18
17
  getBlockSelectionStart,
19
18
  hasMultiSelection,
20
19
  } = useSelect( blockEditorStore );
@@ -54,10 +53,8 @@ export default function useClickSelection() {
54
53
  };
55
54
  },
56
55
  [
57
- multiSelect,
58
56
  selectBlock,
59
57
  isSelectionEnabled,
60
- getBlockParents,
61
58
  getBlockSelectionStart,
62
59
  hasMultiSelection,
63
60
  ]
@@ -30,6 +30,16 @@ export default function useInput() {
30
30
  } = useDispatch( blockEditorStore );
31
31
 
32
32
  return useRefEffect( ( node ) => {
33
+ function onBeforeInput( event ) {
34
+ if ( ! hasMultiSelection() ) {
35
+ return;
36
+ }
37
+ // Prevent the browser to format something when we have multiselection.
38
+ if ( event.inputType?.startsWith( 'format' ) ) {
39
+ event.preventDefault();
40
+ }
41
+ }
42
+
33
43
  function onKeyDown( event ) {
34
44
  if ( event.defaultPrevented ) {
35
45
  return;
@@ -102,9 +112,11 @@ export default function useInput() {
102
112
  }
103
113
  }
104
114
 
115
+ node.addEventListener( 'beforeinput', onBeforeInput );
105
116
  node.addEventListener( 'keydown', onKeyDown );
106
117
  node.addEventListener( 'compositionstart', onCompositionStart );
107
118
  return () => {
119
+ node.removeEventListener( 'beforeinput', onBeforeInput );
108
120
  node.removeEventListener( 'keydown', onKeyDown );
109
121
  node.removeEventListener( 'compositionstart', onCompositionStart );
110
122
  };