@wordpress/block-editor 14.6.0 → 14.7.1-next.082ed6819.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 (332) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-controls/slot.js +6 -3
  3. package/build/components/block-controls/slot.js.map +1 -1
  4. package/build/components/block-inspector/index.js +1 -2
  5. package/build/components/block-inspector/index.js.map +1 -1
  6. package/build/components/block-list/block.js +14 -28
  7. package/build/components/block-list/block.js.map +1 -1
  8. package/build/components/block-lock/modal.js +1 -1
  9. package/build/components/block-lock/modal.js.map +1 -1
  10. package/build/components/block-manager/category.js +79 -0
  11. package/build/components/block-manager/category.js.map +1 -0
  12. package/build/components/block-manager/checklist.js +40 -0
  13. package/build/components/block-manager/checklist.js.map +1 -0
  14. package/build/components/block-manager/index.js +108 -0
  15. package/build/components/block-manager/index.js.map +1 -0
  16. package/build/components/block-patterns-list/index.js +23 -26
  17. package/build/components/block-patterns-list/index.js.map +1 -1
  18. package/build/components/block-popover/index.js +1 -1
  19. package/build/components/block-popover/index.js.map +1 -1
  20. package/build/components/block-preview/async.js +51 -0
  21. package/build/components/block-preview/async.js.map +1 -0
  22. package/build/components/block-preview/index.js +4 -1
  23. package/build/components/block-preview/index.js.map +1 -1
  24. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  25. package/build/components/block-settings-menu/index.js.map +1 -1
  26. package/build/components/block-toolbar/change-design.js +1 -4
  27. package/build/components/block-toolbar/change-design.js.map +1 -1
  28. package/build/components/block-toolbar/index.js +7 -2
  29. package/build/components/block-toolbar/index.js.map +1 -1
  30. package/build/components/block-toolbar/switch-section-style.js +105 -0
  31. package/build/components/block-toolbar/switch-section-style.js.map +1 -0
  32. package/build/components/block-tools/index.js +12 -9
  33. package/build/components/block-tools/index.js.map +1 -1
  34. package/build/components/block-tools/use-block-toolbar-popover-props.js +1 -1
  35. package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  36. package/build/components/block-tools/use-show-block-tools.js +4 -1
  37. package/build/components/block-tools/use-show-block-tools.js.map +1 -1
  38. package/build/components/collab/block-comment-icon-slot.js +2 -6
  39. package/build/components/collab/block-comment-icon-slot.js.map +1 -1
  40. package/build/components/collab/block-comment-icon-toolbar-slot.js +2 -6
  41. package/build/components/collab/block-comment-icon-toolbar-slot.js.map +1 -1
  42. package/build/components/color-palette/with-color-context.js +4 -2
  43. package/build/components/color-palette/with-color-context.js.map +1 -1
  44. package/build/components/font-family/index.js +14 -13
  45. package/build/components/font-family/index.js.map +1 -1
  46. package/build/components/global-styles/dimensions-panel.js +26 -14
  47. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  48. package/build/components/global-styles/use-global-styles-output.js +1 -1
  49. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  50. package/build/components/iframe/get-compatibility-styles.js +4 -4
  51. package/build/components/iframe/get-compatibility-styles.js.map +1 -1
  52. package/build/components/iframe/index.js +156 -23
  53. package/build/components/iframe/index.js.map +1 -1
  54. package/build/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
  55. package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  56. package/build/components/inserter/block-patterns-tab/index.js +1 -2
  57. package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
  58. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +4 -6
  59. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  60. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +3 -0
  61. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
  62. package/build/components/inserter/block-patterns-tab/utils.js +5 -1
  63. package/build/components/inserter/block-patterns-tab/utils.js.map +1 -1
  64. package/build/components/inserter/category-tabs/index.js +7 -8
  65. package/build/components/inserter/category-tabs/index.js.map +1 -1
  66. package/build/components/inserter/hooks/use-block-types-state.js +1 -1
  67. package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
  68. package/build/components/inserter/hooks/use-patterns-paging.js +0 -5
  69. package/build/components/inserter/hooks/use-patterns-paging.js.map +1 -1
  70. package/build/components/inserter/search-results.js +0 -2
  71. package/build/components/inserter/search-results.js.map +1 -1
  72. package/build/components/inserter-draggable-blocks/index.js +2 -1
  73. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  74. package/build/components/inspector-controls/slot.js +7 -4
  75. package/build/components/inspector-controls/slot.js.map +1 -1
  76. package/build/components/inspector-controls-tabs/position-controls-panel.js +1 -1
  77. package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
  78. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -4
  79. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  80. package/build/components/media-placeholder/index.js +33 -25
  81. package/build/components/media-placeholder/index.js.map +1 -1
  82. package/build/components/rich-text/index.js +1 -1
  83. package/build/components/rich-text/index.js.map +1 -1
  84. package/build/components/tabbed-sidebar/index.js +1 -1
  85. package/build/components/tabbed-sidebar/index.js.map +1 -1
  86. package/build/components/url-input/index.js +3 -1
  87. package/build/components/url-input/index.js.map +1 -1
  88. package/build/components/use-block-commands/index.js +5 -6
  89. package/build/components/use-block-commands/index.js.map +1 -1
  90. package/build/hooks/border.js +3 -3
  91. package/build/hooks/border.js.map +1 -1
  92. package/build/hooks/color.js +1 -1
  93. package/build/hooks/color.js.map +1 -1
  94. package/build/hooks/dimensions.js +2 -2
  95. package/build/hooks/dimensions.js.map +1 -1
  96. package/build/hooks/font-family.js +1 -1
  97. package/build/hooks/font-family.js.map +1 -1
  98. package/build/hooks/style.js +6 -6
  99. package/build/hooks/style.js.map +1 -1
  100. package/build/hooks/supports.js +7 -7
  101. package/build/hooks/supports.js.map +1 -1
  102. package/build/hooks/typography.js +6 -6
  103. package/build/hooks/typography.js.map +1 -1
  104. package/build/hooks/utils.js +3 -3
  105. package/build/hooks/utils.js.map +1 -1
  106. package/build/layouts/flex.js +11 -9
  107. package/build/layouts/flex.js.map +1 -1
  108. package/build/lock-unlock.js.map +1 -1
  109. package/build/private-apis.js +4 -4
  110. package/build/private-apis.js.map +1 -1
  111. package/build/store/private-selectors.js +3 -3
  112. package/build/store/private-selectors.js.map +1 -1
  113. package/build/store/selectors.js +12 -8
  114. package/build/store/selectors.js.map +1 -1
  115. package/build/store/utils.js +5 -4
  116. package/build/store/utils.js.map +1 -1
  117. package/build/utils/dom.js +27 -22
  118. package/build/utils/dom.js.map +1 -1
  119. package/build-module/components/block-controls/slot.js +6 -3
  120. package/build-module/components/block-controls/slot.js.map +1 -1
  121. package/build-module/components/block-inspector/index.js +1 -2
  122. package/build-module/components/block-inspector/index.js.map +1 -1
  123. package/build-module/components/block-list/block.js +15 -27
  124. package/build-module/components/block-list/block.js.map +1 -1
  125. package/build-module/components/block-lock/modal.js +1 -1
  126. package/build-module/components/block-lock/modal.js.map +1 -1
  127. package/build-module/components/block-manager/category.js +71 -0
  128. package/build-module/components/block-manager/category.js.map +1 -0
  129. package/build-module/components/block-manager/checklist.js +32 -0
  130. package/build-module/components/block-manager/checklist.js.map +1 -0
  131. package/build-module/components/block-manager/index.js +102 -0
  132. package/build-module/components/block-manager/index.js.map +1 -0
  133. package/build-module/components/block-patterns-list/index.js +23 -26
  134. package/build-module/components/block-patterns-list/index.js.map +1 -1
  135. package/build-module/components/block-popover/index.js +2 -2
  136. package/build-module/components/block-popover/index.js.map +1 -1
  137. package/build-module/components/block-preview/async.js +44 -0
  138. package/build-module/components/block-preview/async.js.map +1 -0
  139. package/build-module/components/block-preview/index.js +4 -1
  140. package/build-module/components/block-preview/index.js.map +1 -1
  141. package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
  142. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  143. package/build-module/components/block-settings-menu/index.js +2 -2
  144. package/build-module/components/block-settings-menu/index.js.map +1 -1
  145. package/build-module/components/block-toolbar/change-design.js +1 -4
  146. package/build-module/components/block-toolbar/change-design.js.map +1 -1
  147. package/build-module/components/block-toolbar/index.js +7 -2
  148. package/build-module/components/block-toolbar/index.js.map +1 -1
  149. package/build-module/components/block-toolbar/switch-section-style.js +97 -0
  150. package/build-module/components/block-toolbar/switch-section-style.js.map +1 -0
  151. package/build-module/components/block-tools/index.js +13 -10
  152. package/build-module/components/block-tools/index.js.map +1 -1
  153. package/build-module/components/block-tools/use-block-toolbar-popover-props.js +2 -2
  154. package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  155. package/build-module/components/block-tools/use-show-block-tools.js +4 -1
  156. package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
  157. package/build-module/components/collab/block-comment-icon-slot.js +2 -6
  158. package/build-module/components/collab/block-comment-icon-slot.js.map +1 -1
  159. package/build-module/components/collab/block-comment-icon-toolbar-slot.js +2 -6
  160. package/build-module/components/collab/block-comment-icon-toolbar-slot.js.map +1 -1
  161. package/build-module/components/color-palette/with-color-context.js +4 -2
  162. package/build-module/components/color-palette/with-color-context.js.map +1 -1
  163. package/build-module/components/font-family/index.js +15 -14
  164. package/build-module/components/font-family/index.js.map +1 -1
  165. package/build-module/components/global-styles/dimensions-panel.js +26 -14
  166. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  167. package/build-module/components/global-styles/use-global-styles-output.js +1 -1
  168. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  169. package/build-module/components/iframe/get-compatibility-styles.js +4 -4
  170. package/build-module/components/iframe/get-compatibility-styles.js.map +1 -1
  171. package/build-module/components/iframe/index.js +157 -24
  172. package/build-module/components/iframe/index.js.map +1 -1
  173. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
  174. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  175. package/build-module/components/inserter/block-patterns-tab/index.js +1 -2
  176. package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
  177. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +5 -7
  178. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  179. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +4 -1
  180. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
  181. package/build-module/components/inserter/block-patterns-tab/utils.js +4 -0
  182. package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -1
  183. package/build-module/components/inserter/category-tabs/index.js +8 -9
  184. package/build-module/components/inserter/category-tabs/index.js.map +1 -1
  185. package/build-module/components/inserter/hooks/use-block-types-state.js +1 -1
  186. package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
  187. package/build-module/components/inserter/hooks/use-patterns-paging.js +1 -6
  188. package/build-module/components/inserter/hooks/use-patterns-paging.js.map +1 -1
  189. package/build-module/components/inserter/search-results.js +0 -2
  190. package/build-module/components/inserter/search-results.js.map +1 -1
  191. package/build-module/components/inserter-draggable-blocks/index.js +2 -1
  192. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  193. package/build-module/components/inspector-controls/slot.js +7 -4
  194. package/build-module/components/inspector-controls/slot.js.map +1 -1
  195. package/build-module/components/inspector-controls-tabs/position-controls-panel.js +1 -1
  196. package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
  197. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -4
  198. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  199. package/build-module/components/media-placeholder/index.js +33 -25
  200. package/build-module/components/media-placeholder/index.js.map +1 -1
  201. package/build-module/components/rich-text/index.js +1 -1
  202. package/build-module/components/rich-text/index.js.map +1 -1
  203. package/build-module/components/tabbed-sidebar/index.js +1 -1
  204. package/build-module/components/tabbed-sidebar/index.js.map +1 -1
  205. package/build-module/components/url-input/index.js +3 -1
  206. package/build-module/components/url-input/index.js.map +1 -1
  207. package/build-module/components/use-block-commands/index.js +4 -4
  208. package/build-module/components/use-block-commands/index.js.map +1 -1
  209. package/build-module/hooks/border.js +3 -3
  210. package/build-module/hooks/border.js.map +1 -1
  211. package/build-module/hooks/color.js +1 -1
  212. package/build-module/hooks/color.js.map +1 -1
  213. package/build-module/hooks/dimensions.js +2 -2
  214. package/build-module/hooks/dimensions.js.map +1 -1
  215. package/build-module/hooks/font-family.js +1 -1
  216. package/build-module/hooks/font-family.js.map +1 -1
  217. package/build-module/hooks/style.js +6 -6
  218. package/build-module/hooks/style.js.map +1 -1
  219. package/build-module/hooks/supports.js +7 -7
  220. package/build-module/hooks/supports.js.map +1 -1
  221. package/build-module/hooks/typography.js +6 -6
  222. package/build-module/hooks/typography.js.map +1 -1
  223. package/build-module/hooks/utils.js +3 -3
  224. package/build-module/hooks/utils.js.map +1 -1
  225. package/build-module/layouts/flex.js +11 -9
  226. package/build-module/layouts/flex.js.map +1 -1
  227. package/build-module/lock-unlock.js.map +1 -1
  228. package/build-module/private-apis.js +6 -6
  229. package/build-module/private-apis.js.map +1 -1
  230. package/build-module/store/private-selectors.js +3 -3
  231. package/build-module/store/private-selectors.js.map +1 -1
  232. package/build-module/store/selectors.js +12 -8
  233. package/build-module/store/selectors.js.map +1 -1
  234. package/build-module/store/utils.js +3 -3
  235. package/build-module/store/utils.js.map +1 -1
  236. package/build-module/utils/dom.js +25 -21
  237. package/build-module/utils/dom.js.map +1 -1
  238. package/build-style/content-rtl.css +30 -15
  239. package/build-style/content.css +30 -15
  240. package/build-style/style-rtl.css +92 -3
  241. package/build-style/style.css +92 -3
  242. package/build-types/utils/dom.d.ts +7 -9
  243. package/build-types/utils/dom.d.ts.map +1 -1
  244. package/package.json +32 -31
  245. package/src/components/block-canvas/style.scss +1 -1
  246. package/src/components/block-controls/slot.js +5 -3
  247. package/src/components/block-inspector/index.js +0 -2
  248. package/src/components/block-inspector/style.scss +2 -1
  249. package/src/components/block-list/block.js +28 -48
  250. package/src/components/block-lock/modal.js +1 -1
  251. package/src/components/block-manager/category.js +102 -0
  252. package/src/components/block-manager/checklist.js +34 -0
  253. package/src/components/block-manager/index.js +127 -0
  254. package/src/components/block-manager/style.scss +82 -0
  255. package/src/components/block-mover/README.md +15 -8
  256. package/src/components/block-mover/stories/index.story.js +73 -71
  257. package/src/components/block-mover/style.scss +3 -0
  258. package/src/components/block-patterns-list/README.md +8 -8
  259. package/src/components/block-patterns-list/index.js +35 -51
  260. package/src/components/block-patterns-list/stories/index.story.js +2 -19
  261. package/src/components/block-popover/index.js +4 -4
  262. package/src/components/block-preview/async.js +43 -0
  263. package/src/components/block-preview/index.js +6 -1
  264. package/src/components/block-settings-menu/block-settings-dropdown.js +2 -2
  265. package/src/components/block-settings-menu/index.js +2 -2
  266. package/src/components/block-toolbar/change-design.js +1 -7
  267. package/src/components/block-toolbar/index.js +6 -0
  268. package/src/components/block-toolbar/switch-section-style.js +115 -0
  269. package/src/components/block-tools/index.js +26 -10
  270. package/src/components/block-tools/style.scss +12 -0
  271. package/src/components/block-tools/use-block-toolbar-popover-props.js +2 -2
  272. package/src/components/block-tools/use-show-block-tools.js +3 -1
  273. package/src/components/collab/block-comment-icon-slot.js +2 -6
  274. package/src/components/collab/block-comment-icon-toolbar-slot.js +3 -5
  275. package/src/components/color-palette/with-color-context.js +25 -7
  276. package/src/components/default-block-appender/content.scss +13 -19
  277. package/src/components/font-family/index.js +13 -13
  278. package/src/components/global-styles/dimensions-panel.js +22 -16
  279. package/src/components/global-styles/test/use-global-styles-output.js +1 -1
  280. package/src/components/global-styles/use-global-styles-output.js +1 -1
  281. package/src/components/iframe/content.scss +16 -3
  282. package/src/components/iframe/get-compatibility-styles.js +4 -9
  283. package/src/components/iframe/index.js +204 -44
  284. package/src/components/inserter/block-patterns-explorer/pattern-list.js +3 -6
  285. package/src/components/inserter/block-patterns-tab/index.js +0 -1
  286. package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +15 -17
  287. package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +8 -0
  288. package/src/components/inserter/block-patterns-tab/utils.js +5 -0
  289. package/src/components/inserter/category-tabs/index.js +8 -9
  290. package/src/components/inserter/hooks/use-block-types-state.js +6 -1
  291. package/src/components/inserter/hooks/use-patterns-paging.js +1 -6
  292. package/src/components/inserter/search-results.js +0 -6
  293. package/src/components/inserter-draggable-blocks/index.js +10 -1
  294. package/src/components/inspector-controls/README.md +2 -0
  295. package/src/components/inspector-controls/slot.js +6 -4
  296. package/src/components/inspector-controls-tabs/position-controls-panel.js +1 -3
  297. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +10 -10
  298. package/src/components/media-placeholder/index.js +41 -37
  299. package/src/components/provider/test/use-block-sync.js +3 -1
  300. package/src/components/rich-text/content.scss +15 -10
  301. package/src/components/rich-text/index.js +8 -1
  302. package/src/components/tabbed-sidebar/index.js +1 -1
  303. package/src/components/tabbed-sidebar/style.scss +1 -1
  304. package/src/components/url-input/index.js +3 -4
  305. package/src/components/use-block-commands/index.js +245 -234
  306. package/src/hooks/border.js +3 -9
  307. package/src/hooks/color.js +1 -1
  308. package/src/hooks/dimensions.js +2 -2
  309. package/src/hooks/font-family.js +1 -1
  310. package/src/hooks/style.js +6 -12
  311. package/src/hooks/supports.js +7 -7
  312. package/src/hooks/test/style.js +1 -2
  313. package/src/hooks/typography.js +6 -6
  314. package/src/hooks/utils.js +8 -3
  315. package/src/layouts/flex.js +26 -18
  316. package/src/private-apis.js +6 -6
  317. package/src/store/private-selectors.js +6 -7
  318. package/src/store/selectors.js +60 -45
  319. package/src/store/test/private-selectors.js +5 -0
  320. package/src/store/test/selectors.js +87 -58
  321. package/src/store/utils.js +12 -11
  322. package/src/style.scss +1 -0
  323. package/src/utils/dom.js +26 -21
  324. package/src/utils/test/dom.js +224 -0
  325. package/tsconfig.json +1 -0
  326. package/tsconfig.tsbuildinfo +1 -1
  327. package/build/components/block-info-slot-fill/index.js +0 -39
  328. package/build/components/block-info-slot-fill/index.js.map +0 -1
  329. package/build-module/components/block-info-slot-fill/index.js +0 -32
  330. package/build-module/components/block-info-slot-fill/index.js.map +0 -1
  331. package/src/components/block-info-slot-fill/index.js +0 -27
  332. /package/src/{lock-unlock.js → lock-unlock.ts} +0 -0
