@wordpress/block-editor 11.0.0 → 11.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 (326) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/README.md +2 -1
  3. package/build/components/alignment-control/ui.js +1 -7
  4. package/build/components/alignment-control/ui.js.map +1 -1
  5. package/build/components/block-alignment-control/use-available-alignments.js +4 -3
  6. package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
  7. package/build/components/block-icon/index.js +4 -2
  8. package/build/components/block-icon/index.js.map +1 -1
  9. package/build/components/block-inspector/index.js +55 -4
  10. package/build/components/block-inspector/index.js.map +1 -1
  11. package/build/components/block-list-appender/index.js +46 -34
  12. package/build/components/block-list-appender/index.js.map +1 -1
  13. package/build/components/block-list-appender/index.native.js +39 -34
  14. package/build/components/block-list-appender/index.native.js.map +1 -1
  15. package/build/components/block-mobile-toolbar/block-actions-menu.native.js +18 -18
  16. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  17. package/build/components/block-mobile-toolbar/index.native.js +1 -1
  18. package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
  19. package/build/components/block-pattern-setup/index.js +14 -7
  20. package/build/components/block-pattern-setup/index.js.map +1 -1
  21. package/build/components/block-styles/index.native.js +1 -3
  22. package/build/components/block-styles/index.native.js.map +1 -1
  23. package/build/components/block-styles/utils.js +7 -10
  24. package/build/components/block-styles/utils.js.map +1 -1
  25. package/build/components/block-toolbar/index.native.js +6 -8
  26. package/build/components/block-toolbar/index.native.js.map +1 -1
  27. package/build/components/block-tools/selected-block-popover.js +1 -3
  28. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  29. package/build/components/block-variation-picker/index.js +1 -1
  30. package/build/components/block-variation-picker/index.js.map +1 -1
  31. package/build/components/colors/utils.js +2 -6
  32. package/build/components/colors/utils.js.map +1 -1
  33. package/build/components/colors-gradients/control.js +0 -3
  34. package/build/components/colors-gradients/control.js.map +1 -1
  35. package/build/components/colors-gradients/dropdown.js +0 -2
  36. package/build/components/colors-gradients/dropdown.js.map +1 -1
  37. package/build/components/colors-gradients/panel-color-gradient-settings.js +2 -19
  38. package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  39. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -3
  40. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  41. package/build/components/copy-handler/index.js +37 -9
  42. package/build/components/copy-handler/index.js.map +1 -1
  43. package/build/components/font-sizes/fluid-utils.js +5 -2
  44. package/build/components/font-sizes/fluid-utils.js.map +1 -1
  45. package/build/components/font-sizes/utils.js +10 -4
  46. package/build/components/font-sizes/utils.js.map +1 -1
  47. package/build/components/font-sizes/with-font-sizes.js +11 -6
  48. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  49. package/build/components/gradients/use-gradient.js +2 -8
  50. package/build/components/gradients/use-gradient.js.map +1 -1
  51. package/build/components/iframe/index.js +13 -95
  52. package/build/components/iframe/index.js.map +1 -1
  53. package/build/components/iframe/use-compatibility-styles.js +93 -0
  54. package/build/components/iframe/use-compatibility-styles.js.map +1 -0
  55. package/build/components/inner-blocks/index.js +6 -2
  56. package/build/components/inner-blocks/index.js.map +1 -1
  57. package/build/components/inserter/hooks/use-insertion-point.js +4 -3
  58. package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
  59. package/build/components/inserter/index.js +13 -4
  60. package/build/components/inserter/index.js.map +1 -1
  61. package/build/components/inserter/media-tab/hooks.js +8 -5
  62. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  63. package/build/components/inserter/quick-inserter.js +6 -3
  64. package/build/components/inserter/quick-inserter.js.map +1 -1
  65. package/build/components/inserter/search-items.js +15 -14
  66. package/build/components/inserter/search-items.js.map +1 -1
  67. package/build/components/inserter/search-results.js +4 -2
  68. package/build/components/inserter/search-results.js.map +1 -1
  69. package/build/components/list-view/block-select-button.js +1 -1
  70. package/build/components/list-view/block-select-button.js.map +1 -1
  71. package/build/components/off-canvas-editor/appender.js +21 -26
  72. package/build/components/off-canvas-editor/appender.js.map +1 -1
  73. package/build/components/off-canvas-editor/block-select-button.js +3 -2
  74. package/build/components/off-canvas-editor/block-select-button.js.map +1 -1
  75. package/build/components/off-canvas-editor/block.js +57 -45
  76. package/build/components/off-canvas-editor/block.js.map +1 -1
  77. package/build/components/off-canvas-editor/index.js +5 -1
  78. package/build/components/off-canvas-editor/index.js.map +1 -1
  79. package/build/components/off-canvas-editor/use-inserted-block.js +58 -0
  80. package/build/components/off-canvas-editor/use-inserted-block.js.map +1 -0
  81. package/build/components/responsive-block-control/label.js.map +1 -1
  82. package/build/components/rich-text/format-edit.js +12 -10
  83. package/build/components/rich-text/format-edit.js.map +1 -1
  84. package/build/components/rich-text/index.js.map +1 -1
  85. package/build/components/rich-text/use-paste-handler.js +21 -12
  86. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  87. package/build/components/spacing-sizes-control/index.js +0 -1
  88. package/build/components/spacing-sizes-control/index.js.map +1 -1
  89. package/build/components/spacing-sizes-control/utils.js +1 -1
  90. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  91. package/build/components/typewriter/index.js +1 -1
  92. package/build/components/typewriter/index.js.map +1 -1
  93. package/build/components/url-popover/image-url-input-ui.js +2 -2
  94. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  95. package/build/components/writing-flow/index.js +1 -1
  96. package/build/components/writing-flow/index.js.map +1 -1
  97. package/build/hooks/border.js +0 -1
  98. package/build/hooks/border.js.map +1 -1
  99. package/build/hooks/color-panel.js +0 -1
  100. package/build/hooks/color-panel.js.map +1 -1
  101. package/build/hooks/color.js +1 -2
  102. package/build/hooks/color.js.map +1 -1
  103. package/build/hooks/font-family.js +4 -4
  104. package/build/hooks/font-family.js.map +1 -1
  105. package/build/hooks/font-size.js +5 -3
  106. package/build/hooks/font-size.js.map +1 -1
  107. package/build/hooks/use-typography-props.js +11 -8
  108. package/build/hooks/use-typography-props.js.map +1 -1
  109. package/build/store/reducer.js +21 -7
  110. package/build/store/reducer.js.map +1 -1
  111. package/build/store/selectors.js +1 -1
  112. package/build/store/selectors.js.map +1 -1
  113. package/build/utils/pasting.js +6 -11
  114. package/build/utils/pasting.js.map +1 -1
  115. package/build-module/components/alignment-control/ui.js +1 -6
  116. package/build-module/components/alignment-control/ui.js.map +1 -1
  117. package/build-module/components/block-alignment-control/use-available-alignments.js +4 -3
  118. package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
  119. package/build-module/components/block-icon/index.js +4 -2
  120. package/build-module/components/block-icon/index.js.map +1 -1
  121. package/build-module/components/block-inspector/index.js +56 -5
  122. package/build-module/components/block-inspector/index.js.map +1 -1
  123. package/build-module/components/block-list-appender/index.js +46 -34
  124. package/build-module/components/block-list-appender/index.js.map +1 -1
  125. package/build-module/components/block-list-appender/index.native.js +39 -32
  126. package/build-module/components/block-list-appender/index.native.js.map +1 -1
  127. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +18 -18
  128. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  129. package/build-module/components/block-mobile-toolbar/index.native.js +1 -1
  130. package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
  131. package/build-module/components/block-pattern-setup/index.js +14 -7
  132. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  133. package/build-module/components/block-styles/index.native.js +1 -2
  134. package/build-module/components/block-styles/index.native.js.map +1 -1
  135. package/build-module/components/block-styles/utils.js +7 -9
  136. package/build-module/components/block-styles/utils.js.map +1 -1
  137. package/build-module/components/block-toolbar/index.native.js +6 -8
  138. package/build-module/components/block-toolbar/index.native.js.map +1 -1
  139. package/build-module/components/block-tools/selected-block-popover.js +1 -2
  140. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  141. package/build-module/components/block-variation-picker/index.js +1 -1
  142. package/build-module/components/block-variation-picker/index.js.map +1 -1
  143. package/build-module/components/colors/utils.js +3 -7
  144. package/build-module/components/colors/utils.js.map +1 -1
  145. package/build-module/components/colors-gradients/control.js +0 -3
  146. package/build-module/components/colors-gradients/control.js.map +1 -1
  147. package/build-module/components/colors-gradients/dropdown.js +0 -2
  148. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  149. package/build-module/components/colors-gradients/panel-color-gradient-settings.js +4 -19
  150. package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  151. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -2
  152. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  153. package/build-module/components/copy-handler/index.js +38 -10
  154. package/build-module/components/copy-handler/index.js.map +1 -1
  155. package/build-module/components/font-sizes/fluid-utils.js +5 -2
  156. package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
  157. package/build-module/components/font-sizes/utils.js +11 -5
  158. package/build-module/components/font-sizes/utils.js.map +1 -1
  159. package/build-module/components/font-sizes/with-font-sizes.js +12 -7
  160. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  161. package/build-module/components/gradients/use-gradient.js +2 -7
  162. package/build-module/components/gradients/use-gradient.js.map +1 -1
  163. package/build-module/components/iframe/index.js +12 -95
  164. package/build-module/components/iframe/index.js.map +1 -1
  165. package/build-module/components/iframe/use-compatibility-styles.js +85 -0
  166. package/build-module/components/iframe/use-compatibility-styles.js.map +1 -0
  167. package/build-module/components/inner-blocks/index.js +6 -2
  168. package/build-module/components/inner-blocks/index.js.map +1 -1
  169. package/build-module/components/inserter/hooks/use-insertion-point.js +4 -3
  170. package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
  171. package/build-module/components/inserter/index.js +13 -4
  172. package/build-module/components/inserter/index.js.map +1 -1
  173. package/build-module/components/inserter/media-tab/hooks.js +8 -5
  174. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  175. package/build-module/components/inserter/quick-inserter.js +6 -3
  176. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  177. package/build-module/components/inserter/search-items.js +15 -13
  178. package/build-module/components/inserter/search-items.js.map +1 -1
  179. package/build-module/components/inserter/search-results.js +4 -2
  180. package/build-module/components/inserter/search-results.js.map +1 -1
  181. package/build-module/components/list-view/block-select-button.js +1 -1
  182. package/build-module/components/list-view/block-select-button.js.map +1 -1
  183. package/build-module/components/off-canvas-editor/appender.js +21 -27
  184. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  185. package/build-module/components/off-canvas-editor/block-select-button.js +3 -2
  186. package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -1
  187. package/build-module/components/off-canvas-editor/block.js +58 -46
  188. package/build-module/components/off-canvas-editor/block.js.map +1 -1
  189. package/build-module/components/off-canvas-editor/index.js +5 -1
  190. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  191. package/build-module/components/off-canvas-editor/use-inserted-block.js +47 -0
  192. package/build-module/components/off-canvas-editor/use-inserted-block.js.map +1 -0
  193. package/build-module/components/responsive-block-control/label.js +1 -2
  194. package/build-module/components/responsive-block-control/label.js.map +1 -1
  195. package/build-module/components/rich-text/format-edit.js +12 -9
  196. package/build-module/components/rich-text/format-edit.js.map +1 -1
  197. package/build-module/components/rich-text/index.js.map +1 -1
  198. package/build-module/components/rich-text/use-paste-handler.js +22 -12
  199. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  200. package/build-module/components/spacing-sizes-control/index.js +0 -1
  201. package/build-module/components/spacing-sizes-control/index.js.map +1 -1
  202. package/build-module/components/spacing-sizes-control/utils.js +1 -1
  203. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  204. package/build-module/components/typewriter/index.js +1 -1
  205. package/build-module/components/typewriter/index.js.map +1 -1
  206. package/build-module/components/url-popover/image-url-input-ui.js +3 -3
  207. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  208. package/build-module/components/writing-flow/index.js +1 -1
  209. package/build-module/components/writing-flow/index.js.map +1 -1
  210. package/build-module/hooks/border.js +0 -1
  211. package/build-module/hooks/border.js.map +1 -1
  212. package/build-module/hooks/color-panel.js +0 -1
  213. package/build-module/hooks/color-panel.js.map +1 -1
  214. package/build-module/hooks/color.js +1 -2
  215. package/build-module/hooks/color.js.map +1 -1
  216. package/build-module/hooks/font-family.js +5 -5
  217. package/build-module/hooks/font-family.js.map +1 -1
  218. package/build-module/hooks/font-size.js +5 -3
  219. package/build-module/hooks/font-size.js.map +1 -1
  220. package/build-module/hooks/use-typography-props.js +11 -8
  221. package/build-module/hooks/use-typography-props.js.map +1 -1
  222. package/build-module/store/reducer.js +21 -6
  223. package/build-module/store/reducer.js.map +1 -1
  224. package/build-module/store/selectors.js +2 -2
  225. package/build-module/store/selectors.js.map +1 -1
  226. package/build-module/utils/pasting.js +6 -10
  227. package/build-module/utils/pasting.js.map +1 -1
  228. package/build-style/content-rtl.css +3 -3
  229. package/build-style/content.css +3 -3
  230. package/build-style/default-editor-styles-rtl.css +3 -3
  231. package/build-style/default-editor-styles.css +3 -3
  232. package/build-style/style-rtl.css +35 -11
  233. package/build-style/style.css +35 -11
  234. package/package.json +29 -29
  235. package/src/components/alignment-control/test/index.js +2 -0
  236. package/src/components/alignment-control/ui.js +1 -7
  237. package/src/components/block-alignment-control/test/index.js +2 -0
  238. package/src/components/block-alignment-control/use-available-alignments.js +4 -3
  239. package/src/components/block-icon/index.js +4 -2
  240. package/src/components/block-icon/test/index.js +9 -5
  241. package/src/components/block-inspector/index.js +77 -4
  242. package/src/components/block-inspector/style.scss +7 -0
  243. package/src/components/block-list-appender/index.js +65 -54
  244. package/src/components/block-list-appender/index.native.js +45 -34
  245. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +18 -22
  246. package/src/components/block-mobile-toolbar/index.native.js +1 -1
  247. package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +125 -0
  248. package/src/components/block-mobile-toolbar/test/block-actions-menu.native.js +439 -0
  249. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +42 -0
  250. package/src/components/block-mover/test/index.native.js +157 -1
  251. package/src/components/block-pattern-setup/index.js +15 -6
  252. package/src/components/block-pattern-setup/style.scss +29 -1
  253. package/src/components/block-styles/index.native.js +1 -2
  254. package/src/components/block-styles/utils.js +5 -7
  255. package/src/components/block-switcher/test/index.js +3 -2
  256. package/src/components/block-toolbar/index.native.js +8 -11
  257. package/src/components/block-tools/selected-block-popover.js +1 -3
  258. package/src/components/block-variation-picker/index.js +5 -1
  259. package/src/components/block-vertical-alignment-control/test/index.js +2 -0
  260. package/src/components/colors/test/with-colors.js +2 -0
  261. package/src/components/colors/utils.js +5 -3
  262. package/src/components/colors-gradients/control.js +0 -7
  263. package/src/components/colors-gradients/dropdown.js +0 -2
  264. package/src/components/colors-gradients/panel-color-gradient-settings.js +4 -22
  265. package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -2
  266. package/src/components/copy-handler/index.js +53 -7
  267. package/src/components/default-block-appender/test/index.js +2 -0
  268. package/src/components/font-sizes/fluid-utils.js +7 -1
  269. package/src/components/font-sizes/utils.js +5 -3
  270. package/src/components/font-sizes/with-font-sizes.js +4 -4
  271. package/src/components/gradients/use-gradient.js +2 -7
  272. package/src/components/iframe/index.js +8 -103
  273. package/src/components/iframe/use-compatibility-styles.js +95 -0
  274. package/src/components/image-size-control/test/index.js +147 -79
  275. package/src/components/inner-blocks/index.js +4 -2
  276. package/src/components/inserter/hooks/use-insertion-point.js +3 -2
  277. package/src/components/inserter/index.js +15 -2
  278. package/src/components/inserter/media-tab/hooks.js +5 -4
  279. package/src/components/inserter/quick-inserter.js +3 -0
  280. package/src/components/inserter/search-items.js +1 -2
  281. package/src/components/inserter/search-results.js +2 -0
  282. package/src/components/link-control/test/index.js +18 -4
  283. package/src/components/list-view/block-select-button.js +1 -1
  284. package/src/components/list-view/style.scss +1 -7
  285. package/src/components/media-replace-flow/test/index.js +2 -0
  286. package/src/components/off-canvas-editor/appender.js +30 -25
  287. package/src/components/off-canvas-editor/block-select-button.js +6 -2
  288. package/src/components/off-canvas-editor/block.js +93 -76
  289. package/src/components/off-canvas-editor/index.js +9 -0
  290. package/src/components/off-canvas-editor/style.scss +5 -1
  291. package/src/components/off-canvas-editor/test/use-inserted-block.js +108 -0
  292. package/src/components/off-canvas-editor/use-inserted-block.js +47 -0
  293. package/src/components/responsive-block-control/label.js +2 -3
  294. package/src/components/responsive-block-control/test/index.js +4 -2
  295. package/src/components/rich-text/format-edit.js +6 -10
  296. package/src/components/rich-text/index.js +1 -0
  297. package/src/components/rich-text/use-paste-handler.js +33 -14
  298. package/src/components/spacing-sizes-control/index.js +0 -1
  299. package/src/components/spacing-sizes-control/utils.js +1 -1
  300. package/src/components/typewriter/index.js +3 -1
  301. package/src/components/url-input/test/button.js +2 -0
  302. package/src/components/url-popover/image-url-input-ui.js +5 -4
  303. package/src/components/url-popover/test/index.js +21 -5
  304. package/src/components/warning/test/index.js +2 -0
  305. package/src/components/writing-flow/index.js +1 -1
  306. package/src/hooks/border.js +0 -1
  307. package/src/hooks/color-panel.js +0 -1
  308. package/src/hooks/color.js +0 -2
  309. package/src/hooks/font-family.js +3 -5
  310. package/src/hooks/font-size.js +13 -4
  311. package/src/hooks/test/use-typography-props.js +26 -0
  312. package/src/hooks/use-typography-props.js +15 -7
  313. package/src/store/reducer.js +13 -6
  314. package/src/store/selectors.js +2 -3
  315. package/src/utils/pasting.js +3 -9
  316. package/tsconfig.tsbuildinfo +1 -1
  317. package/build/components/colors-gradients/use-common-single-multiple-selects.js +0 -21
  318. package/build/components/colors-gradients/use-common-single-multiple-selects.js.map +0 -1
  319. package/build/components/rich-text/file-paste-handler.js +0 -21
  320. package/build/components/rich-text/file-paste-handler.js.map +0 -1
  321. package/build-module/components/colors-gradients/use-common-single-multiple-selects.js +0 -11
  322. package/build-module/components/colors-gradients/use-common-single-multiple-selects.js.map +0 -1
  323. package/build-module/components/rich-text/file-paste-handler.js +0 -13
  324. package/build-module/components/rich-text/file-paste-handler.js.map +0 -1
  325. package/src/components/colors-gradients/use-common-single-multiple-selects.js +0 -11
  326. package/src/components/rich-text/file-paste-handler.js +0 -13
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { useInsertedBlock } from '../use-inserted-block';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { useDispatch, useSelect } from '@wordpress/data';
10
+
11
+ /**
12
+ * External dependencies
13
+ */
14
+ import { act, renderHook } from '@testing-library/react';
15
+
16
+ jest.mock( '@wordpress/data/src/components/use-select', () => {
17
+ // This allows us to tweak the returned value on each test.
18
+ const mock = jest.fn();
19
+ return mock;
20
+ } );
21
+
22
+ jest.mock( '@wordpress/data/src/components/use-dispatch', () => ( {
23
+ useDispatch: jest.fn(),
24
+ } ) );
25
+
26
+ describe( 'useInsertedBlock', () => {
27
+ const mockUpdateBlockAttributes = jest.fn();
28
+
29
+ it( 'returns undefined values when called without a block clientId', () => {
30
+ useSelect.mockImplementation( () => ( {
31
+ insertedBlockAttributes: {
32
+ 'some-attribute': 'some-value',
33
+ },
34
+ insertedBlockName: 'core/navigation-link',
35
+ } ) );
36
+
37
+ useDispatch.mockImplementation( () => ( {
38
+ updateBlockAttributes: mockUpdateBlockAttributes,
39
+ } ) );
40
+
41
+ const { result } = renderHook( () => useInsertedBlock() );
42
+
43
+ const {
44
+ insertedBlockName,
45
+ insertedBlockAttributes,
46
+ setInsertedBlockAttributes,
47
+ } = result.current;
48
+
49
+ expect( insertedBlockName ).toBeUndefined();
50
+ expect( insertedBlockAttributes ).toBeUndefined();
51
+ expect(
52
+ setInsertedBlockAttributes( { 'some-attribute': 'new-value' } )
53
+ ).toBeUndefined();
54
+ } );
55
+
56
+ it( 'returns name and attributes when called with a block clientId', () => {
57
+ useSelect.mockImplementation( () => ( {
58
+ insertedBlockAttributes: {
59
+ 'some-attribute': 'some-value',
60
+ },
61
+ insertedBlockName: 'core/navigation-link',
62
+ } ) );
63
+
64
+ useDispatch.mockImplementation( () => ( {
65
+ updateBlockAttributes: mockUpdateBlockAttributes,
66
+ } ) );
67
+
68
+ const { result } = renderHook( () =>
69
+ useInsertedBlock( 'some-client-id-here' )
70
+ );
71
+
72
+ const { insertedBlockName, insertedBlockAttributes } = result.current;
73
+
74
+ expect( insertedBlockName ).toBe( 'core/navigation-link' );
75
+ expect( insertedBlockAttributes ).toEqual( {
76
+ 'some-attribute': 'some-value',
77
+ } );
78
+ } );
79
+
80
+ it( 'dispatches updateBlockAttributes on provided client ID with new attributes when setInsertedBlockAttributes is called', () => {
81
+ useSelect.mockImplementation( () => ( {
82
+ insertedBlockAttributes: {
83
+ 'some-attribute': 'some-value',
84
+ },
85
+ insertedBlockName: 'core/navigation-link',
86
+ } ) );
87
+
88
+ useDispatch.mockImplementation( () => ( {
89
+ updateBlockAttributes: mockUpdateBlockAttributes,
90
+ } ) );
91
+
92
+ const clientId = '123456789';
93
+
94
+ const { result } = renderHook( () => useInsertedBlock( clientId ) );
95
+
96
+ const { setInsertedBlockAttributes } = result.current;
97
+
98
+ act( () => {
99
+ setInsertedBlockAttributes( {
100
+ 'some-attribute': 'new-value',
101
+ } );
102
+ } );
103
+
104
+ expect( mockUpdateBlockAttributes ).toHaveBeenCalledWith( clientId, {
105
+ 'some-attribute': 'new-value',
106
+ } );
107
+ } );
108
+ } );
@@ -0,0 +1,47 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useSelect, useDispatch } from '@wordpress/data';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { store as blockEditorStore } from '../../store';
10
+
11
+ export const useInsertedBlock = ( insertedBlockClientId ) => {
12
+ const { insertedBlockAttributes, insertedBlockName } = useSelect(
13
+ ( select ) => {
14
+ const { getBlockName, getBlockAttributes } =
15
+ select( blockEditorStore );
16
+
17
+ return {
18
+ insertedBlockAttributes: getBlockAttributes(
19
+ insertedBlockClientId
20
+ ),
21
+ insertedBlockName: getBlockName( insertedBlockClientId ),
22
+ };
23
+ },
24
+ [ insertedBlockClientId ]
25
+ );
26
+
27
+ const { updateBlockAttributes } = useDispatch( blockEditorStore );
28
+
29
+ const setInsertedBlockAttributes = ( _updatedAttributes ) => {
30
+ if ( ! insertedBlockClientId ) return;
31
+ updateBlockAttributes( insertedBlockClientId, _updatedAttributes );
32
+ };
33
+
34
+ if ( ! insertedBlockClientId ) {
35
+ return {
36
+ insertedBlockAttributes: undefined,
37
+ insertedBlockName: undefined,
38
+ setInsertedBlockAttributes,
39
+ };
40
+ }
41
+
42
+ return {
43
+ insertedBlockAttributes,
44
+ insertedBlockName,
45
+ setInsertedBlockAttributes,
46
+ };
47
+ };
@@ -4,7 +4,6 @@
4
4
  import { useInstanceId } from '@wordpress/compose';
