@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
@@ -19,86 +19,7 @@ import { __experimentalStyleProvider as StyleProvider } from '@wordpress/compone
19
19
 
20
20
  import { useBlockSelectionClearer } from '../block-selection-clearer';
21
21
  import { useWritingFlow } from '../writing-flow';
22
- const BODY_CLASS_NAME = 'editor-styles-wrapper';
23
- const BLOCK_PREFIX = 'wp-block';
24
- /**
25
- * Clones stylesheets targetting the editor canvas to the given document. A
26
- * stylesheet is considered targetting the editor a canvas if it contains the
27
- * `editor-styles-wrapper`, `wp-block`, or `wp-block-*` class selectors.
28
- *
29
- * Ideally, this hook should be removed in the future and styles should be added
30
- * explicitly as editor styles.
31
- */
32
-
33
- function useStylesCompatibility() {
34
- return useRefEffect(node => {
35
- // Search the document for stylesheets targetting the editor canvas.
36
- Array.from(document.styleSheets).forEach(styleSheet => {
37
- try {
38
- // May fail for external styles.
39
- // eslint-disable-next-line no-unused-expressions
40
- styleSheet.cssRules;
41
- } catch (e) {
42
- return;
43
- }
44
-
45
- const {
46
- ownerNode,
47
- cssRules
48
- } = styleSheet;
49
-
50
- if (!cssRules) {
51
- return;
52
- } // Generally, ignore inline styles. We add inline styles belonging to a
53
- // stylesheet later, which may or may not match the selectors.
54
-
55
-
56
- if (ownerNode.tagName !== 'LINK') {
57
- return;
58
- } // Don't try to add the reset styles, which were removed as a dependency
59
- // from `edit-blocks` for the iframe since we don't need to reset admin
60
- // styles.
61
-
62
-
63
- if (ownerNode.id === 'wp-reset-editor-styles-css') {
64
- return;
65
- }
66
-
67
- function matchFromRules(_cssRules) {
68
- return Array.from(_cssRules).find(_ref => {
69
- let {
70
- selectorText,
71
- conditionText,
72
- cssRules: __cssRules
73
- } = _ref;
74
-
75
- // If the rule is conditional then it will not have selector text.
76
- // Recurse into child CSS ruleset to determine selector eligibility.
77
- if (conditionText) {
78
- return matchFromRules(__cssRules);
79
- }
80
-
81
- return selectorText && (selectorText.includes(`.${BODY_CLASS_NAME}`) || selectorText.includes(`.${BLOCK_PREFIX}`));
82
- });
83
- }
84
-
85
- const isMatch = matchFromRules(cssRules);
86
-
87
- if (isMatch && !node.ownerDocument.getElementById(ownerNode.id)) {
88
- // Display warning once we have a way to add style dependencies to the editor.
89
- // See: https://github.com/WordPress/gutenberg/pull/37466.
90
- node.appendChild(ownerNode.cloneNode(true)); // Add inline styles belonging to the stylesheet.
91
-
92
- const inlineCssId = ownerNode.id.replace('-css', '-inline-css');
93
- const inlineCssElement = document.getElementById(inlineCssId);
94
-
95
- if (inlineCssElement) {
96
- node.appendChild(inlineCssElement.cloneNode(true));
97
- }
98
- }
99
- });
100
- }, []);
101
- }
22
+ import { useCompatibilityStyles } from './use-compatibility-styles';
102
23
  /**
103
24
  * Bubbles some event types (keydown, keypress, and dragover) to parent document
104
25
  * document to ensure that the keyboard shortcuts and drag and drop work.
@@ -110,7 +31,6 @@ function useStylesCompatibility() {
110
31
  * @param {Document} doc Document to attach listeners to.
111
32
  */
112
33
 
113
-
114
34
  function bubbleEvents(doc) {
115
35
  const {
116
36
  defaultView
@@ -158,11 +78,11 @@ function useParsedAssets(html) {
158
78
  }, [html]);
159
79
  }
160
80
 
161
- async function loadScript(head, _ref2) {
81
+ async function loadScript(head, _ref) {
162
82
  let {
163
83
  id,
164
84
  src
165
- } = _ref2;
85
+ } = _ref;
166
86
  return new Promise((resolve, reject) => {
167
87
  const script = head.ownerDocument.createElement('script');
168
88
  script.id = id;
@@ -181,7 +101,7 @@ async function loadScript(head, _ref2) {
181
101
  });
182
102
  }
183
103
 
184
- function Iframe(_ref3, ref) {
104
+ function Iframe(_ref2, ref) {
185
105
  let {
186
106
  contentRef,
187
107
  children,
@@ -192,11 +112,14 @@ function Iframe(_ref3, ref) {
192
112
  frameSize = 0,
193
113
  readonly,
194
114
  ...props
195
- } = _ref3;
115
+ } = _ref2;
196
116
  const [, forceRender] = useReducer(() => ({}));
197
117
  const [iframeDocument, setIframeDocument] = useState();
198
118
  const [bodyClasses, setBodyClasses] = useState([]);
199
119
  const styles = useParsedAssets(assets === null || assets === void 0 ? void 0 : assets.styles);
120
+ const styleIds = styles.map(style => style.id);
121
+ const compatStyles = useCompatibilityStyles();
122
+ const neededCompatStyles = compatStyles.filter(style => !styleIds.includes(style.id));
200
123
  const scripts = useParsedAssets(assets === null || assets === void 0 ? void 0 : assets.scripts);
201
124
  const clearerRef = useBlockSelectionClearer();
202
125
  const [before, writingFlowRef, after] = useWritingFlow();
@@ -258,8 +181,7 @@ function Iframe(_ref3, ref) {
258
181
  });
259
182
  }, []);
260
183
  const bodyRef = useMergeRefs([contentRef, clearerRef, writingFlowRef]);