@@ -0,0 +1,82 @@
1
+ .block-editor-block-manager__no-results {
2
+ font-style: italic;
3
+ padding: $grid-unit-30 0;
4
+ text-align: center;
5
+ }
6
+
7
+ .block-editor-block-manager__search {
8
+ margin: $grid-unit-20 0;
9
+ }
10
+
11
+ .block-editor-block-manager__disabled-blocks-count {
12
+ border: $border-width solid $gray-300;
13
+ border-width: $border-width 0;
14
+ // Cover up horizontal areas off the sides of the box rectangle
15
+ box-shadow: -$grid-unit-40 0 0 0 $white, $grid-unit-40 0 0 0 $white;
16
+ padding: $grid-unit-10;
17
+ background-color: $white;
18
+ text-align: center;
19
+ position: sticky;
20
+ // When sticking, tuck the top border beneath the modal header border
21
+ top: ($grid-unit-05 + 1) * -1;
22
+ z-index: z-index(".block-editor-block-manager__disabled-blocks-count");
23
+
24
+ // Stick the category titles to the bottom
25
+ ~ .block-editor-block-manager__results .block-editor-block-manager__category-title {
26
+ top: $grid-unit-40 - 1;
27
+ }
28
+ .is-link {
29
+ margin-left: 12px;
30
+ }
31
+ }
32
+
33
+ .block-editor-block-manager__category {
34
+ margin: 0 0 $grid-unit-30 0;
35
+ }
36
+
37
+ .block-editor-block-manager__category-title {
38
+ position: sticky;
39
+ top: - $grid-unit-05; // Offsets the top padding on the modal content container
40
+ padding: $grid-unit-20 0;
41
+ background-color: $white;
42
+ z-index: z-index(".block-editor-block-manager__category-title");
43
+
44
+ .components-checkbox-control__label {
45
+ font-weight: 600;
46
+ }
47
+ }
48
+
49
+ .block-editor-block-manager__checklist {
50
+ margin-top: 0;
51
+ }
52
+
53
+ .block-editor-block-manager__category-title,
54
+ .block-editor-block-manager__checklist-item {
55
+ border-bottom: 1px solid $gray-300;
56
+ }
57
+
58
+ .block-editor-block-manager__checklist-item {
59
+ display: flex;
60
+ justify-content: space-between;
61
+ align-items: center;
62
+ margin-bottom: 0;
63
+ padding: $grid-unit-10 0 $grid-unit-10 $grid-unit-20;
64
+
65
+ .components-modal__content &.components-checkbox-control__input-container {
66
+ margin: 0 $grid-unit-10;
67
+ }
68
+
69
+ .block-editor-block-icon {
70
+ margin-right: 10px;
71
+ fill: $gray-900;
72
+ }
73
+ }
74
+
75
+ .block-editor-block-manager__results {
76
+ border-top: $border-width solid $gray-300;
77
+ }
78
+
79
+ // Remove the top border from results when adjacent to the disabled block count
80
+ .block-editor-block-manager__disabled-blocks-count + .block-editor-block-manager__results {
81
+ border-top-width: 0;
82
+ }
@@ -1,12 +1,10 @@
1
- # Block mover
1
+ # BlockMover
2
2
 