5
5
  import { VisuallyHidden } from '@wordpress/components';
6
6
  import { _x, sprintf } from '@wordpress/i18n';
7
- import { Fragment } from '@wordpress/element';
8
7
 
9
8
  export default function ResponsiveBlockControlLabel( {
10
9
  property,
@@ -24,13 +23,13 @@ export default function ResponsiveBlockControlLabel( {
24
23
  viewport.label
25
24
  );
26
25
  return (
27
- <Fragment>
26
+ <>
28
27
  <span aria-describedby={ `rbc-desc-${ instanceId }` }>
29
28
  { viewport.label }
30
29
  </span>
31
30
  <VisuallyHidden as="span" id={ `rbc-desc-${ instanceId }` }>
32
31
  { accessibleLabel }
33
32
  </VisuallyHidden>
34
- </Fragment>
33
+ </>
35
34
  );
36
35
  }
@@ -15,6 +15,8 @@ import { SelectControl } from '@wordpress/components';
15
15
  */
16
16
  import ResponsiveBlockControl from '../index';
17
17
 
18
+ jest.useFakeTimers();
19
+
18
20
  const inputId = 'input-12345678';
19
21
 
20
22
  const sizeOptions = [
@@ -38,13 +40,13 @@ const sizeOptions = [
38
40
 
39
41
  const renderTestDefaultControlComponent = ( labelComponent, device ) => {
40
42
  return (
41
- <Fragment>
43
+ <>
42
44
  <SelectControl label={ labelComponent } options={ sizeOptions } />
43
45
  <p id={ device.id }>
44
46
  { device.label } is used here for testing purposes to ensure we
45
47
  have access to details about the device.
46
48
  </p>
47
- </Fragment>
49
+ </>
48
50
  );
49
51
  };
50
52
 
@@ -6,10 +6,6 @@ import {
6
6
  getActiveObject,
7
7
  isCollapsed,
8
8
  } from '@wordpress/rich-text';
9
- /**
10
- * External dependencies
11
- */
12
- import { find } from 'lodash';
13
9
 
14
10
  export default function FormatEdit( {
15
11
  formatTypes,
@@ -40,13 +36,13 @@ export default function FormatEdit( {
40
36
  if ( name === 'core/link' && ! isCollapsed( value ) ) {
41
37
  const formats = value.formats;
42
38
 
43
- const linkFormatAtStart = find( formats[ value.start ], {
44
- type: 'core/link',
45
- } );
39
+ const linkFormatAtStart = formats[ value.start ]?.find(
40
+ ( { type } ) => type === 'core/link'
41
+ );
46
42
 
47
- const linkFormatAtEnd = find( formats[ value.end - 1 ], {
48
- type: 'core/link',
49
- } );
43
+ const linkFormatAtEnd = formats[ value.end - 1 ]?.find(
44
+ ( { type } ) => type === 'core/link'
45
+ );
50
46
 
51
47
  if (
52
48
  ! linkFormatAtStart ||
@@ -368,6 +368,7 @@ function RichTextWrapper(
368
368
  <Popover.__unstableSlotNameProvider value="__unstable-block-tools-after">
369
369
  { children &&
370
370
  children( { value, onChange, onFocus } ) }
371
+
371
372
  <FormatEdit
372
373
  value={ value }
373
374
  onChange={ onChange }
@@ -4,7 +4,11 @@
4
4
  import { useRef } from '@wordpress/element';
5
5
  import { useRefEffect } from '@wordpress/compose';
6
6
  import { getFilesFromDataTransfer } from '@wordpress/dom';
7
- import { pasteHandler } from '@wordpress/blocks';
7
+ import {
8
+ pasteHandler,
9
+ findTransform,
10
+ getBlockTransforms,
11
+ } from '@wordpress/blocks';
8
12
  import {
9
13
  isEmpty,
10
14
  insert,
@@ -17,7 +21,6 @@ import { isURL } from '@wordpress/url';
17
21
  /**
18
22
  * Internal dependencies
19
23
  */
20
- import { filePasteHandler } from './file-paste-handler';
21
24
  import { addActiveFormats, isShortcode } from './utils';
22
25
  import { splitValue } from './split-value';
23
26
  import { shouldDismissPastedFiles } from '../../utils/pasting';
@@ -155,6 +158,12 @@ export function usePasteHandler( props ) {
155
158
  return;
156
159
  }
157
160
 
161
+ if ( files?.length ) {
162
+ // Allows us to ask for this information when we get a report.
163
+ // eslint-disable-next-line no-console
164
+ window.console.log( 'Received items:\n\n', files );
165
+ }
166
+
158
167
  // Process any attached files, unless we infer that the files in
159
168
  // question are redundant "screenshots" of the actual HTML payload,
160
169
  // as created by certain office-type programs.
@@ -164,23 +173,33 @@ export function usePasteHandler( props ) {
164
173
  files?.length &&
165
174
  ! shouldDismissPastedFiles( files, html, plainText )
166
175
  ) {
167
- const content = pasteHandler( {
168
- HTML: filePasteHandler( files ),
169
- mode: 'BLOCKS',
170
- tagName,
171
- preserveWhiteSpace,
172
- } );
173
-
174
- // Allows us to ask for this information when we get a report.
175
- // eslint-disable-next-line no-console
176
- window.console.log( 'Received items:\n\n', files );
176
+ const fromTransforms = getBlockTransforms( 'from' );
177
+ const blocks = files
178
+ .reduce( ( accumulator, file ) => {
179
+ const transformation = findTransform(
180
+ fromTransforms,
181
+ ( transform ) =>
182
+ transform.type === 'files' &&
183
+ transform.isMatch( [ file ] )
184
+ );
185
+ if ( transformation ) {
186
+ accumulator.push(
187
+ transformation.transform( [ file ] )
188
+ );
189
+ }
190
+ return accumulator;
191
+ }, [] )
192
+ .flat();
193
+ if ( ! blocks.length ) {
194
+ return;
195
+ }
177
196
 
178
197
  if ( onReplace && isEmpty( value ) ) {
179
- onReplace( content );
198
+ onReplace( blocks );
180
199
  } else {
181
200
  splitValue( {
182
201
  value,
183
- pastedBlocks: content,
202
+ pastedBlocks: blocks,
184
203
  onReplace,
185
204
  onSplit,
186
205
  onSplitMiddle,
@@ -78,7 +78,6 @@ export default function SpacingSizesControl( {
78
78
 
79
79
  return (
80
80
  <fieldset
81
- role="region"
82
81
  className={ classnames( 'component-spacing-sizes-control', {
83
82
  'is-unlinked': ! isLinked,
84
83
  } ) }
@@ -96,7 +96,7 @@ export function getSpacingPresetCssVar( value ) {
96
96
  *
97
97
  * @param {string} value Value to extract slug from.
98
98
  *
99
- * @return {number} The int value of the slug from given spacing preset.
99
+ * @return {string|undefined} The int value of the slug from given spacing preset.
100
100
  */
101
101
  export function getSpacingPresetSlug( value ) {
102
102
  if ( ! value ) {
@@ -105,7 +105,9 @@ export function useTypewriter() {
105
105
  return;
106
106
  }
107
107
 
108
- const windowScroll = scrollContainer === ownerDocument.body;
108
+ const windowScroll =
109
+ scrollContainer === ownerDocument.body ||
110
+ scrollContainer === ownerDocument.documentElement;
109
111
  const scrollY = windowScroll
110
112
  ? defaultView.scrollY
111
113
  : scrollContainer.scrollTop;
@@ -9,6 +9,8 @@ import userEvent from '@testing-library/user-event';
9
9
  */
10
10
  import URLInputButton from '../button';
11
11
 
12
+ jest.useFakeTimers();
13
+
12
14
  describe( 'URLInputButton', () => {
13
15
  it( 'should render a `Insert link` button and not be pressed when `url` is not provided', () => {
14
16
  render( <URLInputButton /> );
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { find, map } from 'lodash';
4
+ import { map } from 'lodash';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -189,7 +189,7 @@ const ImageURLInputUI = ( {
189
189
  linkDestinationInput = LINK_DESTINATION_NONE;
190
190
  } else {
191
191
  linkDestinationInput = (
192
- find( linkDestinations, ( destination ) => {
192
+ linkDestinations.find( ( destination ) => {
193
193
  return destination.url === value;
194
194
  } ) || { linkDestination: LINK_DESTINATION_CUSTOM }
195
195
  ).linkDestination;
@@ -236,8 +236,9 @@ const ImageURLInputUI = ( {
236
236
  const linkEditorValue = urlInput !== null ? urlInput : url;
237
237
 
238
238
  const urlLabel = (
239
- find( getLinkDestinations(), [ 'linkDestination', linkDestination ] ) ||
240
- {}
239
+ getLinkDestinations().find(
240
+ ( destination ) => destination.linkDestination === linkDestination
241
+ ) || {}
241
242
  ).title;
242
243
 
243
244
  return (
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { act, render, screen } from '@testing-library/react';
4
+ import { render, screen, waitFor } from '@testing-library/react';
5
5
  import userEvent from '@testing-library/user-event';
6
6
 
7
7
  /**
@@ -11,6 +11,16 @@ import URLPopover from '../';
11
11
 
12
12
  jest.useRealTimers();
13
13
 
14
+ /**
15
+ * Returns the first found popover element up the DOM tree.
16
+ *
17
+ * @param {HTMLElement} element Element to start with.
18
+ * @return {HTMLElement|null} Popover element, or `null` if not found.
19
+ */
20
+ function getWrappingPopoverElement( element ) {
21
+ return element.closest( '.components-popover' );
22
+ }
23
+
14
24
  describe( 'URLPopover', () => {
15
25
  it( 'matches the snapshot in its default state', async () => {
16
26
  const { container } = render(
@@ -22,8 +32,11 @@ describe( 'URLPopover', () => {
22
32
  </URLPopover>
23
33
  );
24
34
 
25
- // wait for `Popover` effects to finish
26
- await act( () => Promise.resolve() );
35
+ await waitFor( () =>
36
+ expect(
37
+ getWrappingPopoverElement( screen.getByText( 'Editor' ) )
38
+ ).toBePositionedPopover()
39
+ );
27
40
 
28
41
  expect( container ).toMatchSnapshot();
29
42
  } );
@@ -53,8 +66,11 @@ describe( 'URLPopover', () => {
53
66
  </URLPopover>
54
67
  );
55
68
 
56
- // wait for `Popover` effects to finish
57
- await act( () => Promise.resolve() );
69
+ await waitFor( () =>
70
+ expect(
71
+ getWrappingPopoverElement( screen.getByText( 'Editor' ) )
72
+ ).toBePositionedPopover()
73
+ );
58
74
 
59
75
  expect( container ).toMatchSnapshot();
60
76
  } );
@@ -9,6 +9,8 @@ import userEvent from '@testing-library/user-event';
9
9
  */
10
10
  import Warning from '../index';
11
11
 
12
+ jest.useFakeTimers();
13
+
12
14
  describe( 'Warning', () => {
13
15
  it( 'should match snapshot', () => {
14
16
  const { container } = render( <Warning>error</Warning> );
@@ -44,7 +44,7 @@ export function useWritingFlow() {
44
44
  useArrowNav(),
45
45
  useRefEffect(
46
46
  ( node ) => {
47
- node.tabIndex = -1;
47
+ node.tabIndex = 0;
48
48
  node.contentEditable = hasMultiSelection;
49
49
 
50
50
  if ( ! hasMultiSelection ) {
@@ -274,7 +274,6 @@ export function BorderPanel( props ) {
274
274
  popoverPlacement="left-start"
275
275
  size="__unstable-large"
276
276
  value={ hydratedBorder }
277
- __experimentalHasMultipleOrigins={ true }
278
277
  __experimentalIsRenderedInSidebar={ true }
279
278
  />
280
279
  </ToolsPanelItem>
@@ -81,7 +81,6 @@ export default function ColorPanel( {
81
81
  panelId={ clientId }
82
82
  settings={ settings }
83
83
  __experimentalIsItemGroup={ false }
84
- __experimentalHasMultipleOrigins
85
84
  __experimentalIsRenderedInSidebar
86
85
  { ...colorGradientSettings }
87
86
  />
@@ -522,8 +522,6 @@ export function ColorEdit( props ) {
522
522
  allSolids,
523
523
  style?.elements?.link?.color?.text
524
524
  ),
525
- clearable:
526
- !! style?.elements?.link?.color?.text,
527
525
  isShownByDefault: defaultColorControls?.link,
528
526
  resetAllFilter: resetAllLinkFilter,
529
527
  },
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { find, kebabCase } from 'lodash';
4
+ import { kebabCase } from 'lodash';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -111,14 +111,12 @@ export function FontFamilyEdit( {
111
111
  } ) {
112
112
  const fontFamilies = useSetting( 'typography.fontFamilies' );
113
113
 
114
- const value = find(
115
- fontFamilies,
114
+ const value = fontFamilies?.find(
116
115
  ( { slug } ) => fontFamily === slug
117
116
  )?.fontFamily;
118
117
 
119
118
  function onChange( newValue ) {
120
- const predefinedFontFamily = find(
121
- fontFamilies,
119
+ const predefinedFontFamily = fontFamilies?.find(
122
120
  ( { fontFamily: f } ) => f === newValue
123
121
  );
124
122
  setAttributes( {
@@ -324,13 +324,22 @@ function addEditPropsForFluidCustomFontSizes( blockType ) {
324
324
  // BlockListContext.Provider. If we set fontSize using editor.
325
325
  // BlockListBlock instead of using getEditWrapperProps then the value is
326
326
  // clobbered when the core/style/addEditProps filter runs.
327
- const isFluidTypographyEnabled =
328
- !! select( blockEditorStore ).getSettings().__experimentalFeatures
327
+ const fluidTypographyConfig =
328
+ select( blockEditorStore ).getSettings().__experimentalFeatures
329
329
  ?.typography?.fluid;
330
330
 
331
+ const fluidTypographySettings =
332
+ typeof fluidTypographyConfig === 'object'
333
+ ? fluidTypographyConfig
334
+ : {};
335
+
331
336
  const newFontSize =
332
- fontSize && isFluidTypographyEnabled
333
- ? getComputedFluidTypographyValue( { fontSize } )
337
+ fontSize && !! fluidTypographyConfig
338
+ ? getComputedFluidTypographyValue( {
339
+ fontSize,
340
+ minimumFontSizeLimit:
341
+ fluidTypographySettings?.minFontSize,
342
+ } )
334
343
  : null;
335
344
 
336
345
  if ( newFontSize === null ) {
@@ -47,4 +47,30 @@ describe( 'getTypographyClassesAndStyles', () => {
47
47
  },
48
48
  } );
49
49
  } );
50
+
51
+ it( 'should return configured fluid font size styles', () => {
52
+ const attributes = {
53
+ fontFamily: 'tofu',
54
+ style: {
55
+ typography: {
56
+ textDecoration: 'underline',
57
+ fontSize: '2rem',
58
+ textTransform: 'uppercase',
59
+ },
60
+ },
61
+ };
62
+ expect(
63
+ getTypographyClassesAndStyles( attributes, {
64
+ minFontSize: '1rem',
65
+ } )
66
+ ).toEqual( {
67
+ className: 'has-tofu-font-family',
68
+ style: {
69
+ textDecoration: 'underline',
70
+ fontSize:
71
+ 'clamp(1.5rem, 1.5rem + ((1vw - 0.48rem) * 0.962), 2rem)',
72
+ textTransform: 'uppercase',
73
+ },
74
+ } );
75
+ } );
50
76
  } );
@@ -19,23 +19,31 @@ import { getComputedFluidTypographyValue } from '../components/font-sizes/fluid-
19
19
  * Provides the CSS class names and inline styles for a block's typography support
20
20
  * attributes.
21
21
  *
22
- * @param {Object} attributes Block attributes.
23
- * @param {boolean} isFluidFontSizeActive Whether the function should try to convert font sizes to fluid values.
22
+ * @param {Object} attributes Block attributes.
23
+ * @param {Object|boolean} fluidTypographySettings If boolean, whether the function should try to convert font sizes to fluid values,
24
+ * otherwise an object containing theme fluid typography settings.
24
25
  *
25
26
  * @return {Object} Typography block support derived CSS classes & styles.
26
27
  */
27
28
  export function getTypographyClassesAndStyles(
28
29
  attributes,
29
- isFluidFontSizeActive
30
+ fluidTypographySettings
30
31
  ) {
31
32
  let typographyStyles = attributes?.style?.typography || {};
32
33
 
33
- if ( isFluidFontSizeActive ) {
34
+ if (
35
+ !! fluidTypographySettings &&
36
+ ( true === fluidTypographySettings ||
37
+ Object.keys( fluidTypographySettings ).length !== 0 )
38
+ ) {
39
+ const newFontSize =
40
+ getComputedFluidTypographyValue( {
41
+ fontSize: attributes?.style?.typography?.fontSize,
42
+ minimumFontSizeLimit: fluidTypographySettings?.minFontSize,
43
+ } ) || attributes?.style?.typography?.fontSize;
34
44
  typographyStyles = {
35
45
  ...typographyStyles,
36
- fontSize: getComputedFluidTypographyValue( {
37
- fontSize: attributes?.style?.typography?.fontSize,
38
- } ),
46
+ fontSize: newFontSize,
39
47
  };
40
48
  }
41
49
 
@@ -2,7 +2,6 @@
2
2
  * External dependencies
3
3
  */
4
4
  import fastDeepEqual from 'fast-deep-equal/es6';
5
- import { omit, isEmpty } from 'lodash';
6
5
 
7
6
  /**
8
7
  * WordPress dependencies
@@ -113,7 +112,10 @@ function getFlattenedClientIds( blocks ) {
113
112
  * @return {Array} Flattened block attributes object.
114
113
  */
115
114
  function getFlattenedBlocksWithoutAttributes( blocks ) {
116
- return flattenBlocks( blocks, ( block ) => omit( block, 'attributes' ) );
115
+ return flattenBlocks( blocks, ( block ) => {
116
+ const { attributes, ...restBlock } = block;
117
+ return restBlock;
118
+ } );
117
119
  }
118
120
 
119
121
  /**
@@ -782,8 +784,8 @@ export const blocks = pipe(
782
784
  }
783
785
 
784
786
  // Do nothing if only attributes change.
785
- const changes = omit( action.updates, 'attributes' );
786
- if ( isEmpty( changes ) ) {
787
+ const { attributes, ...changes } = action.updates;
788
+ if ( Object.values( changes ).length === 0 ) {
787
789
  return state;
788
790
  }
789
791
 
@@ -1641,13 +1643,18 @@ export const blockListSettings = ( state = {}, action ) => {
1641
1643
  // should correct the state.
1642
1644
  case 'REPLACE_BLOCKS':
1643
1645
  case 'REMOVE_BLOCKS': {
1644
- return omit( state, action.clientIds );
1646
+ return Object.fromEntries(
1647
+ Object.entries( state ).filter(
1648
+ ( [ id ] ) => ! action.clientIds.includes( id )
1649
+ )
1650
+ );
1645
1651
  }
1646
1652
  case 'UPDATE_BLOCK_LIST_SETTINGS': {
1647
1653
  const { clientId } = action;
1648
1654
  if ( ! action.settings ) {
1649
1655
  if ( state.hasOwnProperty( clientId ) ) {
1650
- return omit( state, clientId );
1656
+ const { [ clientId ]: removedBlock, ...restBlocks } = state;
1657
+ return restBlocks;
1651
1658
  }
1652
1659
 
1653
1660
  return state;