261
- const styleCompatibilityRef = useStylesCompatibility();
262
- head = createElement(Fragment, null, createElement("style", null, 'html{height:auto!important;}body{margin:0}'), styles.map(_ref4 => {
184
+ head = createElement(Fragment, null, createElement("style", null, 'html{height:auto!important;}body{margin:0}'), [...styles, ...neededCompatStyles].map(_ref3 => {
263
185
  let {
264
186
  tagName,
265
187
  href,
@@ -267,7 +189,7 @@ function Iframe(_ref3, ref) {
267
189
  rel,
268
190
  media,
269
191
  textContent
270
- } = _ref4;
192
+ } = _ref3;
271
193
  const TagName = tagName.toLowerCase();
272
194
 
273
195
  if (TagName === 'style') {
@@ -295,7 +217,7 @@ function Iframe(_ref3, ref) {
295
217
  ref: headRef
296
218
  }, head, createElement("style", null, `html { transition: background 5s; ${frameSize ? 'background: #2f2f2f; transition: background 0s;' : ''} }`)), createElement("body", {
297
219
  ref: bodyRef,
298
- className: classnames('block-editor-iframe__body', BODY_CLASS_NAME, ...bodyClasses),
220
+ className: classnames('block-editor-iframe__body', 'editor-styles-wrapper', ...bodyClasses),
299
221
  style: {
300
222
  // This is the remaining percentage from the scaling down
301
223
  // of the iframe body(`scale(0.45)`). We also need to subtract
@@ -305,12 +227,7 @@ function Iframe(_ref3, ref) {
305
227
  transform: `scale( ${scale} )`
306
228
  },
307
229
  inert: readonly ? 'true' : undefined
308
- }, contentResizeListener, createElement("div", {
309
- style: {
310
- display: 'none'
311
- },
312
- ref: styleCompatibilityRef
313
- }), createElement(StyleProvider, {
230
+ }, contentResizeListener, createElement(StyleProvider, {
314
231
  document: iframeDocument
315
232
  }, children))), iframeDocument.documentElement)), tabIndex >= 0 && after);
316
233
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"names":["classnames","useState","createPortal","forwardRef","useMemo","useReducer","__","useResizeObserver","useMergeRefs","useRefEffect","__experimentalStyleProvider","StyleProvider","useBlockSelectionClearer","useWritingFlow","BODY_CLASS_NAME","BLOCK_PREFIX","useStylesCompatibility","node","Array","from","document","styleSheets","forEach","styleSheet","cssRules","e","ownerNode","tagName","id","matchFromRules","_cssRules","find","selectorText","conditionText","__cssRules","includes","isMatch","ownerDocument","getElementById","appendChild","cloneNode","inlineCssId","replace","inlineCssElement","bubbleEvents","doc","defaultView","frameElement","bubbleEvent","event","prototype","Object","getPrototypeOf","constructorName","constructor","name","Constructor","window","init","key","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","cancelled","dispatchEvent","preventDefault","eventTypes","addEventListener","useParsedAssets","html","implementation","createHTMLDocument","body","innerHTML","children","loadScript","head","src","Promise","resolve","reject","script","createElement","onload","onerror","Iframe","ref","contentRef","tabIndex","assets","scale","frameSize","readonly","props","forceRender","iframeDocument","setIframeDocument","bodyClasses","setBodyClasses","styles","scripts","clearerRef","before","writingFlowRef","after","contentResizeListener","height","contentHeight","setRef","iFrameDocument","preventFileDropDefault","setDocumentIfReady","contentDocument","readyState","documentElement","classList","filter","startsWith","dir","removeChild","removeEventListener","headRef","element","reduce","promise","then","finally","bodyRef","styleCompatibilityRef","map","href","rel","media","textContent","TagName","toLowerCase","marginBottom","marginTop","transform","undefined","display"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,QADD,EAECC,YAFD,EAGCC,UAHD,EAICC,OAJD,EAKCC,UALD,QAMO,oBANP;AAOA,SAASC,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IAAA,GAAG,EAAGZ;AAFP,IA1BD,EA8BC,cAAC,aAAD;AAAe,IAAA,QAAQ,EAAGjC;AAA1B,KACGrB,QADH,CA9BD,CAXD,CADW,EA+CXqB,cAAc,CAACmB,eA/CJ,CATd,CAFD,EA6DG1B,QAAQ,IAAI,CAAZ,IAAiBgB,KA7DpB,CADD;AAiEA;;AAED,eAAe3G,UAAU,CAAEwF,MAAF,CAAzB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseMemo,\n\tuseReducer,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseResizeObserver,\n\tuseMergeRefs,\n\tuseRefEffect,\n} from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useWritingFlow } from '../writing-flow';\n\nconst BODY_CLASS_NAME = 'editor-styles-wrapper';\nconst BLOCK_PREFIX = 'wp-block';\n\n/**\n * Clones stylesheets targetting the editor canvas to the given document. A\n * stylesheet is considered targetting the editor a canvas if it contains the\n * `editor-styles-wrapper`, `wp-block`, or `wp-block-*` class selectors.\n *\n * Ideally, this hook should be removed in the future and styles should be added\n * explicitly as editor styles.\n */\nfunction useStylesCompatibility() {\n\treturn useRefEffect( ( node ) => {\n\t\t// Search the document for stylesheets targetting the editor canvas.\n\t\tArray.from( document.styleSheets ).forEach( ( styleSheet ) => {\n\t\t\ttry {\n\t\t\t\t// May fail for external styles.\n\t\t\t\t// eslint-disable-next-line no-unused-expressions\n\t\t\t\tstyleSheet.cssRules;\n\t\t\t} catch ( e ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ownerNode, cssRules } = styleSheet;\n\n\t\t\tif ( ! cssRules ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Generally, ignore inline styles. We add inline styles belonging to a\n\t\t\t// stylesheet later, which may or may not match the selectors.\n\t\t\tif ( ownerNode.tagName !== 'LINK' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Don't try to add the reset styles, which were removed as a dependency\n\t\t\t// from `edit-blocks` for the iframe since we don't need to reset admin\n\t\t\t// styles.\n\t\t\tif ( ownerNode.id === 'wp-reset-editor-styles-css' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfunction matchFromRules( _cssRules ) {\n\t\t\t\treturn Array.from( _cssRules ).find(\n\t\t\t\t\t( {\n\t\t\t\t\t\tselectorText,\n\t\t\t\t\t\tconditionText,\n\t\t\t\t\t\tcssRules: __cssRules,\n\t\t\t\t\t} ) => {\n\t\t\t\t\t\t// If the rule is conditional then it will not have selector text.\n\t\t\t\t\t\t// Recurse into child CSS ruleset to determine selector eligibility.\n\t\t\t\t\t\tif ( conditionText ) {\n\t\t\t\t\t\t\treturn matchFromRules( __cssRules );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\tselectorText &&\n\t\t\t\t\t\t\t( selectorText.includes(\n\t\t\t\t\t\t\t\t`.${ BODY_CLASS_NAME }`\n\t\t\t\t\t\t\t) ||\n\t\t\t\t\t\t\t\tselectorText.includes( `.${ BLOCK_PREFIX }` ) )\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst isMatch = matchFromRules( cssRules );\n\n\t\t\tif (\n\t\t\t\tisMatch &&\n\t\t\t\t! node.ownerDocument.getElementById( ownerNode.id )\n\t\t\t) {\n\t\t\t\t// Display warning once we have a way to add style dependencies to the editor.\n\t\t\t\t// See: https://github.com/WordPress/gutenberg/pull/37466.\n\t\t\t\tnode.appendChild( ownerNode.cloneNode( true ) );\n\n\t\t\t\t// Add inline styles belonging to the stylesheet.\n\t\t\t\tconst inlineCssId = ownerNode.id.replace(\n\t\t\t\t\t'-css',\n\t\t\t\t\t'-inline-css'\n\t\t\t\t);\n\t\t\t\tconst inlineCssElement = document.getElementById( inlineCssId );\n\n\t\t\t\tif ( inlineCssElement ) {\n\t\t\t\t\tnode.appendChild( inlineCssElement.cloneNode( true ) );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}, [] );\n}\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} doc Document to attach listeners to.\n */\nfunction bubbleEvents( doc ) {\n\tconst { defaultView } = doc;\n\tconst { frameElement } = defaultView;\n\n\tfunction bubbleEvent( event ) {\n\t\tconst prototype = Object.getPrototypeOf( event );\n\t\tconst constructorName = prototype.constructor.name;\n\t\tconst Constructor = window[ constructorName ];\n\n\t\tconst init = {};\n\n\t\tfor ( const key in event ) {\n\t\t\tinit[ key ] = event[ key ];\n\t\t}\n\n\t\tif ( event instanceof defaultView.MouseEvent ) {\n\t\t\tconst rect = frameElement.getBoundingClientRect();\n\t\t\tinit.clientX += rect.left;\n\t\t\tinit.clientY += rect.top;\n\t\t}\n\n\t\tconst newEvent = new Constructor( event.type, init );\n\t\tconst cancelled = ! frameElement.dispatchEvent( newEvent );\n\n\t\tif ( cancelled ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\tconst eventTypes = [ 'dragover' ];\n\n\tfor ( const name of eventTypes ) {\n\t\tdoc.addEventListener( name, bubbleEvent );\n\t}\n}\n\nfunction useParsedAssets( html ) {\n\treturn useMemo( () => {\n\t\tconst doc = document.implementation.createHTMLDocument( '' );\n\t\tdoc.body.innerHTML = html;\n\t\treturn Array.from( doc.body.children );\n\t}, [ html ] );\n}\n\nasync function loadScript( head, { id, src } ) {\n\treturn new Promise( ( resolve, reject ) => {\n\t\tconst script = head.ownerDocument.createElement( 'script' );\n\t\tscript.id = id;\n\t\tif ( src ) {\n\t\t\tscript.src = src;\n\t\t\tscript.onload = () => resolve();\n\t\t\tscript.onerror = () => reject();\n\t\t} else {\n\t\t\tresolve();\n\t\t}\n\t\thead.appendChild( script );\n\t} );\n}\n\nfunction Iframe(\n\t{\n\t\tcontentRef,\n\t\tchildren,\n\t\thead,\n\t\ttabIndex = 0,\n\t\tassets,\n\t\tscale = 1,\n\t\tframeSize = 0,\n\t\treadonly,\n\t\t...props\n\t},\n\tref\n) {\n\tconst [ , forceRender ] = useReducer( () => ( {} ) );\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst styles = useParsedAssets( assets?.styles );\n\tconst scripts = useParsedAssets( assets?.scripts );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\n\tconst setRef = useRefEffect( ( node ) => {\n\t\tlet iFrameDocument;\n\t\t// Prevent the default browser action for files dropped outside of dropzones.\n\t\tfunction preventFileDropDefault( event ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t\tfunction setDocumentIfReady() {\n\t\t\tconst { contentDocument, ownerDocument } = node;\n\t\t\tconst { readyState, documentElement } = contentDocument;\n\t\t\tiFrameDocument = contentDocument;\n\n\t\t\tif ( readyState !== 'interactive' && readyState !== 'complete' ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tbubbleEvents( contentDocument );\n\t\t\tsetIframeDocument( contentDocument );\n\t\t\tclearerRef( documentElement );\n\n\t\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t\t// the server in the future (which will run the PHP filters).\n\t\t\tsetBodyClasses(\n\t\t\t\tArray.from( ownerDocument.body.classList ).filter(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tname.startsWith( 'admin-color-' ) ||\n\t\t\t\t\t\tname.startsWith( 'post-type-' ) ||\n\t\t\t\t\t\tname === 'wp-embed-responsive'\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tcontentDocument.dir = ownerDocument.dir;\n\t\t\tdocumentElement.removeChild( contentDocument.head );\n\t\t\tdocumentElement.removeChild( contentDocument.body );\n\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t\treturn true;\n\t\t}\n\n\t\t// Document set with srcDoc is not immediately ready.\n\t\tnode.addEventListener( 'load', setDocumentIfReady );\n\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'load', setDocumentIfReady );\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\tconst headRef = useRefEffect( ( element ) => {\n\t\tscripts\n\t\t\t.reduce(\n\t\t\t\t( promise, script ) =>\n\t\t\t\t\tpromise.then( () => loadScript( element, script ) ),\n\t\t\t\tPromise.resolve()\n\t\t\t)\n\t\t\t.finally( () => {\n\t\t\t\t// When script are loaded, re-render blocks to allow them\n\t\t\t\t// to initialise.\n\t\t\t\tforceRender();\n\t\t\t} );\n\t}, [] );\n\tconst bodyRef = useMergeRefs( [ contentRef, clearerRef, writingFlowRef ] );\n\tconst styleCompatibilityRef = useStylesCompatibility();\n\n\thead = (\n\t\t<>\n\t\t\t<style>{ 'html{height:auto!important;}body{margin:0}' }</style>\n\t\t\t{ styles.map(\n\t\t\t\t( { tagName, href, id, rel, media, textContent } ) => {\n\t\t\t\t\tconst TagName = tagName.toLowerCase();\n\n\t\t\t\t\tif ( TagName === 'style' ) {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<TagName { ...{ id } } key={ id }>\n\t\t\t\t\t\t\t\t{ textContent }\n\t\t\t\t\t\t\t</TagName>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TagName { ...{ href, id, rel, media } } key={ id } />\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t) }\n\t\t\t{ head }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ tabIndex >= 0 && before }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t// Correct doctype is required to enable rendering in standards mode\n\t\t\t\tsrcDoc=\"<!doctype html>\"\n\t\t\t\ttitle={ __( 'Editor canvas' ) }\n\t\t\t>\n\t\t\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<head ref={ headRef }>\n\t\t\t\t\t\t\t\t{ head }\n\t\t\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t\t\t{ `html { transition: background 5s; ${\n\t\t\t\t\t\t\t\t\t\tframeSize\n\t\t\t\t\t\t\t\t\t\t\t? 'background: #2f2f2f; transition: background 0s;'\n\t\t\t\t\t\t\t\t\t\t\t: ''\n\t\t\t\t\t\t\t\t\t} }` }\n\t\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t\t</head>\n\t\t\t\t\t\t\t<body\n\t\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t'block-editor-iframe__body',\n\t\t\t\t\t\t\t\t\tBODY_CLASS_NAME,\n\t\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t// This is the remaining percentage from the scaling down\n\t\t\t\t\t\t\t\t\t// of the iframe body(`scale(0.45)`). We also need to subtract\n\t\t\t\t\t\t\t\t\t// the body's bottom margin.\n\t\t\t\t\t\t\t\t\tmarginBottom: `-${\n\t\t\t\t\t\t\t\t\t\tcontentHeight * ( 1 - scale ) -\n\t\t\t\t\t\t\t\t\t\tframeSize\n\t\t\t\t\t\t\t\t\t}px`,\n\t\t\t\t\t\t\t\t\tmarginTop: frameSize,\n\t\t\t\t\t\t\t\t\ttransform: `scale( ${ scale } )`,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tinert={ readonly ? 'true' : undefined }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ contentResizeListener }\n\t\t\t\t\t\t\t\t{ /*\n\t\t\t\t\t\t\t\t * This is a wrapper for the extra styles and scripts\n\t\t\t\t\t\t\t\t * rendered imperatively by cloning the parent,\n\t\t\t\t\t\t\t\t * it's important that this div's content remains uncontrolled.\n\t\t\t\t\t\t\t\t */ }\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tstyle={ { display: 'none' } }\n\t\t\t\t\t\t\t\t\tref={ styleCompatibilityRef }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t\t</body>\n\t\t\t\t\t\t</>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ tabIndex >= 0 && after }\n\t\t</>\n\t);\n}\n\nexport default forwardRef( Iframe );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"names":["classnames","useState","createPortal","forwardRef","useMemo","useReducer","__","useResizeObserver","useMergeRefs","useRefEffect","__experimentalStyleProvider","StyleProvider","useBlockSelectionClearer","useWritingFlow","useCompatibilityStyles","bubbleEvents","doc","defaultView","frameElement","bubbleEvent","event","prototype","Object","getPrototypeOf","constructorName","constructor","name","Constructor","window","init","key","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","cancelled","dispatchEvent","preventDefault","eventTypes","addEventListener","useParsedAssets","html","document","implementation","createHTMLDocument","body","innerHTML","Array","from","children","loadScript","head","id","src","Promise","resolve","reject","script","ownerDocument","createElement","onload","onerror","appendChild","Iframe","ref","contentRef","tabIndex","assets","scale","frameSize","readonly","props","forceRender","iframeDocument","setIframeDocument","bodyClasses","setBodyClasses","styles","styleIds","map","style","compatStyles","neededCompatStyles","filter","includes","scripts","clearerRef","before","writingFlowRef","after","contentResizeListener","height","contentHeight","setRef","node","iFrameDocument","preventFileDropDefault","setDocumentIfReady","contentDocument","readyState","documentElement","classList","startsWith","dir","removeChild","removeEventListener","headRef","element","reduce","promise","then","finally","bodyRef","tagName","href","rel","media","textContent","TagName","toLowerCase","marginBottom","marginTop","transform","undefined"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,QADD,EAECC,YAFD,EAGCC,UAHD,EAICC,OAJD,EAKCC,UALD,QAMO,oBANP;AAOA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,iBADD,EAECC,YAFD,EAGCC,YAHD,QAIO,oBAJP;AAKA,SAASC,2BAA2B,IAAIC,aAAxC,QAA6D,uBAA7D;AAEA;AACA;AACA;;AACA,SAASC,wBAAT,QAAyC,4BAAzC;AACA,SAASC,cAAT,QAA+B,iBAA/B;AACA,SAASC,sBAAT,QAAuC,4BAAvC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,YAAT,CAAuBC,GAAvB,EAA6B;AAC5B,QAAM;AAAEC,IAAAA;AAAF,MAAkBD,GAAxB;AACA,QAAM;AAAEE,IAAAA;AAAF,MAAmBD,WAAzB;;AAEA,WAASE,WAAT,CAAsBC,KAAtB,EAA8B;A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ACFkB,SAAS,GACN,iDADM,GAEN,EACH,IALF,CAFD,CADD,EAWC;AACC,IAAA,GAAG,EAAG2C,OADP;AAEC,IAAA,SAAS,EAAGrH,UAAU,CACrB,2BADqB,EAErB,uBAFqB,EAGrB,GAAGgF,WAHkB,CAFvB;AAOC,IAAA,KAAK,EAAG;AACP;AACA;AACA;AACA6C,MAAAA,YAAY,EAAG,IACd5B,aAAa,IAAK,IAAIxB,KAAT,CAAb,GACAC,SACA,IAPM;AAQPoD,MAAAA,SAAS,EAAEpD,SARJ;AASPqD,MAAAA,SAAS,EAAG,UAAUtD,KAAO;AATtB,KAPT;AAkBC,IAAA,KAAK,EAAGE,QAAQ,GAAG,MAAH,GAAYqD;AAlB7B,KAoBGjC,qBApBH,EAqBC,cAAC,aAAD;AAAe,IAAA,QAAQ,EAAGjB;AAA1B,KACGxB,QADH,CArBD,CAXD,CADW,EAsCXwB,cAAc,CAAC2B,eAtCJ,CATd,CAFD,EAoDGlC,QAAQ,IAAI,CAAZ,IAAiBuB,KApDpB,CADD;AAwDA;;AAED,eAAe3F,UAAU,CAAEiE,MAAF,CAAzB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseMemo,\n\tuseReducer,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseResizeObserver,\n\tuseMergeRefs,\n\tuseRefEffect,\n} from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useWritingFlow } from '../writing-flow';\nimport { useCompatibilityStyles } from './use-compatibility-styles';\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} doc Document to attach listeners to.\n */\nfunction bubbleEvents( doc ) {\n\tconst { defaultView } = doc;\n\tconst { frameElement } = defaultView;\n\n\tfunction bubbleEvent( event ) {\n\t\tconst prototype = Object.getPrototypeOf( event );\n\t\tconst constructorName = prototype.constructor.name;\n\t\tconst Constructor = window[ constructorName ];\n\n\t\tconst init = {};\n\n\t\tfor ( const key in event ) {\n\t\t\tinit[ key ] = event[ key ];\n\t\t}\n\n\t\tif ( event instanceof defaultView.MouseEvent ) {\n\t\t\tconst rect = frameElement.getBoundingClientRect();\n\t\t\tinit.clientX += rect.left;\n\t\t\tinit.clientY += rect.top;\n\t\t}\n\n\t\tconst newEvent = new Constructor( event.type, init );\n\t\tconst cancelled = ! frameElement.dispatchEvent( newEvent );\n\n\t\tif ( cancelled ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\tconst eventTypes = [ 'dragover' ];\n\n\tfor ( const name of eventTypes ) {\n\t\tdoc.addEventListener( name, bubbleEvent );\n\t}\n}\n\nfunction useParsedAssets( html ) {\n\treturn useMemo( () => {\n\t\tconst doc = document.implementation.createHTMLDocument( '' );\n\t\tdoc.body.innerHTML = html;\n\t\treturn Array.from( doc.body.children );\n\t}, [ html ] );\n}\n\nasync function loadScript( head, { id, src } ) {\n\treturn new Promise( ( resolve, reject ) => {\n\t\tconst script = head.ownerDocument.createElement( 'script' );\n\t\tscript.id = id;\n\t\tif ( src ) {\n\t\t\tscript.src = src;\n\t\t\tscript.onload = () => resolve();\n\t\t\tscript.onerror = () => reject();\n\t\t} else {\n\t\t\tresolve();\n\t\t}\n\t\thead.appendChild( script );\n\t} );\n}\n\nfunction Iframe(\n\t{\n\t\tcontentRef,\n\t\tchildren,\n\t\thead,\n\t\ttabIndex = 0,\n\t\tassets,\n\t\tscale = 1,\n\t\tframeSize = 0,\n\t\treadonly,\n\t\t...props\n\t},\n\tref\n) {\n\tconst [ , forceRender ] = useReducer( () => ( {} ) );\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst styles = useParsedAssets( assets?.styles );\n\tconst styleIds = styles.map( ( style ) => style.id );\n\tconst compatStyles = useCompatibilityStyles();\n\tconst neededCompatStyles = compatStyles.filter(\n\t\t( style ) => ! styleIds.includes( style.id )\n\t);\n\tconst scripts = useParsedAssets( assets?.scripts );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\n\tconst setRef = useRefEffect( ( node ) => {\n\t\tlet iFrameDocument;\n\t\t// Prevent the default browser action for files dropped outside of dropzones.\n\t\tfunction preventFileDropDefault( event ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t\tfunction setDocumentIfReady() {\n\t\t\tconst { contentDocument, ownerDocument } = node;\n\t\t\tconst { readyState, documentElement } = contentDocument;\n\t\t\tiFrameDocument = contentDocument;\n\n\t\t\tif ( readyState !== 'interactive' && readyState !== 'complete' ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tbubbleEvents( contentDocument );\n\t\t\tsetIframeDocument( contentDocument );\n\t\t\tclearerRef( documentElement );\n\n\t\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t\t// the server in the future (which will run the PHP filters).\n\t\t\tsetBodyClasses(\n\t\t\t\tArray.from( ownerDocument.body.classList ).filter(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tname.startsWith( 'admin-color-' ) ||\n\t\t\t\t\t\tname.startsWith( 'post-type-' ) ||\n\t\t\t\t\t\tname === 'wp-embed-responsive'\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tcontentDocument.dir = ownerDocument.dir;\n\t\t\tdocumentElement.removeChild( contentDocument.head );\n\t\t\tdocumentElement.removeChild( contentDocument.body );\n\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t\treturn true;\n\t\t}\n\n\t\t// Document set with srcDoc is not immediately ready.\n\t\tnode.addEventListener( 'load', setDocumentIfReady );\n\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'load', setDocumentIfReady );\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\tconst headRef = useRefEffect( ( element ) => {\n\t\tscripts\n\t\t\t.reduce(\n\t\t\t\t( promise, script ) =>\n\t\t\t\t\tpromise.then( () => loadScript( element, script ) ),\n\t\t\t\tPromise.resolve()\n\t\t\t)\n\t\t\t.finally( () => {\n\t\t\t\t// When script are loaded, re-render blocks to allow them\n\t\t\t\t// to initialise.\n\t\t\t\tforceRender();\n\t\t\t} );\n\t}, [] );\n\tconst bodyRef = useMergeRefs( [ contentRef, clearerRef, writingFlowRef ] );\n\n\thead = (\n\t\t<>\n\t\t\t<style>{ 'html{height:auto!important;}body{margin:0}' }</style>\n\t\t\t{ [ ...styles, ...neededCompatStyles ].map(\n\t\t\t\t( { tagName, href, id, rel, media, textContent } ) => {\n\t\t\t\t\tconst TagName = tagName.toLowerCase();\n\n\t\t\t\t\tif ( TagName === 'style' ) {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<TagName { ...{ id } } key={ id }>\n\t\t\t\t\t\t\t\t{ textContent }\n\t\t\t\t\t\t\t</TagName>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TagName { ...{ href, id, rel, media } } key={ id } />\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t) }\n\t\t\t{ head }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ tabIndex >= 0 && before }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t// Correct doctype is required to enable rendering in standards mode\n\t\t\t\tsrcDoc=\"<!doctype html>\"\n\t\t\t\ttitle={ __( 'Editor canvas' ) }\n\t\t\t>\n\t\t\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<head ref={ headRef }>\n\t\t\t\t\t\t\t\t{ head }\n\t\t\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t\t\t{ `html { transition: background 5s; ${\n\t\t\t\t\t\t\t\t\t\tframeSize\n\t\t\t\t\t\t\t\t\t\t\t? 'background: #2f2f2f; transition: background 0s;'\n\t\t\t\t\t\t\t\t\t\t\t: ''\n\t\t\t\t\t\t\t\t\t} }` }\n\t\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t\t</head>\n\t\t\t\t\t\t\t<body\n\t\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t'block-editor-iframe__body',\n\t\t\t\t\t\t\t\t\t'editor-styles-wrapper',\n\t\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t// This is the remaining percentage from the scaling down\n\t\t\t\t\t\t\t\t\t// of the iframe body(`scale(0.45)`). We also need to subtract\n\t\t\t\t\t\t\t\t\t// the body's bottom margin.\n\t\t\t\t\t\t\t\t\tmarginBottom: `-${\n\t\t\t\t\t\t\t\t\t\tcontentHeight * ( 1 - scale ) -\n\t\t\t\t\t\t\t\t\t\tframeSize\n\t\t\t\t\t\t\t\t\t}px`,\n\t\t\t\t\t\t\t\t\tmarginTop: frameSize,\n\t\t\t\t\t\t\t\t\ttransform: `scale( ${ scale } )`,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tinert={ readonly ? 'true' : undefined }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ contentResizeListener }\n\t\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t\t</body>\n\t\t\t\t\t\t</>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ tabIndex >= 0 && after }\n\t\t</>\n\t);\n}\n\nexport default forwardRef( Iframe );\n"]}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useMemo } from '@wordpress/element';
5
+ /**
6
+ * Returns a list of stylesheets that target the editor canvas. A stylesheet is
7
+ * considered targetting the editor a canvas if it contains the
8
+ * `editor-styles-wrapper`, `wp-block`, or `wp-block-*` class selectors.
9
+ *
10
+ * Ideally, this hook should be removed in the future and styles should be added
11
+ * explicitly as editor styles.
12
+ */
13
+
14
+ export function useCompatibilityStyles() {
15
+ // Only memoize the result once on load, since these stylesheets should not
16
+ // change.
17
+ return useMemo(() => {
18
+ // Search the document for stylesheets targetting the editor canvas.
19
+ return Array.from(document.styleSheets).reduce((accumulator, styleSheet) => {
20
+ try {
21
+ // May fail for external styles.
22
+ // eslint-disable-next-line no-unused-expressions
23
+ styleSheet.cssRules;
24
+ } catch (e) {
25
+ return accumulator;
26
+ }
27
+
28
+ const {
29
+ ownerNode,
30
+ cssRules
31
+ } = styleSheet;
32
+
33
+ if (!cssRules) {
34
+ return accumulator;
35
+ } // Generally, ignore inline styles. We add inline styles belonging to a
36
+ // stylesheet later, which may or may not match the selectors.
37
+
38
+
39
+ if (ownerNode.tagName !== 'LINK') {
40
+ return accumulator;
41
+ } // Don't try to add the reset styles, which were removed as a dependency
42
+ // from `edit-blocks` for the iframe since we don't need to reset admin
43
+ // styles.
44
+
45
+
46
+ if (ownerNode.id === 'wp-reset-editor-styles-css') {
47
+ return accumulator;
48
+ }
49
+
50
+ function matchFromRules(_cssRules) {
51
+ return Array.from(_cssRules).find(_ref => {
52
+ let {
53
+ selectorText,
54
+ conditionText,
55
+ cssRules: __cssRules
56
+ } = _ref;
57
+
58
+ // If the rule is conditional then it will not have selector text.
59
+ // Recurse into child CSS ruleset to determine selector eligibility.
60
+ if (conditionText) {
61
+ return matchFromRules(__cssRules);
62
+ }
63
+
64
+ return selectorText && (selectorText.includes('.editor-styles-wrapper') || selectorText.includes('.wp-block'));
65
+ });
66
+ }
67
+
68
+ if (matchFromRules(cssRules)) {
69
+ // Display warning once we have a way to add style dependencies to the editor.
70
+ // See: https://github.com/WordPress/gutenberg/pull/37466.
71
+ accumulator.push(ownerNode.cloneNode(true)); // Add inline styles belonging to the stylesheet.
72
+
73
+ const inlineCssId = ownerNode.id.replace('-css', '-inline-css');
74
+ const inlineCssElement = document.getElementById(inlineCssId);
75
+
76
+ if (inlineCssElement) {
77
+ accumulator.push(inlineCssElement.cloneNode(true));
78
+ }
79
+ }
80
+
81
+ return accumulator;
82
+ }, []);
83
+ }, []);
84
+ }
85
+ //# sourceMappingURL=use-compatibility-styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/iframe/use-compatibility-styles.js"],"names":["useMemo","useCompatibilityStyles","Array","from","document","styleSheets","reduce","accumulator","styleSheet","cssRules","e","ownerNode","tagName","id","matchFromRules","_cssRules","find","selectorText","conditionText","__cssRules","includes","push","cloneNode","inlineCssId","replace","inlineCssElement","getElementById"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,sBAAT,GAAkC;AACxC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B,EAEnB,aAFmB,CAApB;AAIA,cAAMC,gBAAgB,GACrBrB,QAAQ,CAACsB,cAAT,CAAyBH,WAAzB,CADD;;AAGA,YAAKE,gBAAL,EAAwB;AACvBlB,UAAAA,WAAW,CAACc,IAAZ,CAAkBI,gBAAgB,CAACH,SAAjB,CAA4B,IAA5B,CAAlB;AACA;AACD;;AAED,aAAOf,WAAP;AACA,KAxEK,EAyEN,EAzEM,CAAP;AA2EA,GA7Ea,EA6EX,EA7EW,CAAd;AA8EA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Returns a list of stylesheets that target the editor canvas. A stylesheet is\n * considered targetting the editor a canvas if it contains the\n * `editor-styles-wrapper`, `wp-block`, or `wp-block-*` class selectors.\n *\n * Ideally, this hook should be removed in the future and styles should be added\n * explicitly as editor styles.\n */\nexport function useCompatibilityStyles() {\n\t// Only memoize the result once on load, since these stylesheets should not\n\t// change.\n\treturn useMemo( () => {\n\t\t// Search the document for stylesheets targetting the editor canvas.\n\t\treturn Array.from( document.styleSheets ).reduce(\n\t\t\t( accumulator, styleSheet ) => {\n\t\t\t\ttry {\n\t\t\t\t\t// May fail for external styles.\n\t\t\t\t\t// eslint-disable-next-line no-unused-expressions\n\t\t\t\t\tstyleSheet.cssRules;\n\t\t\t\t} catch ( e ) {\n\t\t\t\t\treturn accumulator;\n\t\t\t\t}\n\n\t\t\t\tconst { ownerNode, cssRules } = styleSheet;\n\n\t\t\t\tif ( ! cssRules ) {\n\t\t\t\t\treturn accumulator;\n\t\t\t\t}\n\n\t\t\t\t// Generally, ignore inline styles. We add inline styles belonging to a\n\t\t\t\t// stylesheet later, which may or may not match the selectors.\n\t\t\t\tif ( ownerNode.tagName !== 'LINK' ) {\n\t\t\t\t\treturn accumulator;\n\t\t\t\t}\n\n\t\t\t\t// Don't try to add the reset styles, which were removed as a dependency\n\t\t\t\t// from `edit-blocks` for the iframe since we don't need to reset admin\n\t\t\t\t// styles.\n\t\t\t\tif ( ownerNode.id === 'wp-reset-editor-styles-css' ) {\n\t\t\t\t\treturn accumulator;\n\t\t\t\t}\n\n\t\t\t\tfunction matchFromRules( _cssRules ) {\n\t\t\t\t\treturn Array.from( _cssRules ).find(\n\t\t\t\t\t\t( {\n\t\t\t\t\t\t\tselectorText,\n\t\t\t\t\t\t\tconditionText,\n\t\t\t\t\t\t\tcssRules: __cssRules,\n\t\t\t\t\t\t} ) => {\n\t\t\t\t\t\t\t// If the rule is conditional then it will not have selector text.\n\t\t\t\t\t\t\t// Recurse into child CSS ruleset to determine selector eligibility.\n\t\t\t\t\t\t\tif ( conditionText ) {\n\t\t\t\t\t\t\t\treturn matchFromRules( __cssRules );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\tselectorText &&\n\t\t\t\t\t\t\t\t( selectorText.includes(\n\t\t\t\t\t\t\t\t\t'.editor-styles-wrapper'\n\t\t\t\t\t\t\t\t) ||\n\t\t\t\t\t\t\t\t\tselectorText.includes( '.wp-block' ) )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif ( matchFromRules( cssRules ) ) {\n\t\t\t\t\t// Display warning once we have a way to add style dependencies to the editor.\n\t\t\t\t\t// See: https://github.com/WordPress/gutenberg/pull/37466.\n\t\t\t\t\taccumulator.push( ownerNode.cloneNode( true ) );\n\n\t\t\t\t\t// Add inline styles belonging to the stylesheet.\n\t\t\t\t\tconst inlineCssId = ownerNode.id.replace(\n\t\t\t\t\t\t'-css',\n\t\t\t\t\t\t'-inline-css'\n\t\t\t\t\t);\n\t\t\t\t\tconst inlineCssElement =\n\t\t\t\t\t\tdocument.getElementById( inlineCssId );\n\n\t\t\t\t\tif ( inlineCssElement ) {\n\t\t\t\t\t\taccumulator.push( inlineCssElement.cloneNode( true ) );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t}, [] );\n}\n"]}
@@ -60,6 +60,8 @@ function UncontrolledInnerBlocks(props) {
60
60
  context,
61
61
  name
62
62
  } = useSelect(select => {
63
+ var _blockType$providesCo;
64
+
63
65
  const block = select(blockEditorStore).getBlock(clientId); // This check is here to avoid the Redux zombie bug where a child subscription
64
66
  // is called before a parent, causing potential JS errors when the child has been removed.
65
67
 
@@ -69,8 +71,10 @@ function UncontrolledInnerBlocks(props) {
69
71
 
70
72
  const blockType = getBlockType(block.name);
71
73
 
72
- if (!blockType || !blockType.providesContext) {
73
- return {};
74
+ if (Object.keys((_blockType$providesCo = blockType === null || blockType === void 0 ? void 0 : blockType.providesContext) !== null && _blockType$providesCo !== void 0 ? _blockType$providesCo : {}).length === 0) {
75
+ return {
76
+ name: block.name
77
+ };
74
78
  }
75
79
 
76
80
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/index.js"],"names":["classnames","useViewportMatch","useMergeRefs","forwardRef","useMemo","useSelect","getBlockSupport","getBlockType","store","blocksStore","__unstableGetInnerBlocksProps","getInnerBlocksProps","ButtonBlockAppender","DefaultBlockAppender","useNestedSettingsUpdate","useInnerBlockTemplateSync","getBlockContext","BlockListItems","BlockContextProvider","useBlockEditContext","useBlockSync","blockEditorStore","useBlockDropZone","UncontrolledInnerBlocks","props","clientId","allowedBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","template","templateLock","wrapperRef","templateInsertUpdatesSelection","__experimentalCaptureToolbars","captureToolbars","__experimentalAppenderTagName","renderAppender","orientation","placeholder","__experimentalLayout","context","name","select","block","getBlock","blockType","providesContext","attributes","allowSizingOnChildren","layout","ControlledInnerBlocks","ForwardedInnerBlocks","ref","innerBlocksProps","useInnerBlocksProps","options","__unstableDisableLayoutClassNames","__unstableDisableDropZone","__unstableLayoutClassNames","layoutClassNames","isSmallScreen","hasOverlay","getBlockName","isBlockSelected","hasSelectedInnerBlock","__unstableGetEditorMode","blockName","enableClickThrough","hasBlockSupport","blockDropZoneRef","rootClientId","InnerBlocks","value","onChange","className","children","save","Content"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,EAA2BC,YAA3B,QAA+C,oBAA/C;AACA,SAASC,UAAT,EAAqBC,OAArB,QAAoC,oBAApC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,eADD,EAECC,YAFD,EAGCC,KAAK,IAAIC,WAHV,EAICC,6BAA6B,IAAIC,mBAJlC,QAKO,mBALP;AAOA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,OAAOC,yBAAP,MAAsC,iCAAtC;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,SAASC,cAAT,QAA+B,eAA/B;AACA,SAASC,oBAAT,QAAqC,kBAArC;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,OAAOC,YAAP,MAAyB,4BAAzB;AACA,SAASZ,KAAK,IAAIa,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,gBAAP,MAA6B,wBAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,uBAAT,CAAkCC,KAAlC,EAA0C;AACzC,QAAM;AACLC,IAAAA,QADK;AAELC,IAAAA,aAFK;AAGLC,IAAAA,0BAHK;AAILC,IAAAA,0BAJK;AAKLC,IAAAA,QALK;AAMLC,IAAAA,YANK;AAOLC,IAAAA,UAPK;AAQLC,IAAAA,8BARK;AASLC,IAAAA,6BAA6B,EAAEC,eAT1B;AAULC,IAAAA,6BAVK;AAWLC,IAAAA,cAXK;AAYLC,IAAAA,WAZK;AAaLC,IAAAA,WAbK;AAcLC,IAAAA;AAdK,MAeFf,KAfJ;AAiBAV,EAAAA,uBAAuB,CACtBW,QADsB,EAEtBC,aAFsB,EAGtBC,0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D,QAAQ,GACjB,cAAC,WAAD,eAAkB4B,gBAAlB;AAAqC,MAAA,QAAQ,EAAG5B;AAAhD,OADiB,GAGjB,cAAC,cAAD,EAAqB8B,OAArB;AAdK,GAAP;AAiBA;AAEDD,mBAAmB,CAACsB,IAApB,GAA2BjE,mBAA3B,C,CAEA;;AACAwC,oBAAoB,CAACtC,oBAArB,GAA4CA,oBAA5C;AACAsC,oBAAoB,CAACvC,mBAArB,GAA2CA,mBAA3C;;AAEAuC,oBAAoB,CAAC0B,OAArB,GAA+B,MAAMvB,mBAAmB,CAACsB,IAApB,GAA2BD,QAAhE;AAEA;AACA;AACA;;;AACA,eAAexB,oBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch, useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tgetBlockSupport,\n\tgetBlockType,\n\tstore as blocksStore,\n\t__unstableGetInnerBlocksProps as getInnerBlocksProps,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport ButtonBlockAppender from './button-block-appender';\nimport DefaultBlockAppender from './default-block-appender';\nimport useNestedSettingsUpdate from './use-nested-settings-update';\nimport useInnerBlockTemplateSync from './use-inner-block-template-sync';\nimport getBlockContext from './get-block-context';\nimport { BlockListItems } from '../block-list';\nimport { BlockContextProvider } from '../block-context';\nimport { useBlockEditContext } from '../block-edit/context';\nimport useBlockSync from '../provider/use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDropZone from '../use-block-drop-zone';\n\n/**\n * InnerBlocks is a component which allows a single block to have multiple blocks\n * as children. The UncontrolledInnerBlocks component is used whenever the inner\n * blocks are not controlled by another entity. In other words, it is normally\n * used for inner blocks in the post editor\n *\n * @param {Object} props The component props.\n */\nfunction UncontrolledInnerBlocks( props ) {\n\tconst {\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\twrapperRef,\n\t\ttemplateInsertUpdatesSelection,\n\t\t__experimentalCaptureToolbars: captureToolbars,\n\t\t__experimentalAppenderTagName,\n\t\trenderAppender,\n\t\torientation,\n\t\tplaceholder,\n\t\t__experimentalLayout,\n\t} = props;\n\n\tuseNestedSettingsUpdate(\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\t__experimentalLayout\n\t);\n\n\tuseInnerBlockTemplateSync(\n\t\tclientId,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection\n\t);\n\n\tconst { context, name } = useSelect(\n\t\t( select ) => {\n\t\t\tconst block = select( blockEditorStore ).getBlock( clientId );\n\n\t\t\t// This check is here to avoid the Redux zombie bug where a child subscription\n\t\t\t// is called before a parent, causing potential JS errors when the child has been removed.\n\t\t\tif ( ! block ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst blockType = getBlockType( block.name );\n\n\t\t\tif ( ! blockType || ! blockType.providesContext ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcontext: getBlockContext( block.attributes, blockType ),\n\t\t\t\tname: block.name,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { allowSizingOnChildren = false } =\n\t\tgetBlockSupport( name, '__experimentalLayout' ) || {};\n\n\tconst layout = useMemo(\n\t\t() => ( {\n\t\t\t...__experimentalLayout,\n\t\t\t...( allowSizingOnChildren && {\n\t\t\t\tallowSizingOnChildren: true,\n\t\t\t} ),\n\t\t} ),\n\t\t[ __experimentalLayout, allowSizingOnChildren ]\n\t);\n\n\t// This component needs to always be synchronous as it's the one changing\n\t// the async mode depending on the block selection.\n\treturn (\n\t\t<BlockContextProvider value={ context }>\n\t\t\t<BlockListItems\n\t\t\t\trootClientId={ clientId }\n\t\t\t\trenderAppender={ renderAppender }\n\t\t\t\t__experimentalAppenderTagName={ __experimentalAppenderTagName }\n\t\t\t\t__experimentalLayout={ layout }\n\t\t\t\twrapperRef={ wrapperRef }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t/>\n\t\t</BlockContextProvider>\n\t);\n}\n\n/**\n * The controlled inner blocks component wraps the uncontrolled inner blocks\n * component with the blockSync hook. This keeps the innerBlocks of the block in\n * the block-editor store in sync with the blocks of the controlling entity. An\n * example of an inner block controller is a template part block, which provides\n * its own blocks from the template part entity data source.\n *\n * @param {Object} props The component props.\n */\nfunction ControlledInnerBlocks( props ) {\n\tuseBlockSync( props );\n\treturn <UncontrolledInnerBlocks { ...props } />;\n}\n\nconst ForwardedInnerBlocks = forwardRef( ( props, ref ) => {\n\tconst innerBlocksProps = useInnerBlocksProps( { ref }, props );\n\treturn (\n\t\t<div className=\"block-editor-inner-blocks\">\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n} );\n\n/**\n * This hook is used to lightly mark an element as an inner blocks wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * an inner blocks wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Optional. Inner blocks options.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport function useInnerBlocksProps( props = {}, options = {} ) {\n\tconst { __unstableDisableLayoutClassNames, __unstableDisableDropZone } =\n\t\toptions;\n\tconst { clientId, __unstableLayoutClassNames: layoutClassNames = '' } =\n\t\tuseBlockEditContext();\n\tconst isSmallScreen = useViewportMatch( 'medium', '<' );\n\tconst { __experimentalCaptureToolbars, hasOverlay } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tisBlockSelected,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst enableClickThrough =\n\t\t\t\t__unstableGetEditorMode() === 'navigation' || isSmallScreen;\n\t\t\treturn {\n\t\t\t\t__experimentalCaptureToolbars: select(\n\t\t\t\t\tblocksStore\n\t\t\t\t).hasBlockSupport(\n\t\t\t\t\tblockName,\n\t\t\t\t\t'__experimentalExposeControlsToChildren',\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasOverlay:\n\t\t\t\t\tblockName !== 'core/template' &&\n\t\t\t\t\t! isBlockSelected( clientId ) &&\n\t\t\t\t\t! hasSelectedInnerBlock( clientId, true ) &&\n\t\t\t\t\tenableClickThrough,\n\t\t\t};\n\t\t},\n\t\t[ clientId, isSmallScreen ]\n\t);\n\n\tconst blockDropZoneRef = useBlockDropZone( {\n\t\trootClientId: clientId,\n\t} );\n\n\tconst ref = useMergeRefs( [\n\t\tprops.ref,\n\t\t__unstableDisableDropZone ? null : blockDropZoneRef,\n\t] );\n\n\tconst innerBlocksProps = {\n\t\t__experimentalCaptureToolbars,\n\t\t...options,\n\t};\n\tconst InnerBlocks =\n\t\tinnerBlocksProps.value && innerBlocksProps.onChange\n\t\t\t? ControlledInnerBlocks\n\t\t\t: UncontrolledInnerBlocks;\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: classnames(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-list__layout',\n\t\t\t__unstableDisableLayoutClassNames ? '' : layoutClassNames,\n\t\t\t{\n\t\t\t\t'has-overlay': hasOverlay,\n\t\t\t}\n\t\t),\n\t\tchildren: clientId ? (\n\t\t\t<InnerBlocks { ...innerBlocksProps } clientId={ clientId } />\n\t\t) : (\n\t\t\t<BlockListItems { ...options } />\n\t\t),\n\t};\n}\n\nuseInnerBlocksProps.save = getInnerBlocksProps;\n\n// Expose default appender placeholders as components.\nForwardedInnerBlocks.DefaultBlockAppender = DefaultBlockAppender;\nForwardedInnerBlocks.ButtonBlockAppender = ButtonBlockAppender;\n\nForwardedInnerBlocks.Content = () => useInnerBlocksProps.save().children;\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport default ForwardedInnerBlocks;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/index.js"],"names":["classnames","useViewportMatch","useMergeRefs","forwardRef","useMemo","useSelect","getBlockSupport","getBlockType","store","blocksStore","__unstableGetInnerBlocksProps","getInnerBlocksProps","ButtonBlockAppender","DefaultBlockAppender","useNestedSettingsUpdate","useInnerBlockTemplateSync","getBlockContext","BlockListItems","BlockContextProvider","useBlockEditContext","useBlockSync","blockEditorStore","useBlockDropZone","UncontrolledInnerBlocks","props","clientId","allowedBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","template","templateLock","wrapperRef","templateInsertUpdatesSelection","__experimentalCaptureToolbars","captureToolbars","__experimentalAppenderTagName","renderAppender","orientation","placeholder","__experimentalLayout","context","name","select","block","getBlock","blockType","Object","keys","providesContext","length","attributes","allowSizingOnChildren","layout","ControlledInnerBlocks","ForwardedInnerBlocks","ref","innerBlocksProps","useInnerBlocksProps","options","__unstableDisableLayoutClassNames","__unstableDisableDropZone","__unstableLayoutClassNames","layoutClassNames","isSmallScreen","hasOverlay","getBlockName","isBlockSelected","hasSelectedInnerBlock","__unstableGetEditorMode","blockName","enableClickThrough","hasBlockSupport","blockDropZoneRef","rootClientId","InnerBlocks","value","onChange","className","children","save","Content"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,EAA2BC,YAA3B,QAA+C,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,MAAA,QAAQ,EAAG/B;AAAhD,OADiB,GAGjB,cAAC,cAAD,EAAqBiC,OAArB;AAdK,GAAP;AAiBA;AAEDD,mBAAmB,CAACsB,IAApB,GAA2BpE,mBAA3B,C,CAEA;;AACA2C,oBAAoB,CAACzC,oBAArB,GAA4CA,oBAA5C;AACAyC,oBAAoB,CAAC1C,mBAArB,GAA2CA,mBAA3C;;AAEA0C,oBAAoB,CAAC0B,OAArB,GAA+B,MAAMvB,mBAAmB,CAACsB,IAApB,GAA2BD,QAAhE;AAEA;AACA;AACA;;;AACA,eAAexB,oBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch, useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tgetBlockSupport,\n\tgetBlockType,\n\tstore as blocksStore,\n\t__unstableGetInnerBlocksProps as getInnerBlocksProps,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport ButtonBlockAppender from './button-block-appender';\nimport DefaultBlockAppender from './default-block-appender';\nimport useNestedSettingsUpdate from './use-nested-settings-update';\nimport useInnerBlockTemplateSync from './use-inner-block-template-sync';\nimport getBlockContext from './get-block-context';\nimport { BlockListItems } from '../block-list';\nimport { BlockContextProvider } from '../block-context';\nimport { useBlockEditContext } from '../block-edit/context';\nimport useBlockSync from '../provider/use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDropZone from '../use-block-drop-zone';\n\n/**\n * InnerBlocks is a component which allows a single block to have multiple blocks\n * as children. The UncontrolledInnerBlocks component is used whenever the inner\n * blocks are not controlled by another entity. In other words, it is normally\n * used for inner blocks in the post editor\n *\n * @param {Object} props The component props.\n */\nfunction UncontrolledInnerBlocks( props ) {\n\tconst {\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\twrapperRef,\n\t\ttemplateInsertUpdatesSelection,\n\t\t__experimentalCaptureToolbars: captureToolbars,\n\t\t__experimentalAppenderTagName,\n\t\trenderAppender,\n\t\torientation,\n\t\tplaceholder,\n\t\t__experimentalLayout,\n\t} = props;\n\n\tuseNestedSettingsUpdate(\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\t__experimentalLayout\n\t);\n\n\tuseInnerBlockTemplateSync(\n\t\tclientId,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection\n\t);\n\n\tconst { context, name } = useSelect(\n\t\t( select ) => {\n\t\t\tconst block = select( blockEditorStore ).getBlock( clientId );\n\n\t\t\t// This check is here to avoid the Redux zombie bug where a child subscription\n\t\t\t// is called before a parent, causing potential JS errors when the child has been removed.\n\t\t\tif ( ! block ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst blockType = getBlockType( block.name );\n\n\t\t\tif (\n\t\t\t\tObject.keys( blockType?.providesContext ?? {} ).length === 0\n\t\t\t) {\n\t\t\t\treturn { name: block.name };\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcontext: getBlockContext( block.attributes, blockType ),\n\t\t\t\tname: block.name,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { allowSizingOnChildren = false } =\n\t\tgetBlockSupport( name, '__experimentalLayout' ) || {};\n\n\tconst layout = useMemo(\n\t\t() => ( {\n\t\t\t...__experimentalLayout,\n\t\t\t...( allowSizingOnChildren && {\n\t\t\t\tallowSizingOnChildren: true,\n\t\t\t} ),\n\t\t} ),\n\t\t[ __experimentalLayout, allowSizingOnChildren ]\n\t);\n\n\t// This component needs to always be synchronous as it's the one changing\n\t// the async mode depending on the block selection.\n\treturn (\n\t\t<BlockContextProvider value={ context }>\n\t\t\t<BlockListItems\n\t\t\t\trootClientId={ clientId }\n\t\t\t\trenderAppender={ renderAppender }\n\t\t\t\t__experimentalAppenderTagName={ __experimentalAppenderTagName }\n\t\t\t\t__experimentalLayout={ layout }\n\t\t\t\twrapperRef={ wrapperRef }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t/>\n\t\t</BlockContextProvider>\n\t);\n}\n\n/**\n * The controlled inner blocks component wraps the uncontrolled inner blocks\n * component with the blockSync hook. This keeps the innerBlocks of the block in\n * the block-editor store in sync with the blocks of the controlling entity. An\n * example of an inner block controller is a template part block, which provides\n * its own blocks from the template part entity data source.\n *\n * @param {Object} props The component props.\n */\nfunction ControlledInnerBlocks( props ) {\n\tuseBlockSync( props );\n\treturn <UncontrolledInnerBlocks { ...props } />;\n}\n\nconst ForwardedInnerBlocks = forwardRef( ( props, ref ) => {\n\tconst innerBlocksProps = useInnerBlocksProps( { ref }, props );\n\treturn (\n\t\t<div className=\"block-editor-inner-blocks\">\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n} );\n\n/**\n * This hook is used to lightly mark an element as an inner blocks wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * an inner blocks wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Optional. Inner blocks options.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport function useInnerBlocksProps( props = {}, options = {} ) {\n\tconst { __unstableDisableLayoutClassNames, __unstableDisableDropZone } =\n\t\toptions;\n\tconst { clientId, __unstableLayoutClassNames: layoutClassNames = '' } =\n\t\tuseBlockEditContext();\n\tconst isSmallScreen = useViewportMatch( 'medium', '<' );\n\tconst { __experimentalCaptureToolbars, hasOverlay } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tisBlockSelected,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst enableClickThrough =\n\t\t\t\t__unstableGetEditorMode() === 'navigation' || isSmallScreen;\n\t\t\treturn {\n\t\t\t\t__experimentalCaptureToolbars: select(\n\t\t\t\t\tblocksStore\n\t\t\t\t).hasBlockSupport(\n\t\t\t\t\tblockName,\n\t\t\t\t\t'__experimentalExposeControlsToChildren',\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasOverlay:\n\t\t\t\t\tblockName !== 'core/template' &&\n\t\t\t\t\t! isBlockSelected( clientId ) &&\n\t\t\t\t\t! hasSelectedInnerBlock( clientId, true ) &&\n\t\t\t\t\tenableClickThrough,\n\t\t\t};\n\t\t},\n\t\t[ clientId, isSmallScreen ]\n\t);\n\n\tconst blockDropZoneRef = useBlockDropZone( {\n\t\trootClientId: clientId,\n\t} );\n\n\tconst ref = useMergeRefs( [\n\t\tprops.ref,\n\t\t__unstableDisableDropZone ? null : blockDropZoneRef,\n\t] );\n\n\tconst innerBlocksProps = {\n\t\t__experimentalCaptureToolbars,\n\t\t...options,\n\t};\n\tconst InnerBlocks =\n\t\tinnerBlocksProps.value && innerBlocksProps.onChange\n\t\t\t? ControlledInnerBlocks\n\t\t\t: UncontrolledInnerBlocks;\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: classnames(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-list__layout',\n\t\t\t__unstableDisableLayoutClassNames ? '' : layoutClassNames,\n\t\t\t{\n\t\t\t\t'has-overlay': hasOverlay,\n\t\t\t}\n\t\t),\n\t\tchildren: clientId ? (\n\t\t\t<InnerBlocks { ...innerBlocksProps } clientId={ clientId } />\n\t\t) : (\n\t\t\t<BlockListItems { ...options } />\n\t\t),\n\t};\n}\n\nuseInnerBlocksProps.save = getInnerBlocksProps;\n\n// Expose default appender placeholders as components.\nForwardedInnerBlocks.DefaultBlockAppender = DefaultBlockAppender;\nForwardedInnerBlocks.ButtonBlockAppender = ButtonBlockAppender;\n\nForwardedInnerBlocks.Content = () => useInnerBlocksProps.save().children;\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport default ForwardedInnerBlocks;\n"]}
@@ -39,7 +39,8 @@ function useInsertionPoint(_ref) {
39
39
  clientId,
40
40
  isAppender,
41
41
  onSelect,
42
- shouldFocusBlock = true
42
+ shouldFocusBlock = true,
43
+ selectBlockOnInsert = true
43
44
  } = _ref;
44
45
  const {
45
46
  getSelectedBlock
@@ -91,7 +92,7 @@ function useInsertionPoint(_ref) {
91
92
  if (!isAppender && selectedBlock && isUnmodifiedDefaultBlock(selectedBlock)) {
92
93
  replaceBlocks(selectedBlock.clientId, blocks, null, shouldFocusBlock || shouldForceFocusBlock ? 0 : null, meta);
93
94
  } else {
94
- insertBlocks(blocks, destinationIndex, destinationRootClientId, true, shouldFocusBlock || shouldForceFocusBlock ? 0 : null, meta);
95
+ insertBlocks(blocks, destinationIndex, destinationRootClientId, selectBlockOnInsert, shouldFocusBlock || shouldForceFocusBlock ? 0 : null, meta);
95
96
  }
96
97
 
97
98
  const blockLength = Array.isArray(blocks) ? blocks.length : 1;
@@ -100,7 +101,7 @@ function useInsertionPoint(_ref) {
100
101
  speak(message);
101
102
 
102
103
  if (onSelect) {
103
- onSelect();
104
+ onSelect(blocks);
104
105
  }
105
106
  }, [isAppender, getSelectedBlock, replaceBlocks, insertBlocks, destinationRootClientId, destinationIndex, onSelect, shouldFocusBlock]);
106
107
  const onToggleInsertionPoint = useCallback(show => {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-insertion-point.js"],"names":["useDispatch","useSelect","isUnmodifiedDefaultBlock","_n","sprintf","speak","useCallback","store","blockEditorStore","useInsertionPoint","rootClientId","insertionIndex","clientId","isAppender","onSelect","shouldFocusBlock","getSelectedBlock","destinationRootClientId","destinationIndex","select","getSelectedBlockClientId","getBlockRootClientId","getBlockIndex","getBlockOrder","selectedBlockClientId","_destinationRootClientId","_destinationIndex","undefined","length","replaceBlocks","insertBlocks","showInsertionPoint","hideInsertionPoint","onInsertBlocks","blocks","meta","shouldForceFocusBlock","selectedBlock","blockLength","Array","isArray","message","onToggleInsertionPoint","show"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,wBAAT,QAAyC,mBAAzC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SAASC,WAAT,QAA4B,oBAA5B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,gBAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,iBAAT,OAOI;AAAA,MAPwB;AAC3BC,IAAAA,YAAY,GAAG,EADY;AAE3BC,IAAAA,cAF2B;AAG3BC,IAAAA,QAH2B;AAI3BC,IAAAA,UAJ2B;AAK3BC,IAAAA,QAL2B;AAM3BC,IAAAA,gBAAgB,GAAG;AANQ,GAOxB;AACH,QAAM;AAAEC,IAAAA;AAAF,MAAuBf,SAAS,CAAEO,gBAAF,CAAtC;AACA,QAAM;AAAES,IAAAA,uBAAF;AAA2BC,IAAAA;AAA3B,MAAgDjB,SAAS,CAC5DkB,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,wBADK;AAELC,MAAAA,oBAFK;AAGLC,MAAAA,aAHK;AAILC,MAAAA;AAJK,QAKFJ,MAAM,CAAEX,gBAAF,CALV;AAMA,UAAMgB,qBA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A5C,GAAgD,IAJpC,EAKZD,IALY,CAAb;AAOA,KAZD,MAYO;AACNL,MAAAA,YAAY,CACXI,MADW,EAEXhB,gBAFW,EAGXD,uBAHW,EAIX,IAJW,EAKXF,gBAAgB,IAAIqB,qBAApB,GAA4C,CAA5C,GAAgD,IALrC,EAMXD,IANW,CAAZ;AAQA;;AACD,UAAMG,WAAW,GAAGC,KAAK,CAACC,OAAN,CAAeN,MAAf,IAA0BA,MAAM,CAACN,MAAjC,GAA0C,CAA9D;AACA,UAAMa,OAAO,GAAGrC,OAAO,EACtB;AACAD,IAAAA,EAAE,CAAE,iBAAF,EAAqB,kBAArB,EAAyCmC,WAAzC,CAFoB,EAGtBA,WAHsB,CAAvB;AAKAjC,IAAAA,KAAK,CAAEoC,OAAF,CAAL;;AAEA,QAAK3B,QAAL,EAAgB;AACfA,MAAAA,QAAQ;AACR;AACD,GArCgC,EAsCjC,CACCD,UADD,EAECG,gBAFD,EAGCa,aAHD,EAICC,YAJD,EAKCb,uBALD,EAMCC,gBAND,EAOCJ,QAPD,EAQCC,gBARD,CAtCiC,CAAlC;AAkDA,QAAM2B,sBAAsB,GAAGpC,WAAW,CACvCqC,IAAF,IAAY;AACX,QAAKA,IAAL,EAAY;AACXZ,MAAAA,kBAAkB,CAAEd,uBAAF,EAA2BC,gBAA3B,CAAlB;AACA,KAFD,MAEO;AACNc,MAAAA,kBAAkB;AAClB;AACD,GAPwC,EAQzC,CACCD,kBADD,EAECC,kBAFD,EAGCf,uBAHD,EAICC,gBAJD,CARyC,CAA1C;AAgBA,SAAO,CAAED,uBAAF,EAA2BgB,cAA3B,EAA2CS,sBAA3C,CAAP;AACA;;AAED,eAAejC,iBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\n\n/**\n * @typedef WPInserterConfig\n *\n * @property {string=} rootClientId If set, insertion will be into the\n * block with this ID.\n * @property {number=} insertionIndex If set, insertion will be into this\n * explicit position.\n * @property {string=} clientId If set, insertion will be after the\n * block with this ID.\n * @property {boolean=} isAppender Whether the inserter is an appender\n * or not.\n * @property {Function=} onSelect Called after insertion.\n */\n\n/**\n * Returns the insertion point state given the inserter config.\n *\n * @param {WPInserterConfig} config Inserter Config.\n * @return {Array} Insertion Point State (rootClientID, onInsertBlocks and onToggle).\n */\nfunction useInsertionPoint( {\n\trootClientId = '',\n\tinsertionIndex,\n\tclientId,\n\tisAppender,\n\tonSelect,\n\tshouldFocusBlock = true,\n} ) {\n\tconst { getSelectedBlock } = useSelect( blockEditorStore );\n\tconst { destinationRootClientId, destinationIndex } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockIndex,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\n\t\t\tlet _destinationRootClientId = rootClientId;\n\t\t\tlet _destinationIndex;\n\n\t\t\tif ( insertionIndex !== undefined ) {\n\t\t\t\t// Insert into a specific index.\n\t\t\t\t_destinationIndex = insertionIndex;\n\t\t\t} else if ( clientId ) {\n\t\t\t\t// Insert after a specific client ID.\n\t\t\t\t_destinationIndex = getBlockIndex( clientId );\n\t\t\t} else if ( ! isAppender && selectedBlockClientId ) {\n\t\t\t\t_destinationRootClientId = getBlockRootClientId(\n\t\t\t\t\tselectedBlockClientId\n\t\t\t\t);\n\t\t\t\t_destinationIndex = getBlockIndex( selectedBlockClientId ) + 1;\n\t\t\t} else {\n\t\t\t\t// Insert at the end of the list.\n\t\t\t\t_destinationIndex = getBlockOrder(\n\t\t\t\t\t_destinationRootClientId\n\t\t\t\t).length;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tdestinationRootClientId: _destinationRootClientId,\n\t\t\t\tdestinationIndex: _destinationIndex,\n\t\t\t};\n\t\t},\n\t\t[ rootClientId, insertionIndex, clientId, isAppender ]\n\t);\n\n\tconst {\n\t\treplaceBlocks,\n\t\tinsertBlocks,\n\t\tshowInsertionPoint,\n\t\thideInsertionPoint,\n\t} = useDispatch( blockEditorStore );\n\n\tconst onInsertBlocks = useCallback(\n\t\t( blocks, meta, shouldForceFocusBlock = false ) => {\n\t\t\tconst selectedBlock = getSelectedBlock();\n\n\t\t\tif (\n\t\t\t\t! isAppender &&\n\t\t\t\tselectedBlock &&\n\t\t\t\tisUnmodifiedDefaultBlock( selectedBlock )\n\t\t\t) {\n\t\t\t\treplaceBlocks(\n\t\t\t\t\tselectedBlock.clientId,\n\t\t\t\t\tblocks,\n\t\t\t\t\tnull,\n\t\t\t\t\tshouldFocusBlock || shouldForceFocusBlock ? 0 : null,\n\t\t\t\t\tmeta\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tinsertBlocks(\n\t\t\t\t\tblocks,\n\t\t\t\t\tdestinationIndex,\n\t\t\t\t\tdestinationRootClientId,\n\t\t\t\t\ttrue,\n\t\t\t\t\tshouldFocusBlock || shouldForceFocusBlock ? 0 : null,\n\t\t\t\t\tmeta\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst blockLength = Array.isArray( blocks ) ? blocks.length : 1;\n\t\t\tconst message = sprintf(\n\t\t\t\t// translators: %d: the name of the block that has been added\n\t\t\t\t_n( '%d block added.', '%d blocks added.', blockLength ),\n\t\t\t\tblockLength\n\t\t\t);\n\t\t\tspeak( message );\n\n\t\t\tif ( onSelect ) {\n\t\t\t\tonSelect();\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tisAppender,\n\t\t\tgetSelectedBlock,\n\t\t\treplaceBlocks,\n\t\t\tinsertBlocks,\n\t\t\tdestinationRootClientId,\n\t\t\tdestinationIndex,\n\t\t\tonSelect,\n\t\t\tshouldFocusBlock,\n\t\t]\n\t);\n\n\tconst onToggleInsertionPoint = useCallback(\n\t\t( show ) => {\n\t\t\tif ( show ) {\n\t\t\t\tshowInsertionPoint( destinationRootClientId, destinationIndex );\n\t\t\t} else {\n\t\t\t\thideInsertionPoint();\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tshowInsertionPoint,\n\t\t\thideInsertionPoint,\n\t\t\tdestinationRootClientId,\n\t\t\tdestinationIndex,\n\t\t]\n\t);\n\n\treturn [ destinationRootClientId, onInsertBlocks, onToggleInsertionPoint ];\n}\n\nexport default useInsertionPoint;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-insertion-point.js"],"names":["useDispatch","useSelect","isUnmodifiedDefaultBlock","_n","sprintf","speak","useCallback","store","blockEditorStore","useInsertionPoint","rootClientId","insertionIndex","clientId","isAppender","onSelect","shouldFocusBlock","selectBlockOnInsert","getSelectedBlock","destinationRootClientId","destinationIndex","select","getSelectedBlockClientId","getBlockRootClientId","getBlockIndex","getBlockOrder","selectedBlockClientId","_destinationRootClientId","_destinationIndex","undefined","length","replaceBlocks","insertBlocks","showInsertionPoint","hideInsertionPoint","onInsertBlocks","blocks","meta","shouldForceFocusBlock","selectedBlock","blockLength","Array","isArray","message","onToggleInsertionPoint","show"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,wBAAT,QAAyC,mBAAzC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SAASC,WAAT,QAA4B,oBAA5B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,gBAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,iBAAT,OAQI;AAAA,MARwB;AAC3B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B,GAAGrC,WAAW,CACvCsC,IAAF,IAAY;AACX,QAAKA,IAAL,EAAY;AACXZ,MAAAA,kBAAkB,CAAEd,uBAAF,EAA2BC,gBAA3B,CAAlB;AACA,KAFD,MAEO;AACNc,MAAAA,kBAAkB;AAClB;AACD,GAPwC,EAQzC,CACCD,kBADD,EAECC,kBAFD,EAGCf,uBAHD,EAICC,gBAJD,CARyC,CAA1C;AAgBA,SAAO,CAAED,uBAAF,EAA2BgB,cAA3B,EAA2CS,sBAA3C,CAAP;AACA;;AAED,eAAelC,iBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\n\n/**\n * @typedef WPInserterConfig\n *\n * @property {string=} rootClientId If set, insertion will be into the\n * block with this ID.\n * @property {number=} insertionIndex If set, insertion will be into this\n * explicit position.\n * @property {string=} clientId If set, insertion will be after the\n * block with this ID.\n * @property {boolean=} isAppender Whether the inserter is an appender\n * or not.\n * @property {Function=} onSelect Called after insertion.\n */\n\n/**\n * Returns the insertion point state given the inserter config.\n *\n * @param {WPInserterConfig} config Inserter Config.\n * @return {Array} Insertion Point State (rootClientID, onInsertBlocks and onToggle).\n */\nfunction useInsertionPoint( {\n\trootClientId = '',\n\tinsertionIndex,\n\tclientId,\n\tisAppender,\n\tonSelect,\n\tshouldFocusBlock = true,\n\tselectBlockOnInsert = true,\n} ) {\n\tconst { getSelectedBlock } = useSelect( blockEditorStore );\n\tconst { destinationRootClientId, destinationIndex } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockIndex,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\n\t\t\tlet _destinationRootClientId = rootClientId;\n\t\t\tlet _destinationIndex;\n\n\t\t\tif ( insertionIndex !== undefined ) {\n\t\t\t\t// Insert into a specific index.\n\t\t\t\t_destinationIndex = insertionIndex;\n\t\t\t} else if ( clientId ) {\n\t\t\t\t// Insert after a specific client ID.\n\t\t\t\t_destinationIndex = getBlockIndex( clientId );\n\t\t\t} else if ( ! isAppender && selectedBlockClientId ) {\n\t\t\t\t_destinationRootClientId = getBlockRootClientId(\n\t\t\t\t\tselectedBlockClientId\n\t\t\t\t);\n\t\t\t\t_destinationIndex = getBlockIndex( selectedBlockClientId ) + 1;\n\t\t\t} else {\n\t\t\t\t// Insert at the end of the list.\n\t\t\t\t_destinationIndex = getBlockOrder(\n\t\t\t\t\t_destinationRootClientId\n\t\t\t\t).length;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tdestinationRootClientId: _destinationRootClientId,\n\t\t\t\tdestinationIndex: _destinationIndex,\n\t\t\t};\n\t\t},\n\t\t[ rootClientId, insertionIndex, clientId, isAppender ]\n\t);\n\n\tconst {\n\t\treplaceBlocks,\n\t\tinsertBlocks,\n\t\tshowInsertionPoint,\n\t\thideInsertionPoint,\n\t} = useDispatch( blockEditorStore );\n\n\tconst onInsertBlocks = useCallback(\n\t\t( blocks, meta, shouldForceFocusBlock = false ) => {\n\t\t\tconst selectedBlock = getSelectedBlock();\n\n\t\t\tif (\n\t\t\t\t! isAppender &&\n\t\t\t\tselectedBlock &&\n\t\t\t\tisUnmodifiedDefaultBlock( selectedBlock )\n\t\t\t) {\n\t\t\t\treplaceBlocks(\n\t\t\t\t\tselectedBlock.clientId,\n\t\t\t\t\tblocks,\n\t\t\t\t\tnull,\n\t\t\t\t\tshouldFocusBlock || shouldForceFocusBlock ? 0 : null,\n\t\t\t\t\tmeta\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tinsertBlocks(\n\t\t\t\t\tblocks,\n\t\t\t\t\tdestinationIndex,\n\t\t\t\t\tdestinationRootClientId,\n\t\t\t\t\tselectBlockOnInsert,\n\t\t\t\t\tshouldFocusBlock || shouldForceFocusBlock ? 0 : null,\n\t\t\t\t\tmeta\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst blockLength = Array.isArray( blocks ) ? blocks.length : 1;\n\t\t\tconst message = sprintf(\n\t\t\t\t// translators: %d: the name of the block that has been added\n\t\t\t\t_n( '%d block added.', '%d blocks added.', blockLength ),\n\t\t\t\tblockLength\n\t\t\t);\n\t\t\tspeak( message );\n\n\t\t\tif ( onSelect ) {\n\t\t\t\tonSelect( blocks );\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tisAppender,\n\t\t\tgetSelectedBlock,\n\t\t\treplaceBlocks,\n\t\t\tinsertBlocks,\n\t\t\tdestinationRootClientId,\n\t\t\tdestinationIndex,\n\t\t\tonSelect,\n\t\t\tshouldFocusBlock,\n\t\t]\n\t);\n\n\tconst onToggleInsertionPoint = useCallback(\n\t\t( show ) => {\n\t\t\tif ( show ) {\n\t\t\t\tshowInsertionPoint( destinationRootClientId, destinationIndex );\n\t\t\t} else {\n\t\t\t\thideInsertionPoint();\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tshowInsertionPoint,\n\t\t\thideInsertionPoint,\n\t\t\tdestinationRootClientId,\n\t\t\tdestinationIndex,\n\t\t]\n\t);\n\n\treturn [ destinationRootClientId, onInsertBlocks, onToggleInsertionPoint ];\n}\n\nexport default useInsertionPoint;\n"]}
@@ -151,18 +151,27 @@ class Inserter extends Component {
151
151
  // This prop is experimental to give some time for the quick inserter to mature
152
152
  // Feel free to make them stable after a few releases.
153
153
  __experimentalIsQuick: isQuick,
154
- prioritizePatterns
154
+ prioritizePatterns,
155
+ onSelectOrClose,
156
+ selectBlockOnInsert
155
157
  } = this.props;
156
158
 
157
159
  if (isQuick) {
158
160
  return createElement(QuickInserter, {
159
- onSelect: () => {
161
+ onSelect: blocks => {
162
+ const firstBlock = Array.isArray(blocks) && blocks !== null && blocks !== void 0 && blocks.length ? blocks[0] : blocks;
163
+
164
+ if (onSelectOrClose && typeof onSelectOrClose === 'function') {
165
+ onSelectOrClose(firstBlock);
166
+ }
167
+
160
168
  onClose();
161
169
  },
162
170
  rootClientId: rootClientId,
163
171
  clientId: clientId,
164
172
  isAppender: isAppender,
165
- prioritizePatterns: prioritizePatterns
173
+ prioritizePatterns: prioritizePatterns,
174
+ selectBlockOnInsert: selectBlockOnInsert
166
175
  });
167
176
  }
168
177
 
@@ -363,7 +372,7 @@ export default compose([withSelect((select, _ref4) => {
363
372
  var _blockToInsert;
364
373
 
365
374
  onSelectOrClose({
366
- insertedBlockId: (_blockToInsert = blockToInsert) === null || _blockToInsert === void 0 ? void 0 : _blockToInsert.clientId
375
+ clientId: (_blockToInsert = blockToInsert) === null || _blockToInsert === void 0 ? void 0 : _blockToInsert.clientId
367
376
  });
368
377
  }
369
378