3
- Block movers allow moving blocks inside the editor using up and down buttons.
3
+ BlockMover component allows moving blocks inside the editor using up and down buttons.
4
4
 
5
5
  ![Block mover screenshot](https://make.wordpress.org/core/files/2020/08/block-mover-screenshot.png)
6
6
 
7
- ## Development guidelines
8
-
9
- ### Usage
7
+ ## Usage
10
8
 
11
9
  Shows the block mover buttons in the block toolbar.
12
10
 
@@ -15,13 +13,22 @@ import { BlockMover } from '@wordpress/block-editor';
15
13
  const MyMover = () => <BlockMover clientIds={ [ clientId ] } />;
16
14
  ```
17
15
 
18
- ### Props
16
+ ## Props
19
17
 
20
- #### clientIds
18
+ ### clientIds
21
19
 
22
- Blocks IDs
20
+ The IDs of the blocks to move.
23
21
 
24
22
  - Type: `Array`
23
+ - Required: Yes
24
+
25
+ ### hideDragHandle
26
+
27
+ If this property is true, the drag handle is hidden.
28
+
29
+ - Type: `boolean`
30
+ - Required: No
31
+ - Default: `false`
25
32
 
26
33
  ## Related components
27
34
 
@@ -14,6 +14,7 @@ import BlockMover from '../';
14
14
  import { ExperimentalBlockEditorProvider } from '../../provider';
15
15
  import { store as blockEditorStore } from '../../../store';
16
16
 
17
+ // For the purpose of this story, we need to register the core blocks samples.
17
18
  registerCoreBlocks();
18
19
  const blocks = [
19
20
  // vertical
@@ -30,81 +31,82 @@ const blocks = [
30
31
  ] ),
31
32
  ];
32
33
 
33
- function Provider( { children } ) {
34
- const wrapperStyle = { margin: '24px', position: 'relative' };
35
-
36
- return (
37
- <div style={ wrapperStyle }>
34
+ /**
35
+ * BlockMover component allows moving blocks inside the editor using up and down buttons.
36
+ */
37
+ const meta = {
38
+ title: 'BlockEditor/BlockMover',
39
+ component: BlockMover,
40
+ parameters: {
41
+ docs: { canvas: { sourceState: 'shown' } },
42
+ },
43
+ decorators: [
44
+ ( Story ) => (
38
45
  <ExperimentalBlockEditorProvider value={ blocks }>
39
- { children }
46
+ <Toolbar label="Block Mover">
47
+ <Story />
48
+ </Toolbar>
40
49
  </ExperimentalBlockEditorProvider>
41
- </div>
42
- );
43
- }
44
-
45
- function BlockMoverStory() {
46
- const { updateBlockListSettings } = useDispatch( blockEditorStore );
47
-
48
- useEffect( () => {
49
- /**
50
- * This shouldn't be needed but unfortunatley
51
- * the layout orientation is not declarative, we need
52
- * to render the blocks to update the block settings in the state.
53
- */
54
- updateBlockListSettings( blocks[ 1 ].clientId, {
55
- orientation: 'horizontal',
56
- } );
57
- }, [] );
58
-
59
- return (
60
- <div>
61
- <p>The mover by default is vertical</p>
62
- <Toolbar label="Block Mover">
63
- <BlockMover
64
- clientIds={
65
- blocks.length
66
- ? [ blocks[ 0 ].innerBlocks[ 1 ].clientId ]
67
- : []
68
- }
69
- />
70
- </Toolbar>
71
-
72
- <p style={ { marginTop: 36 } }>
73
- But it can also accommodate horizontal blocks.
74
- </p>
75
- <Toolbar label="Block Mover">
76
- <BlockMover
77
- clientIds={
78
- blocks.length
79
- ? [ blocks[ 1 ].innerBlocks[ 1 ].clientId ]
80
- : []
81
- }
82
- />
83
- </Toolbar>
50
+ ),
51
+ ],
52
+ argTypes: {
53
+ clientIds: {
54
+ control: {
55
+ type: 'none',
56
+ },
57
+ description: 'The client IDs of the blocks to move.',
58
+ },
59
+ hideDragHandle: {
60
+ control: {
61
+ type: 'boolean',
62
+ },
63
+ description: 'If this property is true, the drag handle is hidden.',
64
+ },
65
+ },
66
+ };
67
+ export default meta;
84
68
 
85
- <p style={ { marginTop: 36 } }>We can also hide the drag handle.</p>
86
- <Toolbar label="Block Mover">
87
- <BlockMover
88
- clientIds={
89
- blocks.length
90
- ? [ blocks[ 1 ].innerBlocks[ 0 ].clientId ]
91
- : []
92
- }
93
- hideDragHandle
94
- />
95
- </Toolbar>
96
- </div>
97
- );
98
- }
69
+ export const Default = {
70
+ args: {
71
+ clientIds: [ blocks[ 0 ].innerBlocks[ 1 ].clientId ],
72
+ },
73
+ };
99
74
 
100
- export default {
101
- title: 'BlockEditor/BlockMover',
75
+ /**
76
+ * This story shows the block mover with horizontal orientation.
77
+ * It is necessary to render the blocks to update the block settings in the state.
78
+ */
79
+ export const Horizontal = {
80
+ decorators: [
81
+ ( Story ) => {
82
+ const { updateBlockListSettings } = useDispatch( blockEditorStore );
83
+ useEffect( () => {
84
+ /**
85
+ * This shouldn't be needed but unfortunately
86
+ * the layout orientation is not declarative, we need
87
+ * to render the blocks to update the block settings in the state.
88
+ */
89
+ updateBlockListSettings( blocks[ 1 ].clientId, {
90
+ orientation: 'horizontal',
91
+ } );
92
+ }, [] );
93
+ return <Story />;
94
+ },
95
+ ],
96
+ args: {
97
+ clientIds: [ blocks[ 1 ].innerBlocks[ 1 ].clientId ],
98
+ },
99
+ parameters: {
100
+ docs: { canvas: { sourceState: 'hidden' } },
101
+ },
102
102
  };
103
103
 
104
- export const _default = () => {
105
- return (
106
- <Provider>
107
- <BlockMoverStory />
108
- </Provider>
109
- );
104
+ /**
105
+ * You can hide the drag handle by `hideDragHandle` attribute.
106
+ */
107
+ export const HideDragHandle = {
108
+ args: {
109
+ ...Default.args,
110
+ hideDragHandle: true,
111
+ },
110
112
  };
@@ -71,6 +71,9 @@
71
71
 
72
72
  // Specificity is necessary to override block toolbar button styles.
73
73
  .components-button.block-editor-block-mover-button {
74
+ // Prevent the SVGs inside the button from overflowing the button.
75
+ overflow: hidden;
76
+
74
77
  // Focus and toggle pseudo elements.
75
78
  &::before {
76
79
  content: "";
@@ -18,7 +18,6 @@ import { BlockPatternsList } from '@wordpress/block-editor';
18
18
  const MyBlockPatternsList = () => (
19
19
  <BlockPatternsList
20
20
  blockPatterns={ shownBlockPatterns }
21
- shownPatterns={ shownBlockPatterns }
22
21
  onClickPattern={ onSelectBlockPattern }
23
22
  />
24
23
  );
@@ -33,13 +32,6 @@ An array of block patterns that can be shown in the block patterns list.
33
32
  - Type: `Array`
34
33
  - Required: Yes
35
34
 
36
- #### shownPatterns
37
-
38
- An array of shown block patterns objects.
39
-
40
- - Type: `Array`
41
- - Required: Yes
42
-
43
35
  #### onClickPattern
44
36
 
45
37
  The performed event after a click on a block pattern. In most cases, the pattern is inserted in the block editor.
@@ -69,6 +61,14 @@ The aria label for the block patterns list.
69
61
  - Required: No
70
62
  - Default: `Block Patterns`
71
63
 
64
+ #### showTitlesAsTooltip
65
+
66
+ Whether to render the title of each pattern as a tooltip. User-defined patterns always show their visual title regardless of this prop.
67
+
68
+ - Type: `boolean`
69
+ - Required: No
70
+ - Default: `false`
71
+
72
72
  ## Related components
73
73
 
74
74
  Block Editor components are components that can be used to compose the UI of your block editor. Thus, they can only be used under a [`BlockEditorProvider`](https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/provider/README.md) in the components tree.
@@ -39,14 +39,14 @@ function BlockPattern( {
39
39
  pattern,
40
40
  onClick,
41
41
  onHover,
42
- showTitle = true,
43
- showTooltip,
42
+ showTitlesAsTooltip,
44
43
  category,
45
44
  } ) {
46
45
  const [ isDragging, setIsDragging ] = useState( false );
47
46
  const { blocks, viewportWidth } = pattern;
48
47
  const instanceId = useInstanceId( BlockPattern );
49
48
  const descriptionId = `block-editor-block-patterns-list__item-description-${ instanceId }`;
49
+ const isUserPattern = pattern.type === INSERTER_PATTERN_TYPES.user;
50
50
 
51
51
  // When we have a selected category and the pattern is draggable, we need to update the
52
52
  // pattern's categories in metadata to only contain the selected category, and pass this to
@@ -94,10 +94,7 @@ function BlockPattern( {
94
94
  } }
95
95
  >
96
96
  <WithToolTip
97
- showTooltip={
98
- showTooltip &&
99
- ! pattern.type !== INSERTER_PATTERN_TYPES.user
100
- }
97
+ showTooltip={ showTitlesAsTooltip && ! isUserPattern }
101
98
  title={ pattern.title }
102
99
  >
103
100
  <Composite.Item
@@ -134,33 +131,30 @@ function BlockPattern( {
134
131
  } }
135
132
  onMouseLeave={ () => onHover?.( null ) }
136
133
  >
137
- <BlockPreview
138
- blocks={ blocks }
139
- viewportWidth={ viewportWidth }
140
- />
141
-
142
- { showTitle && (
134
+ <BlockPreview.Async
135
+ placeholder={ <BlockPatternPlaceholder /> }
136
+ >
137
+ <BlockPreview
138
+ blocks={ blocks }
139
+ viewportWidth={ viewportWidth }
140
+ />
141
+ </BlockPreview.Async>
142
+ { ( ! showTitlesAsTooltip || isUserPattern ) && (
143
143
  <HStack
144
144
  className="block-editor-patterns__pattern-details"
145
145
  spacing={ 2 }
146
146
  >
147
- { pattern.type ===
148
- INSERTER_PATTERN_TYPES.user &&
149
- ! pattern.syncStatus && (
150
- <div className="block-editor-patterns__pattern-icon-wrapper">
151
- <Icon
152
- className="block-editor-patterns__pattern-icon"
153
- icon={ symbol }
154
- />
155
- </div>
156
- ) }
157
- { ( ! showTooltip ||
158
- pattern.type ===
159
- INSERTER_PATTERN_TYPES.user ) && (
160
- <div className="block-editor-block-patterns-list__item-title">
161
- { pattern.title }
147
+ { isUserPattern && ! pattern.syncStatus && (
148
+ <div className="block-editor-patterns__pattern-icon-wrapper">
149
+ <Icon
150
+ className="block-editor-patterns__pattern-icon"
151
+ icon={ symbol }
152
+ />
162
153
  </div>
163
154
  ) }
155
+ <div className="block-editor-block-patterns-list__item-title">
156
+ { pattern.title }
157
+ </div>
164
158
  </HStack>
165
159
  ) }
166
160
 
@@ -187,13 +181,11 @@ function BlockPatternsList(
187
181
  {
188
182
  isDraggable,
189
183
  blockPatterns,
190
- shownPatterns,
191
184
  onHover,
192
185
  onClickPattern,
193
186
  orientation,
194
187
  label = __( 'Block patterns' ),
195
188
  category,
196
- showTitle = true,
197
189
  showTitlesAsTooltip,
198
190
  pagingProps,
199
191
  },
@@ -205,11 +197,9 @@ function BlockPatternsList(
205
197
  // Reset the active composite item whenever the available patterns change,
206
198
  // to make sure that Composite widget can receive focus correctly when its
207
199
  // composite items change. The first composite item will receive focus.
208
- const firstCompositeItemId = blockPatterns.find( ( pattern ) =>
209
- shownPatterns.includes( pattern )
210
- )?.name;
200
+ const firstCompositeItemId = blockPatterns[ 0 ]?.name;
211
201
  setActiveCompositeId( firstCompositeItemId );
212
- }, [ shownPatterns, blockPatterns ] );
202
+ }, [ blockPatterns ] );
213
203
 
214
204
  return (
215
205
  <Composite
@@ -221,24 +211,18 @@ function BlockPatternsList(
221
211
  aria-label={ label }
222
212
  ref={ ref }
223
213
  >
224
- { blockPatterns.map( ( pattern ) => {
225
- const isShown = shownPatterns.includes( pattern );
226
- return isShown ? (
227
- <BlockPattern
228
- key={ pattern.name }
229
- id={ pattern.name }
230
- pattern={ pattern }
231
- onClick={ onClickPattern }
232
- onHover={ onHover }
233
- isDraggable={ isDraggable }
234
- showTitle={ showTitle }
235
- showTooltip={ showTitlesAsTooltip }
236
- category={ category }
237
- />
238
- ) : (
239
- <BlockPatternPlaceholder key={ pattern.name } />
240
- );
241
- } ) }
214
+ { blockPatterns.map( ( pattern ) => (
215
+ <BlockPattern
216
+ key={ pattern.name }
217
+ id={ pattern.name }
218
+ pattern={ pattern }
219
+ onClick={ onClickPattern }
220
+ onHover={ onHover }
221
+ isDraggable={ isDraggable }
222
+ showTitlesAsTooltip={ showTitlesAsTooltip }
223
+ category={ category }
224
+ />
225
+ ) ) }
242
226
  { pagingProps && <BlockPatternsPaging { ...pagingProps } /> }
243
227
  </Composite>
244
228
  );
@@ -3,11 +3,6 @@
3
3
  */
4
4
  import blockLibraryStyles from '!!raw-loader!../../../../../block-library/build-style/style.css';
5
5
 
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { useAsyncList } from '@wordpress/compose';
10
-
11
6
  /**
12
7
  * Internal dependencies
13
8
  */
@@ -26,13 +21,9 @@ export default {
26
21
 
27
22
  export const Default = {
28
23
  render: function Template( props ) {
29
- const shownPatterns = useAsyncList( props.blockPatterns );
30
24
  return (
31
25
  <ExperimentalBlockEditorProvider settings={ blockEditorSettings }>
32
- <BlockPatternsList
33
- shownPatterns={ shownPatterns }
34
- { ...props }
35
- />
26
+ <BlockPatternsList { ...props } />
36
27
  </ExperimentalBlockEditorProvider>
37
28
  );
38
29
  },
@@ -40,7 +31,6 @@ export const Default = {
40
31
  blockPatterns: patterns,
41
32
  isDraggable: false,
42
33
  label: 'Block patterns story',
43
- showTitle: true,
44
34
  showTitlesAsTooltip: false,
45
35
  },
46
36
  argTypes: {
@@ -49,18 +39,11 @@ export const Default = {
49
39
  description:
50
40
  'Usually this component is used with `useAsyncList` for performance reasons and you should provide the returned list from that hook. Alternatively it should have the same value with `blockPatterns`.',
51
41
  },
52
- showTitle: {
53
- description: 'Whether to render the title of each pattern.',
54
- table: {
55
- defaultValue: { summary: true },
56
- type: { summary: 'boolean' },
57
- },
58
- },
59
42
  onClickPattern: { type: 'function' },
60
43
  onHover: { type: 'function' },
61
44
  showTitlesAsTooltip: {
62
45
  description:
63
- 'Whether to render the title of each pattern as a tooltip. If enabled, it takes precedence over `showTitle` prop.',
46
+ 'Whether to render the title of each pattern as a tooltip. If enabled',
64
47
  },
65
48
  orientation: {
66
49
  description: 'Orientation for the underlying composite widget.',
@@ -20,7 +20,7 @@ import {
20
20
  */
21
21
  import { useBlockElement } from '../block-list/use-block-props/use-block-refs';
22
22
  import usePopoverScroll from './use-popover-scroll';
23
- import { rectUnion, getVisibleElementBounds } from '../../utils/dom';
23
+ import { rectUnion, getElementBounds } from '../../utils/dom';
24
24
 
25
25
  const MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;
26
26
 
@@ -90,10 +90,10 @@ function BlockPopover(
90
90
  getBoundingClientRect() {
91
91
  return lastSelectedElement
92
92
  ? rectUnion(
93
- getVisibleElementBounds( selectedElement ),
94
- getVisibleElementBounds( lastSelectedElement )
93
+ getElementBounds( selectedElement ),
94
+ getElementBounds( lastSelectedElement )
95
95
  )
96
- : getVisibleElementBounds( selectedElement );
96
+ : getElementBounds( selectedElement );
97
97
  },
98
98
  contextElement: selectedElement,
99
99
  };
@@ -0,0 +1,43 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useEffect, useState, flushSync } from '@wordpress/element';
5
+ import { createQueue } from '@wordpress/priority-queue';
6
+
7
+ const blockPreviewQueue = createQueue();
8
+
9
+ /**
10
+ * Renders a component at the next idle time.
11
+ * @param {*} props
12
+ */
13
+ export function Async( { children, placeholder } ) {
14
+ const [ shouldRender, setShouldRender ] = useState( false );
15
+
16
+ // In the future, we could try to use startTransition here, but currently
17
+ // react will batch all transitions, which means all previews will be
18
+ // rendered at the same time.
19
+ // https://react.dev/reference/react/startTransition#caveats
20
+ // > If there are multiple ongoing Transitions, React currently batches them
21
+ // > together. This is a limitation that will likely be removed in a future
22
+ // > release.
23
+
24
+ useEffect( () => {
25
+ const context = {};
26
+ blockPreviewQueue.add( context, () => {
27
+ // Synchronously run all renders so it consumes timeRemaining.
28
+ // See https://github.com/WordPress/gutenberg/pull/48238
29
+ flushSync( () => {
30
+ setShouldRender( true );
31
+ } );
32
+ } );
33
+ return () => {
34
+ blockPreviewQueue.cancel( context );
35
+ };
36
+ }, [] );
37
+
38
+ if ( ! shouldRender ) {
39
+ return placeholder;
40
+ }
41
+
42
+ return children;
43
+ }
@@ -19,6 +19,7 @@ import AutoHeightBlockPreview from './auto';
19
19
  import EditorStyles from '../editor-styles';
20
20
  import { store as blockEditorStore } from '../../store';
21
21
  import { BlockListItems } from '../block-list';
22
+ import { Async } from './async';
22
23
 
23
24
  const EMPTY_ADDITIONAL_STYLES = [];
24
25
 
@@ -86,6 +87,10 @@ export function BlockPreview( {
86
87
  );
87
88
  }
88
89
 
90
+ const MemoizedBlockPreview = memo( BlockPreview );
91
+
92
+ MemoizedBlockPreview.Async = Async;
93
+
89
94
  /**
90
95
  * BlockPreview renders a preview of a block or array of blocks.
91
96
  *
@@ -97,7 +102,7 @@ export function BlockPreview( {
97
102
  *
98
103
  * @return {Component} The component to be rendered.
99
104
  */
100
- export default memo( BlockPreview );
105
+ export default MemoizedBlockPreview;
101
106
 
102
107
  /**
103
108
  * This hook is used to lightly mark an element as a block preview wrapper
@@ -19,7 +19,7 @@ import { pipe, useCopyToClipboard } from '@wordpress/compose';
19
19
  * Internal dependencies
20
20
  */
21
21
  import BlockActions from '../block-actions';
22
- import __unstableCommentIconFill from '../../components/collab/block-comment-icon-slot';
22
+ import CommentIconSlotFill from '../../components/collab/block-comment-icon-slot';
23
23
  import BlockHTMLConvertButton from './block-html-convert-button';
24
24
  import __unstableBlockSettingsMenuFirstItem from './block-settings-menu-first-item';
25
25
  import BlockSettingsMenuControls from '../block-settings-menu-controls';
@@ -295,7 +295,7 @@ export function BlockSettingsDropdown( {
295
295
  </MenuItem>
296
296
  </>
297
297
  ) }
298
- <__unstableCommentIconFill.Slot
298
+ <CommentIconSlotFill.Slot
299
299
  fillProps={ { onClose } }
300
300
  />
301
301
  </MenuGroup>
@@ -7,12 +7,12 @@ import { ToolbarGroup, ToolbarItem } from '@wordpress/components';
7
7
  * Internal dependencies
8
8
  */
9
9
  import BlockSettingsDropdown from './block-settings-dropdown';
10
- import __unstableCommentIconToolbarFill from '../../components/collab/block-comment-icon-toolbar-slot';
10
+ import CommentIconToolbarSlotFill from '../../components/collab/block-comment-icon-toolbar-slot';
11
11
 
12
12
  export function BlockSettingsMenu( { clientIds, ...props } ) {
13
13
  return (
14
14
  <ToolbarGroup>
15
- <__unstableCommentIconToolbarFill.Slot />
15
+ <CommentIconToolbarSlotFill.Slot />
16
16
 
17
17
  <ToolbarItem>
18
18
  { ( toggleProps ) => (