@wordpress/block-editor 12.13.0 → 12.14.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 (344) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-heading-level-dropdown/index.js +1 -1
  3. package/build/components/block-heading-level-dropdown/index.js.map +1 -1
  4. package/build/components/block-list/index.js +2 -9
  5. package/build/components/block-list/index.js.map +1 -1
  6. package/build/components/block-list-appender/index.js +16 -3
  7. package/build/components/block-list-appender/index.js.map +1 -1
  8. package/build/components/block-quick-navigation/index.js +6 -4
  9. package/build/components/block-quick-navigation/index.js.map +1 -1
  10. package/build/components/block-styles/index.js +0 -8
  11. package/build/components/block-styles/index.js.map +1 -1
  12. package/build/components/block-switcher/pattern-transformations-menu.js +18 -14
  13. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  14. package/build/components/block-tools/back-compat.js +2 -2
  15. package/build/components/block-tools/back-compat.js.map +1 -1
  16. package/build/components/block-tools/block-contextual-toolbar.js +11 -81
  17. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  18. package/build/components/block-tools/empty-block-inserter.js +56 -0
  19. package/build/components/block-tools/empty-block-inserter.js.map +1 -0
  20. package/build/components/block-tools/index.js +48 -9
  21. package/build/components/block-tools/index.js.map +1 -1
  22. package/build/components/block-tools/selected-block-tools.js +113 -0
  23. package/build/components/block-tools/selected-block-tools.js.map +1 -0
  24. package/build/components/block-tools/use-selected-block-tool-props.js +56 -0
  25. package/build/components/block-tools/use-selected-block-tool-props.js.map +1 -0
  26. package/build/components/editable-text/index.js +1 -2
  27. package/build/components/editable-text/index.js.map +1 -1
  28. package/build/components/iframe/index.js +4 -3
  29. package/build/components/iframe/index.js.map +1 -1
  30. package/build/components/inserter/block-patterns-explorer/{explorer.js → index.js} +7 -7
  31. package/build/components/inserter/block-patterns-explorer/index.js.map +1 -0
  32. package/build/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +1 -1
  33. package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -0
  34. package/build/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +4 -4
  35. package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -0
  36. package/build/components/inserter/block-patterns-tab/index.js +75 -0
  37. package/build/components/inserter/block-patterns-tab/index.js.map +1 -0
  38. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +48 -0
  39. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -0
  40. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +108 -0
  41. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -0
  42. package/build/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +18 -34
  43. package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -0
  44. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +55 -0
  45. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -0
  46. package/build/components/inserter/block-patterns-tab/utils.js +70 -0
  47. package/build/components/inserter/block-patterns-tab/utils.js.map +1 -0
  48. package/build/components/inserter/media-tab/media-list.js +9 -5
  49. package/build/components/inserter/media-tab/media-list.js.map +1 -1
  50. package/build/components/inserter/media-tab/media-preview.js +15 -12
  51. package/build/components/inserter/media-tab/media-preview.js.map +1 -1
  52. package/build/components/inserter/menu.js +3 -4
  53. package/build/components/inserter/menu.js.map +1 -1
  54. package/build/components/link-control/index.js +6 -5
  55. package/build/components/link-control/index.js.map +1 -1
  56. package/build/components/list-view/block-select-button.js +39 -0
  57. package/build/components/list-view/block-select-button.js.map +1 -1
  58. package/build/components/list-view/block.js +16 -3
  59. package/build/components/list-view/block.js.map +1 -1
  60. package/build/components/list-view/index.js +3 -2
  61. package/build/components/list-view/index.js.map +1 -1
  62. package/build/components/navigable-toolbar/index.js +69 -18
  63. package/build/components/navigable-toolbar/index.js.map +1 -1
  64. package/build/components/provider/use-block-sync.js +1 -14
  65. package/build/components/provider/use-block-sync.js.map +1 -1
  66. package/build/components/rich-text/index.js +0 -1
  67. package/build/components/rich-text/index.js.map +1 -1
  68. package/build/components/rich-text/index.native.js +3 -1
  69. package/build/components/rich-text/index.native.js.map +1 -1
  70. package/build/components/rich-text/native/format-edit.js +45 -0
  71. package/build/components/rich-text/native/format-edit.js.map +1 -0
  72. package/build/components/rich-text/native/get-format-colors.native.js +41 -0
  73. package/build/components/rich-text/native/get-format-colors.native.js.map +1 -0
  74. package/build/components/rich-text/native/index.js +9 -0
  75. package/build/components/rich-text/native/index.js.map +1 -0
  76. package/build/components/rich-text/native/index.native.js +1158 -0
  77. package/build/components/rich-text/native/index.native.js.map +1 -0
  78. package/build/components/rich-text/native/toolbar-button-with-options.native.js +58 -0
  79. package/build/components/rich-text/native/toolbar-button-with-options.native.js.map +1 -0
  80. package/build/components/rich-text/native/use-format-types.js +111 -0
  81. package/build/components/rich-text/native/use-format-types.js.map +1 -0
  82. package/build/components/rich-text/use-paste-handler.js +2 -5
  83. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  84. package/build/components/url-popover/image-url-input-ui.js +2 -1
  85. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  86. package/build/components/writing-flow/use-tab-nav.js +7 -3
  87. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  88. package/build/hooks/align.js +10 -10
  89. package/build/hooks/align.js.map +1 -1
  90. package/build/hooks/align.native.js +2 -2
  91. package/build/hooks/align.native.js.map +1 -1
  92. package/build/hooks/anchor.js +7 -6
  93. package/build/hooks/anchor.js.map +1 -1
  94. package/build/hooks/background.js +16 -4
  95. package/build/hooks/background.js.map +1 -1
  96. package/build/hooks/block-hooks.js +7 -8
  97. package/build/hooks/block-hooks.js.map +1 -1
  98. package/build/hooks/block-rename-ui.js +7 -5
  99. package/build/hooks/block-rename-ui.js.map +1 -1
  100. package/build/hooks/content-lock-ui.js +5 -5
  101. package/build/hooks/content-lock-ui.js.map +1 -1
  102. package/build/hooks/custom-class-name.js +8 -7
  103. package/build/hooks/custom-class-name.js.map +1 -1
  104. package/build/hooks/custom-fields.js +4 -4
  105. package/build/hooks/custom-fields.js.map +1 -1
  106. package/build/hooks/duotone.js +9 -20
  107. package/build/hooks/duotone.js.map +1 -1
  108. package/build/hooks/layout.js +90 -86
  109. package/build/hooks/layout.js.map +1 -1
  110. package/build/hooks/position.js +10 -9
  111. package/build/hooks/position.js.map +1 -1
  112. package/build/hooks/style.js +10 -13
  113. package/build/hooks/style.js.map +1 -1
  114. package/build/hooks/utils.js +30 -0
  115. package/build/hooks/utils.js.map +1 -1
  116. package/build/private-apis.js +3 -0
  117. package/build/private-apis.js.map +1 -1
  118. package/build/store/actions.js +30 -37
  119. package/build/store/actions.js.map +1 -1
  120. package/build/store/reducer.js +18 -0
  121. package/build/store/reducer.js.map +1 -1
  122. package/build/store/selectors.js +16 -13
  123. package/build/store/selectors.js.map +1 -1
  124. package/build-module/components/block-heading-level-dropdown/index.js +1 -1
  125. package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
  126. package/build-module/components/block-list/index.js +3 -10
  127. package/build-module/components/block-list/index.js.map +1 -1
  128. package/build-module/components/block-list-appender/index.js +16 -3
  129. package/build-module/components/block-list-appender/index.js.map +1 -1
  130. package/build-module/components/block-quick-navigation/index.js +7 -5
  131. package/build-module/components/block-quick-navigation/index.js.map +1 -1
  132. package/build-module/components/block-styles/index.js +0 -8
  133. package/build-module/components/block-styles/index.js.map +1 -1
  134. package/build-module/components/block-switcher/pattern-transformations-menu.js +17 -13
  135. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  136. package/build-module/components/block-tools/back-compat.js +1 -1
  137. package/build-module/components/block-tools/back-compat.js.map +1 -1
  138. package/build-module/components/block-tools/block-contextual-toolbar.js +11 -80
  139. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  140. package/build-module/components/block-tools/empty-block-inserter.js +48 -0
  141. package/build-module/components/block-tools/empty-block-inserter.js.map +1 -0
  142. package/build-module/components/block-tools/index.js +48 -9
  143. package/build-module/components/block-tools/index.js.map +1 -1
  144. package/build-module/components/block-tools/selected-block-tools.js +105 -0
  145. package/build-module/components/block-tools/selected-block-tools.js.map +1 -0
  146. package/build-module/components/block-tools/use-selected-block-tool-props.js +50 -0
  147. package/build-module/components/block-tools/use-selected-block-tool-props.js.map +1 -0
  148. package/build-module/components/editable-text/index.js +1 -2
  149. package/build-module/components/editable-text/index.js.map +1 -1
  150. package/build-module/components/iframe/index.js +4 -3
  151. package/build-module/components/iframe/index.js.map +1 -1
  152. package/build-module/components/inserter/block-patterns-explorer/{explorer.js → index.js} +5 -5
  153. package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -0
  154. package/build-module/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +1 -1
  155. package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -0
  156. package/build-module/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +2 -2
  157. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -0
  158. package/build-module/components/inserter/block-patterns-tab/index.js +66 -0
  159. package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -0
  160. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +42 -0
  161. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -0
  162. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +100 -0
  163. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -0
  164. package/build-module/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +7 -20
  165. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -0
  166. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +47 -0
  167. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -0
  168. package/build-module/components/inserter/block-patterns-tab/utils.js +58 -0
  169. package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -0
  170. package/build-module/components/inserter/media-tab/media-list.js +9 -5
  171. package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
  172. package/build-module/components/inserter/media-tab/media-preview.js +15 -12
  173. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
  174. package/build-module/components/inserter/menu.js +4 -3
  175. package/build-module/components/inserter/menu.js.map +1 -1
  176. package/build-module/components/link-control/index.js +7 -6
  177. package/build-module/components/link-control/index.js.map +1 -1
  178. package/build-module/components/list-view/block-select-button.js +39 -0
  179. package/build-module/components/list-view/block-select-button.js.map +1 -1
  180. package/build-module/components/list-view/block.js +16 -3
  181. package/build-module/components/list-view/block.js.map +1 -1
  182. package/build-module/components/list-view/index.js +3 -2
  183. package/build-module/components/list-view/index.js.map +1 -1
  184. package/build-module/components/navigable-toolbar/index.js +69 -17
  185. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  186. package/build-module/components/provider/use-block-sync.js +1 -14
  187. package/build-module/components/provider/use-block-sync.js.map +1 -1
  188. package/build-module/components/rich-text/index.js +0 -1
  189. package/build-module/components/rich-text/index.js.map +1 -1
  190. package/build-module/components/rich-text/index.native.js +3 -1
  191. package/build-module/components/rich-text/index.native.js.map +1 -1
  192. package/build-module/components/rich-text/native/format-edit.js +38 -0
  193. package/build-module/components/rich-text/native/format-edit.js.map +1 -0
  194. package/build-module/components/rich-text/native/get-format-colors.native.js +34 -0
  195. package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -0
  196. package/build-module/components/rich-text/native/index.js +2 -0
  197. package/build-module/components/rich-text/native/index.js.map +1 -0
  198. package/build-module/components/rich-text/native/index.native.js +1148 -0
  199. package/build-module/components/rich-text/native/index.native.js.map +1 -0
  200. package/build-module/components/rich-text/native/toolbar-button-with-options.native.js +51 -0
  201. package/build-module/components/rich-text/native/toolbar-button-with-options.native.js.map +1 -0
  202. package/build-module/components/rich-text/native/use-format-types.js +104 -0
  203. package/build-module/components/rich-text/native/use-format-types.js.map +1 -0
  204. package/build-module/components/rich-text/use-paste-handler.js +2 -5
  205. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  206. package/build-module/components/url-popover/image-url-input-ui.js +2 -1
  207. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  208. package/build-module/components/writing-flow/use-tab-nav.js +7 -3
  209. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  210. package/build-module/hooks/align.js +8 -8
  211. package/build-module/hooks/align.js.map +1 -1
  212. package/build-module/hooks/align.native.js +2 -2
  213. package/build-module/hooks/align.native.js.map +1 -1
  214. package/build-module/hooks/anchor.js +5 -4
  215. package/build-module/hooks/anchor.js.map +1 -1
  216. package/build-module/hooks/background.js +17 -5
  217. package/build-module/hooks/background.js.map +1 -1
  218. package/build-module/hooks/block-hooks.js +5 -6
  219. package/build-module/hooks/block-hooks.js.map +1 -1
  220. package/build-module/hooks/block-rename-ui.js +5 -3
  221. package/build-module/hooks/block-rename-ui.js.map +1 -1
  222. package/build-module/hooks/content-lock-ui.js +3 -3
  223. package/build-module/hooks/content-lock-ui.js.map +1 -1
  224. package/build-module/hooks/custom-class-name.js +6 -5
  225. package/build-module/hooks/custom-class-name.js.map +1 -1
  226. package/build-module/hooks/custom-fields.js +4 -4
  227. package/build-module/hooks/custom-fields.js.map +1 -1
  228. package/build-module/hooks/duotone.js +10 -21
  229. package/build-module/hooks/duotone.js.map +1 -1
  230. package/build-module/hooks/layout.js +90 -86
  231. package/build-module/hooks/layout.js.map +1 -1
  232. package/build-module/hooks/position.js +11 -10
  233. package/build-module/hooks/position.js.map +1 -1
  234. package/build-module/hooks/style.js +10 -13
  235. package/build-module/hooks/style.js.map +1 -1
  236. package/build-module/hooks/utils.js +30 -1
  237. package/build-module/hooks/utils.js.map +1 -1
  238. package/build-module/private-apis.js +4 -1
  239. package/build-module/private-apis.js.map +1 -1
  240. package/build-module/store/actions.js +29 -37
  241. package/build-module/store/actions.js.map +1 -1
  242. package/build-module/store/reducer.js +17 -0
  243. package/build-module/store/reducer.js.map +1 -1
  244. package/build-module/store/selectors.js +15 -13
  245. package/build-module/store/selectors.js.map +1 -1
  246. package/build-style/style-rtl.css +16 -15
  247. package/build-style/style.css +16 -15
  248. package/package.json +31 -31
  249. package/src/components/block-heading-level-dropdown/index.js +1 -1
  250. package/src/components/block-list/index.js +4 -18
  251. package/src/components/block-list-appender/index.js +20 -4
  252. package/src/components/block-quick-navigation/index.js +11 -5
  253. package/src/components/block-styles/index.js +0 -10
  254. package/src/components/block-switcher/pattern-transformations-menu.js +20 -14
  255. package/src/components/block-toolbar/style.scss +8 -0
  256. package/src/components/block-tools/back-compat.js +1 -1
  257. package/src/components/block-tools/block-contextual-toolbar.js +11 -134
  258. package/src/components/block-tools/empty-block-inserter.js +56 -0
  259. package/src/components/block-tools/index.js +72 -16
  260. package/src/components/block-tools/selected-block-tools.js +127 -0
  261. package/src/components/block-tools/style.scss +0 -10
  262. package/src/components/block-tools/use-selected-block-tool-props.js +66 -0
  263. package/src/components/editable-text/index.js +1 -8
  264. package/src/components/iframe/index.js +4 -3
  265. package/src/components/inserter/block-patterns-explorer/{explorer.js → index.js} +4 -4
  266. package/src/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +4 -1
  267. package/src/components/inserter/block-patterns-tab/index.js +118 -0
  268. package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +48 -0
  269. package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +175 -0
  270. package/src/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +15 -21
  271. package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +96 -0
  272. package/src/components/inserter/block-patterns-tab/utils.js +76 -0
  273. package/src/components/inserter/media-tab/media-list.js +7 -7
  274. package/src/components/inserter/media-tab/media-preview.js +27 -22
  275. package/src/components/inserter/menu.js +4 -5
  276. package/src/components/link-control/README.md +2 -2
  277. package/src/components/link-control/index.js +15 -6
  278. package/src/components/link-control/style.scss +8 -5
  279. package/src/components/list-view/block-select-button.js +44 -1
  280. package/src/components/list-view/block.js +11 -11
  281. package/src/components/list-view/index.js +2 -0
  282. package/src/components/media-replace-flow/style.scss +2 -2
  283. package/src/components/navigable-toolbar/index.js +71 -25
  284. package/src/components/plain-text/README.md +3 -3
  285. package/src/components/provider/use-block-sync.js +2 -21
  286. package/src/components/rich-text/README.md +9 -8
  287. package/src/components/rich-text/index.js +0 -1
  288. package/src/components/rich-text/index.native.js +3 -1
  289. package/src/components/rich-text/native/format-edit.js +44 -0
  290. package/src/components/rich-text/native/get-format-colors.native.js +54 -0
  291. package/src/components/rich-text/native/index.js +1 -0
  292. package/src/components/rich-text/native/index.native.js +1363 -0
  293. package/src/components/rich-text/native/style.native.scss +28 -0
  294. package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +79 -0
  295. package/src/components/rich-text/native/test/index.native.js +278 -0
  296. package/src/components/rich-text/native/test/performance/rich-text.native.js +44 -0
  297. package/src/components/rich-text/native/toolbar-button-with-options.native.js +61 -0
  298. package/src/components/rich-text/native/use-format-types.js +146 -0
  299. package/src/components/rich-text/use-paste-handler.js +1 -6
  300. package/src/components/url-popover/image-url-input-ui.js +1 -0
  301. package/src/components/writing-flow/use-tab-nav.js +8 -3
  302. package/src/hooks/align.js +8 -8
  303. package/src/hooks/align.native.js +2 -2
  304. package/src/hooks/anchor.js +21 -23
  305. package/src/hooks/background.js +28 -6
  306. package/src/hooks/block-hooks.js +20 -16
  307. package/src/hooks/block-rename-ui.js +6 -4
  308. package/src/hooks/content-lock-ui.js +3 -3
  309. package/src/hooks/custom-class-name.js +7 -6
  310. package/src/hooks/custom-fields.js +5 -5
  311. package/src/hooks/duotone.js +23 -33
  312. package/src/hooks/layout.js +114 -105
  313. package/src/hooks/position.js +8 -21
  314. package/src/hooks/style.js +17 -31
  315. package/src/hooks/test/align.js +4 -4
  316. package/src/hooks/utils.js +33 -1
  317. package/src/private-apis.js +4 -1
  318. package/src/store/actions.js +26 -72
  319. package/src/store/reducer.js +19 -0
  320. package/src/store/selectors.js +13 -19
  321. package/build/components/block-tools/selected-block-popover.js +0 -221
  322. package/build/components/block-tools/selected-block-popover.js.map +0 -1
  323. package/build/components/inserter/block-patterns-explorer/explorer.js.map +0 -1
  324. package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +0 -1
  325. package/build/components/inserter/block-patterns-explorer/sidebar.js.map +0 -1
  326. package/build/components/inserter/block-patterns-filter.js.map +0 -1
  327. package/build/components/inserter/block-patterns-tab.js +0 -270
  328. package/build/components/inserter/block-patterns-tab.js.map +0 -1
  329. package/build/store/utils.js +0 -22
  330. package/build/store/utils.js.map +0 -1
  331. package/build-module/components/block-tools/selected-block-popover.js +0 -213
  332. package/build-module/components/block-tools/selected-block-popover.js.map +0 -1
  333. package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +0 -1
  334. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +0 -1
  335. package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +0 -1
  336. package/build-module/components/inserter/block-patterns-filter.js.map +0 -1
  337. package/build-module/components/inserter/block-patterns-tab.js +0 -254
  338. package/build-module/components/inserter/block-patterns-tab.js.map +0 -1
  339. package/build-module/store/utils.js +0 -16
  340. package/build-module/store/utils.js.map +0 -1
  341. package/src/components/block-tools/selected-block-popover.js +0 -265
  342. package/src/components/inserter/block-patterns-tab.js +0 -448
  343. package/src/store/utils.js +0 -12
  344. /package/src/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"names":["SVG","Path","DropdownMenu","MenuGroup","MenuItemsChoice","ExternalLink","__","Icon","useMemo","createInterpolateElement","myPatternsCategory","PATTERN_TYPES","all","synced","unsynced","user","theme","directory","SYNC_TYPES","full","getShouldDisableSyncFilter","sourceFilter","getShouldDisableNonUserSources","category","name","BlockPatternsSyncFilter","setPatternSyncFilter","setPatternSourceFilter","patternSyncFilter","patternSourceFilter","scrollContainerRef","currentPatternSourceFilter","shouldDisableSyncFilter","shouldDisableNonUserSources","patternSyncMenuOptions","value","label","disabled","patternSourceMenuOptions","handleSetSourceFilterChange","newSourceFilter","createElement","Fragment","popoverProps","placement","icon","width","height","viewBox","fill","xmlns","d","choices","onSelect","current","scrollTo","className","Link","href"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-filter.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tSVG,\n\tPath,\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItemsChoice,\n\tExternalLink,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { Icon } from '@wordpress/icons';\nimport { useMemo, createInterpolateElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { myPatternsCategory } from './block-patterns-tab';\n\nexport const PATTERN_TYPES = {\n\tall: 'all',\n\tsynced: 'synced',\n\tunsynced: 'unsynced',\n\tuser: 'user',\n\ttheme: 'theme',\n\tdirectory: 'directory',\n};\n\nexport const SYNC_TYPES = {\n\tall: 'all',\n\tfull: 'fully',\n\tunsynced: 'unsynced',\n};\n\nconst getShouldDisableSyncFilter = ( sourceFilter ) =>\n\tsourceFilter !== PATTERN_TYPES.all && sourceFilter !== PATTERN_TYPES.user;\n\nconst getShouldDisableNonUserSources = ( category ) => {\n\treturn category.name === myPatternsCategory.name;\n};\n\nexport function BlockPatternsSyncFilter( {\n\tsetPatternSyncFilter,\n\tsetPatternSourceFilter,\n\tpatternSyncFilter,\n\tpatternSourceFilter,\n\tscrollContainerRef,\n\tcategory,\n} ) {\n\t// If the category is `myPatterns` then we need to set the source filter to `user`, but\n\t// we do this by deriving from props rather than calling setPatternSourceFilter otherwise\n\t// the user may be confused when switching to another category if the haven't explicity set\n\t// this filter themselves.\n\tconst currentPatternSourceFilter =\n\t\tcategory.name === myPatternsCategory.name\n\t\t\t? PATTERN_TYPES.user\n\t\t\t: patternSourceFilter;\n\n\t// We need to disable the sync filter option if the source filter is not 'all' or 'user'\n\t// otherwise applying them will just result in no patterns being shown.\n\tconst shouldDisableSyncFilter = getShouldDisableSyncFilter(\n\t\tcurrentPatternSourceFilter\n\t);\n\n\t// We also need to disable the directory and theme source filter options if the category\n\t// is `myPatterns` otherwise applying them will also just result in no patterns being shown.\n\tconst shouldDisableNonUserSources =\n\t\tgetShouldDisableNonUserSources( category );\n\n\tconst patternSyncMenuOptions = useMemo(\n\t\t() => [\n\t\t\t{ value: SYNC_TYPES.all, label: __( 'All' ) },\n\t\t\t{\n\t\t\t\tvalue: SYNC_TYPES.full,\n\t\t\t\tlabel: __( 'Synced' ),\n\t\t\t\tdisabled: shouldDisableSyncFilter,\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: SYNC_TYPES.unsynced,\n\t\t\t\tlabel: __( 'Not synced' ),\n\t\t\t\tdisabled: shouldDisableSyncFilter,\n\t\t\t},\n\t\t],\n\t\t[ shouldDisableSyncFilter ]\n\t);\n\n\tconst patternSourceMenuOptions = useMemo(\n\t\t() => [\n\t\t\t{\n\t\t\t\tvalue: PATTERN_TYPES.all,\n\t\t\t\tlabel: __( 'All' ),\n\t\t\t\tdisabled: shouldDisableNonUserSources,\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: PATTERN_TYPES.directory,\n\t\t\t\tlabel: __( 'Pattern Directory' ),\n\t\t\t\tdisabled: shouldDisableNonUserSources,\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: PATTERN_TYPES.theme,\n\t\t\t\tlabel: __( 'Theme & Plugins' ),\n\t\t\t\tdisabled: shouldDisableNonUserSources,\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: PATTERN_TYPES.user,\n\t\t\t\tlabel: __( 'User' ),\n\t\t\t},\n\t\t],\n\t\t[ shouldDisableNonUserSources ]\n\t);\n\n\tfunction handleSetSourceFilterChange( newSourceFilter ) {\n\t\tsetPatternSourceFilter( newSourceFilter );\n\t\tif ( getShouldDisableSyncFilter( newSourceFilter ) ) {\n\t\t\tsetPatternSyncFilter( SYNC_TYPES.all );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\tpopoverProps={ {\n\t\t\t\t\tplacement: 'right-end',\n\t\t\t\t} }\n\t\t\t\tlabel=\"Filter patterns\"\n\t\t\t\ticon={\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t<SVG\n\t\t\t\t\t\t\t\twidth=\"24\"\n\t\t\t\t\t\t\t\theight=\"24\"\n\t\t\t\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Path\n\t\t\t\t\t\t\t\t\td=\"M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z\"\n\t\t\t\t\t\t\t\t\tfill=\"#1E1E1E\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</SVG>\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{ () => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<MenuGroup label={ __( 'Source' ) }>\n\t\t\t\t\t\t\t<MenuItemsChoice\n\t\t\t\t\t\t\t\tchoices={ patternSourceMenuOptions }\n\t\t\t\t\t\t\t\tonSelect={ ( value ) => {\n\t\t\t\t\t\t\t\t\thandleSetSourceFilterChange( value );\n\t\t\t\t\t\t\t\t\tscrollContainerRef.current?.scrollTo(\n\t\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\t\t0\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tvalue={ currentPatternSourceFilter }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<MenuGroup label={ __( 'Type' ) }>\n\t\t\t\t\t\t\t<MenuItemsChoice\n\t\t\t\t\t\t\t\tchoices={ patternSyncMenuOptions }\n\t\t\t\t\t\t\t\tonSelect={ ( value ) => {\n\t\t\t\t\t\t\t\t\tsetPatternSyncFilter( value );\n\t\t\t\t\t\t\t\t\tscrollContainerRef.current?.scrollTo(\n\t\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\t\t0\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tvalue={ patternSyncFilter }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<div className=\"block-editor-tool-selector__help\">\n\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Patterns are available from the <Link>WordPress.org Pattern Directory</Link>, bundled in the active theme, or created by users on this site. Only patterns created on this site can be synced.'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tLink: (\n\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/patterns/'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\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}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,GAAG,EACHC,IAAI,EACJC,YAAY,EACZC,SAAS,EACTC,eAAe,EACfC,YAAY,QACN,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,IAAI,QAAQ,kBAAkB;AACvC,SAASC,OAAO,EAAEC,wBAAwB,QAAQ,oBAAoB;;AAEt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I,EAAC,MAAM;QACXC,KAAK,EAAC;MAA4B,GAElCT,aAAA,CAACxC,IAAI;QACJkD,CAAC,EAAC,8DAA8D;QAChEF,IAAI,EAAC;MAAS,CACd,CACG;IACL,CACD;EACD,GAEC,MACDR,aAAA,CAAAC,QAAA,QACCD,aAAA,CAACtC,SAAS;IAACiC,KAAK,EAAG9B,EAAE,CAAE,QAAS;EAAG,GAClCmC,aAAA,CAACrC,eAAe;IACfgD,OAAO,EAAGd,wBAA0B;IACpCe,QAAQ,EAAKlB,KAAK,IAAM;MACvBI,2BAA2B,CAAEJ,KAAM,CAAC;MACpCL,kBAAkB,CAACwB,OAAO,EAAEC,QAAQ,CACnC,CAAC,EACD,CACD,CAAC;IACF,CAAG;IACHpB,KAAK,EAAGJ;EAA4B,CACpC,CACS,CAAC,EACZU,aAAA,CAACtC,SAAS;IAACiC,KAAK,EAAG9B,EAAE,CAAE,MAAO;EAAG,GAChCmC,aAAA,CAACrC,eAAe;IACfgD,OAAO,EAAGlB,sBAAwB;IAClCmB,QAAQ,EAAKlB,KAAK,IAAM;MACvBT,oBAAoB,CAAES,KAAM,CAAC;MAC7BL,kBAAkB,CAACwB,OAAO,EAAEC,QAAQ,CACnC,CAAC,EACD,CACD,CAAC;IACF,CAAG;IACHpB,KAAK,EAAGP;EAAmB,CAC3B,CACS,CAAC,EACZa,aAAA;IAAKe,SAAS,EAAC;EAAkC,GAC9C/C,wBAAwB,CACzBH,EAAE,CACD,gMACD,CAAC,EACD;IACCmD,IAAI,EACHhB,aAAA,CAACpC,YAAY;MACZqD,IAAI,EAAGpD,EAAE,CACR,iCACD;IAAG,CACH;EAEH,CACD,CACI,CACJ,CAEU,CACb,CAAC;AAEL"}
@@ -1,254 +0,0 @@
1
- import { createElement, Fragment } from "react";
2
- /**
3
- * WordPress dependencies
4
- */
5
- import { useMemo, useState, useCallback, useRef, useEffect } from '@wordpress/element';
6
- import { _x, __, _n, isRTL, sprintf } from '@wordpress/i18n';
7
- import { useViewportMatch } from '@wordpress/compose';
8
- import { __experimentalItemGroup as ItemGroup, __experimentalItem as Item, __experimentalHStack as HStack, __experimentalVStack as VStack, __experimentalHeading as Heading, __experimentalText as Text, FlexBlock, Button } from '@wordpress/components';
9
- import { Icon, chevronRight, chevronLeft } from '@wordpress/icons';
10
- import { focus } from '@wordpress/dom';
11
- import { speak } from '@wordpress/a11y';
12
-
13
- /**
14
- * Internal dependencies
15
- */
16
- import usePatternsState from './hooks/use-patterns-state';
17
- import BlockPatternList from '../block-patterns-list';
18
- import PatternsExplorerModal from './block-patterns-explorer/explorer';
19
- import MobileTabNavigation from './mobile-tab-navigation';
20
- import usePatternsPaging from './hooks/use-patterns-paging';
21
- import { BlockPatternsSyncFilter, SYNC_TYPES, PATTERN_TYPES } from './block-patterns-filter';
22
- const noop = () => {};
23
- export const allPatternsCategory = {
24
- name: 'allPatterns',
25
- label: __('All patterns')
26
- };
27
- export const myPatternsCategory = {
28
- name: 'myPatterns',
29
- label: __('My patterns')
30
- };
31
- export function isPatternFiltered(pattern, sourceFilter, syncFilter) {
32
- const isUserPattern = pattern.name.startsWith('core/block');
33
- const isDirectoryPattern = pattern.source === 'core' || pattern.source?.startsWith('pattern-directory');
34
-
35
- // If theme source selected, filter out user created patterns and those from
36
- // the core patterns directory.
37
- if (sourceFilter === PATTERN_TYPES.theme && (isUserPattern || isDirectoryPattern)) {
38
- return true;
39
- }
40
-
41
- // If the directory source is selected, filter out user created patterns
42
- // and those bundled with the theme.
43
- if (sourceFilter === PATTERN_TYPES.directory && (isUserPattern || !isDirectoryPattern)) {
44
- return true;
45
- }
46
-
47
- // If user source selected, filter out theme patterns. Any pattern without
48
- // an id wasn't created by a user.
49
- if (sourceFilter === PATTERN_TYPES.user && !pattern.id) {
50
- return true;
51
- }
52
-
53
- // Filter by sync status.
54
- if (syncFilter === SYNC_TYPES.full && pattern.syncStatus !== '') {
55
- return true;
56
- }
57
- if (syncFilter === SYNC_TYPES.unsynced && pattern.syncStatus !== 'unsynced' && isUserPattern) {
58
- return true;
59
- }
60
- return false;
61
- }
62
- export function usePatternsCategories(rootClientId, sourceFilter = 'all') {
63
- const [patterns, allCategories] = usePatternsState(undefined, rootClientId);
64
- const filteredPatterns = useMemo(() => sourceFilter === 'all' ? patterns : patterns.filter(pattern => !isPatternFiltered(pattern, sourceFilter)), [sourceFilter, patterns]);
65
- const hasRegisteredCategory = useCallback(pattern => {
66
- if (!pattern.categories || !pattern.categories.length) {
67
- return false;
68
- }
69
- return pattern.categories.some(cat => allCategories.some(category => category.name === cat));
70
- }, [allCategories]);
71
-
72
- // Remove any empty categories.
73
- const populatedCategories = useMemo(() => {
74
- const categories = allCategories.filter(category => filteredPatterns.some(pattern => pattern.categories?.includes(category.name))).sort((a, b) => a.label.localeCompare(b.label));
75
- if (filteredPatterns.some(pattern => !hasRegisteredCategory(pattern)) && !categories.find(category => category.name === 'uncategorized')) {
76
- categories.push({
77
- name: 'uncategorized',
78
- label: _x('Uncategorized')
79
- });
80
- }
81
- if (filteredPatterns.some(pattern => pattern.id)) {
82
- categories.unshift(myPatternsCategory);
83
- }
84
- if (filteredPatterns.length > 0) {
85
- categories.unshift({
86
- name: allPatternsCategory.name,
87
- label: allPatternsCategory.label
88
- });
89
- }
90
- speak(sprintf( /* translators: %d: number of categories . */
91
- _n('%d category button displayed.', '%d category buttons displayed.', categories.length), categories.length));
92
- return categories;
93
- }, [allCategories, filteredPatterns, hasRegisteredCategory]);
94
- return populatedCategories;
95
- }
96
- export function BlockPatternsCategoryDialog({
97
- rootClientId,
98
- onInsert,
99
- onHover,
100
- category,
101
- showTitlesAsTooltip,
102
- patternFilter
103
- }) {
104
- const container = useRef();
105
- useEffect(() => {
106
- const timeout = setTimeout(() => {
107
- const [firstTabbable] = focus.tabbable.find(container.current);
108
- firstTabbable?.focus();
109
- });
110
- return () => clearTimeout(timeout);
111
- }, [category]);
112
- return createElement("div", {
113
- ref: container,
114
- className: "block-editor-inserter__patterns-category-dialog"
115
- }, createElement(BlockPatternsCategoryPanel, {
116
- key: category.name,
117
- rootClientId: rootClientId,
118
- onInsert: onInsert,
119
- onHover: onHover,
120
- category: category,
121
- showTitlesAsTooltip: showTitlesAsTooltip,
122
- patternFilter: patternFilter
123
- }));
124
- }
125
- export function BlockPatternsCategoryPanel({
126
- rootClientId,
127
- onInsert,
128
- onHover = noop,
129
- category,
130
- showTitlesAsTooltip
131
- }) {
132
- const [allPatterns,, onClickPattern] = usePatternsState(onInsert, rootClientId);
133
- const [patternSyncFilter, setPatternSyncFilter] = useState('all');
134
- const [patternSourceFilter, setPatternSourceFilter] = useState('all');
135
- const availableCategories = usePatternsCategories(rootClientId, patternSourceFilter);
136
- const scrollContainerRef = useRef();
137
- const currentCategoryPatterns = useMemo(() => allPatterns.filter(pattern => {
138
- var _pattern$categories$f;
139
- if (isPatternFiltered(pattern, patternSourceFilter, patternSyncFilter)) {
140
- return false;
141
- }
142
- if (category.name === allPatternsCategory.name) {
143
- return true;
144
- }
145
- if (category.name === myPatternsCategory.name && pattern.id) {
146
- return true;
147
- }
148
- if (category.name !== 'uncategorized') {
149
- return pattern.categories?.includes(category.name);
150
- }
151
-
152
- // The uncategorized category should show all the patterns without any category
153
- // or with no available category.
154
- const availablePatternCategories = (_pattern$categories$f = pattern.categories?.filter(cat => availableCategories.find(availableCategory => availableCategory.name === cat))) !== null && _pattern$categories$f !== void 0 ? _pattern$categories$f : [];
155
- return availablePatternCategories.length === 0;
156
- }), [allPatterns, availableCategories, category.name, patternSourceFilter, patternSyncFilter]);
157
- const pagingProps = usePatternsPaging(currentCategoryPatterns, category, scrollContainerRef);
158
- const {
159
- changePage
160
- } = pagingProps;
161
-
162
- // Hide block pattern preview on unmount.
163
- // eslint-disable-next-line react-hooks/exhaustive-deps
164
- useEffect(() => () => onHover(null), []);
165
- const onSetPatternSyncFilter = useCallback(value => {
166
- setPatternSyncFilter(value);
167
- changePage(1);
168
- }, [setPatternSyncFilter, changePage]);
169
- const onSetPatternSourceFilter = useCallback(value => {
170
- setPatternSourceFilter(value);
171
- changePage(1);
172
- }, [setPatternSourceFilter, changePage]);
173
- return createElement("div", {
174
- className: "block-editor-inserter__patterns-category-panel"
175
- }, createElement(VStack, {
176
- spacing: 2,
177
- className: "block-editor-inserter__patterns-category-panel-header"
178
- }, createElement(HStack, null, createElement(FlexBlock, null, createElement(Heading, {
179
- level: 4,
180
- as: "div"
181
- }, category.label)), createElement(BlockPatternsSyncFilter, {
182
- patternSyncFilter: patternSyncFilter,
183
- patternSourceFilter: patternSourceFilter,
184
- setPatternSyncFilter: onSetPatternSyncFilter,
185
- setPatternSourceFilter: onSetPatternSourceFilter,
186
- scrollContainerRef: scrollContainerRef,
187
- category: category
188
- })), !currentCategoryPatterns.length && createElement(Text, {
189
- variant: "muted",
190
- className: "block-editor-inserter__patterns-category-no-results"
191
- }, __('No results found'))), currentCategoryPatterns.length > 0 && createElement(BlockPatternList, {
192
- ref: scrollContainerRef,
193
- shownPatterns: pagingProps.categoryPatternsAsyncList,
194
- blockPatterns: pagingProps.categoryPatterns,
195
- onClickPattern: onClickPattern,
196
- onHover: onHover,
197
- label: category.label,
198
- orientation: "vertical",
199
- category: category.name,
200
- isDraggable: true,
201
- showTitlesAsTooltip: showTitlesAsTooltip,
202
- patternFilter: patternSourceFilter,
203
- pagingProps: pagingProps
204
- }));
205
- }
206
- function BlockPatternsTabs({
207
- onSelectCategory,
208
- selectedCategory,
209
- onInsert,
210
- rootClientId
211
- }) {
212
- const [showPatternsExplorer, setShowPatternsExplorer] = useState(false);
213
- const categories = usePatternsCategories(rootClientId);
214
- const initialCategory = selectedCategory || categories[0];
215
- const isMobile = useViewportMatch('medium', '<');
216
- return createElement(Fragment, null, !isMobile && createElement("div", {
217
- className: "block-editor-inserter__block-patterns-tabs-container"
218
- }, createElement("nav", {
219
- "aria-label": __('Block pattern categories'),
220
- className: "block-editor-inserter__block-patterns-tabs"
221
- }, createElement(ItemGroup, {
222
- role: "list"
223
- }, categories.map(category => createElement(Item, {
224
- role: "listitem",
225
- key: category.name,
226
- onClick: () => onSelectCategory(category),
227
- className: category === selectedCategory ? 'block-editor-inserter__patterns-category block-editor-inserter__patterns-selected-category' : 'block-editor-inserter__patterns-category',
228
- "aria-label": category.label,
229
- "aria-current": category === selectedCategory ? 'true' : undefined
230
- }, createElement(HStack, null, createElement(FlexBlock, null, category.label), createElement(Icon, {
231
- icon: isRTL() ? chevronLeft : chevronRight
232
- })))), createElement("div", {
233
- role: "listitem"
234
- }, createElement(Button, {
235
- className: "block-editor-inserter__patterns-explore-button",
236
- onClick: () => setShowPatternsExplorer(true),
237
- variant: "secondary"
238
- }, __('Explore all patterns')))))), isMobile && createElement(MobileTabNavigation, {
239
- categories: categories
240
- }, category => createElement(BlockPatternsCategoryPanel, {
241
- key: category.name,
242
- onInsert: onInsert,
243
- rootClientId: rootClientId,
244
- category: category,
245
- showTitlesAsTooltip: false
246
- })), showPatternsExplorer && createElement(PatternsExplorerModal, {
247
- initialCategory: initialCategory,
248
- patternCategories: categories,
249
- onModalClose: () => setShowPatternsExplorer(false),
250
- rootClientId: rootClientId
251
- }));
252
- }
253
- export default BlockPatternsTabs;
254
- //# sourceMappingURL=block-patterns-tab.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useMemo","useState","useCallback","useRef","useEffect","_x","__","_n","isRTL","sprintf","useViewportMatch","__experimentalItemGroup","ItemGroup","__experimentalItem","Item","__experimentalHStack","HStack","__experimentalVStack","VStack","__experimentalHeading","Heading","__experimentalText","Text","FlexBlock","Button","Icon","chevronRight","chevronLeft","focus","speak","usePatternsState","BlockPatternList","PatternsExplorerModal","MobileTabNavigation","usePatternsPaging","BlockPatternsSyncFilter","SYNC_TYPES","PATTERN_TYPES","noop","allPatternsCategory","name","label","myPatternsCategory","isPatternFiltered","pattern","sourceFilter","syncFilter","isUserPattern","startsWith","isDirectoryPattern","source","theme","directory","user","id","full","syncStatus","unsynced","usePatternsCategories","rootClientId","patterns","allCategories","undefined","filteredPatterns","filter","hasRegisteredCategory","categories","length","some","cat","category","populatedCategories","includes","sort","a","b","localeCompare","find","push","unshift","BlockPatternsCategoryDialog","onInsert","onHover","showTitlesAsTooltip","patternFilter","container","timeout","setTimeout","firstTabbable","tabbable","current","clearTimeout","createElement","ref","className","BlockPatternsCategoryPanel","key","allPatterns","onClickPattern","patternSyncFilter","setPatternSyncFilter","patternSourceFilter","setPatternSourceFilter","availableCategories","scrollContainerRef","currentCategoryPatterns","_pattern$categories$f","availablePatternCategories","availableCategory","pagingProps","changePage","onSetPatternSyncFilter","value","onSetPatternSourceFilter","spacing","level","as","variant","shownPatterns","categoryPatternsAsyncList","blockPatterns","categoryPatterns","orientation","isDraggable","BlockPatternsTabs","onSelectCategory","selectedCategory","showPatternsExplorer","setShowPatternsExplorer","initialCategory","isMobile","Fragment","role","map","onClick","icon","patternCategories","onModalClose"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMemo,\n\tuseState,\n\tuseCallback,\n\tuseRef,\n\tuseEffect,\n} from '@wordpress/element';\nimport { _x, __, _n, isRTL, sprintf } from '@wordpress/i18n';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalHeading as Heading,\n\t__experimentalText as Text,\n\tFlexBlock,\n\tButton,\n} from '@wordpress/components';\nimport { Icon, chevronRight, chevronLeft } from '@wordpress/icons';\nimport { focus } from '@wordpress/dom';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport usePatternsState from './hooks/use-patterns-state';\nimport BlockPatternList from '../block-patterns-list';\nimport PatternsExplorerModal from './block-patterns-explorer/explorer';\nimport MobileTabNavigation from './mobile-tab-navigation';\nimport usePatternsPaging from './hooks/use-patterns-paging';\nimport {\n\tBlockPatternsSyncFilter,\n\tSYNC_TYPES,\n\tPATTERN_TYPES,\n} from './block-patterns-filter';\n\nconst noop = () => {};\n\nexport const allPatternsCategory = {\n\tname: 'allPatterns',\n\tlabel: __( 'All patterns' ),\n};\n\nexport const myPatternsCategory = {\n\tname: 'myPatterns',\n\tlabel: __( 'My patterns' ),\n};\n\nexport function isPatternFiltered( pattern, sourceFilter, syncFilter ) {\n\tconst isUserPattern = pattern.name.startsWith( 'core/block' );\n\tconst isDirectoryPattern =\n\t\tpattern.source === 'core' ||\n\t\tpattern.source?.startsWith( 'pattern-directory' );\n\n\t// If theme source selected, filter out user created patterns and those from\n\t// the core patterns directory.\n\tif (\n\t\tsourceFilter === PATTERN_TYPES.theme &&\n\t\t( isUserPattern || isDirectoryPattern )\n\t) {\n\t\treturn true;\n\t}\n\n\t// If the directory source is selected, filter out user created patterns\n\t// and those bundled with the theme.\n\tif (\n\t\tsourceFilter === PATTERN_TYPES.directory &&\n\t\t( isUserPattern || ! isDirectoryPattern )\n\t) {\n\t\treturn true;\n\t}\n\n\t// If user source selected, filter out theme patterns. Any pattern without\n\t// an id wasn't created by a user.\n\tif ( sourceFilter === PATTERN_TYPES.user && ! pattern.id ) {\n\t\treturn true;\n\t}\n\n\t// Filter by sync status.\n\tif ( syncFilter === SYNC_TYPES.full && pattern.syncStatus !== '' ) {\n\t\treturn true;\n\t}\n\n\tif (\n\t\tsyncFilter === SYNC_TYPES.unsynced &&\n\t\tpattern.syncStatus !== 'unsynced' &&\n\t\tisUserPattern\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nexport function usePatternsCategories( rootClientId, sourceFilter = 'all' ) {\n\tconst [ patterns, allCategories ] = usePatternsState(\n\t\tundefined,\n\t\trootClientId\n\t);\n\n\tconst filteredPatterns = useMemo(\n\t\t() =>\n\t\t\tsourceFilter === 'all'\n\t\t\t\t? patterns\n\t\t\t\t: patterns.filter(\n\t\t\t\t\t\t( pattern ) =>\n\t\t\t\t\t\t\t! isPatternFiltered( pattern, sourceFilter )\n\t\t\t\t ),\n\t\t[ sourceFilter, patterns ]\n\t);\n\n\tconst hasRegisteredCategory = useCallback(\n\t\t( pattern ) => {\n\t\t\tif ( ! pattern.categories || ! pattern.categories.length ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn pattern.categories.some( ( cat ) =>\n\t\t\t\tallCategories.some( ( category ) => category.name === cat )\n\t\t\t);\n\t\t},\n\t\t[ allCategories ]\n\t);\n\n\t// Remove any empty categories.\n\tconst populatedCategories = useMemo( () => {\n\t\tconst categories = allCategories\n\t\t\t.filter( ( category ) =>\n\t\t\t\tfilteredPatterns.some( ( pattern ) =>\n\t\t\t\t\tpattern.categories?.includes( category.name )\n\t\t\t\t)\n\t\t\t)\n\t\t\t.sort( ( a, b ) => a.label.localeCompare( b.label ) );\n\n\t\tif (\n\t\t\tfilteredPatterns.some(\n\t\t\t\t( pattern ) => ! hasRegisteredCategory( pattern )\n\t\t\t) &&\n\t\t\t! categories.find(\n\t\t\t\t( category ) => category.name === 'uncategorized'\n\t\t\t)\n\t\t) {\n\t\t\tcategories.push( {\n\t\t\t\tname: 'uncategorized',\n\t\t\t\tlabel: _x( 'Uncategorized' ),\n\t\t\t} );\n\t\t}\n\t\tif ( filteredPatterns.some( ( pattern ) => pattern.id ) ) {\n\t\t\tcategories.unshift( myPatternsCategory );\n\t\t}\n\t\tif ( filteredPatterns.length > 0 ) {\n\t\t\tcategories.unshift( {\n\t\t\t\tname: allPatternsCategory.name,\n\t\t\t\tlabel: allPatternsCategory.label,\n\t\t\t} );\n\t\t}\n\t\tspeak(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of categories . */\n\t\t\t\t_n(\n\t\t\t\t\t'%d category button displayed.',\n\t\t\t\t\t'%d category buttons displayed.',\n\t\t\t\t\tcategories.length\n\t\t\t\t),\n\t\t\t\tcategories.length\n\t\t\t)\n\t\t);\n\t\treturn categories;\n\t}, [ allCategories, filteredPatterns, hasRegisteredCategory ] );\n\n\treturn populatedCategories;\n}\n\nexport function BlockPatternsCategoryDialog( {\n\trootClientId,\n\tonInsert,\n\tonHover,\n\tcategory,\n\tshowTitlesAsTooltip,\n\tpatternFilter,\n} ) {\n\tconst container = useRef();\n\n\tuseEffect( () => {\n\t\tconst timeout = setTimeout( () => {\n\t\t\tconst [ firstTabbable ] = focus.tabbable.find( container.current );\n\t\t\tfirstTabbable?.focus();\n\t\t} );\n\t\treturn () => clearTimeout( timeout );\n\t}, [ category ] );\n\n\treturn (\n\t\t<div\n\t\t\tref={ container }\n\t\t\tclassName=\"block-editor-inserter__patterns-category-dialog\"\n\t\t>\n\t\t\t<BlockPatternsCategoryPanel\n\t\t\t\tkey={ category.name }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\tonInsert={ onInsert }\n\t\t\t\tonHover={ onHover }\n\t\t\t\tcategory={ category }\n\t\t\t\tshowTitlesAsTooltip={ showTitlesAsTooltip }\n\t\t\t\tpatternFilter={ patternFilter }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport function BlockPatternsCategoryPanel( {\n\trootClientId,\n\tonInsert,\n\tonHover = noop,\n\tcategory,\n\tshowTitlesAsTooltip,\n} ) {\n\tconst [ allPatterns, , onClickPattern ] = usePatternsState(\n\t\tonInsert,\n\t\trootClientId\n\t);\n\tconst [ patternSyncFilter, setPatternSyncFilter ] = useState( 'all' );\n\tconst [ patternSourceFilter, setPatternSourceFilter ] = useState( 'all' );\n\n\tconst availableCategories = usePatternsCategories(\n\t\trootClientId,\n\t\tpatternSourceFilter\n\t);\n\tconst scrollContainerRef = useRef();\n\tconst currentCategoryPatterns = useMemo(\n\t\t() =>\n\t\t\tallPatterns.filter( ( pattern ) => {\n\t\t\t\tif (\n\t\t\t\t\tisPatternFiltered(\n\t\t\t\t\t\tpattern,\n\t\t\t\t\t\tpatternSourceFilter,\n\t\t\t\t\t\tpatternSyncFilter\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif ( category.name === allPatternsCategory.name ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif ( category.name === myPatternsCategory.name && pattern.id ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif ( category.name !== 'uncategorized' ) {\n\t\t\t\t\treturn pattern.categories?.includes( category.name );\n\t\t\t\t}\n\n\t\t\t\t// The uncategorized category should show all the patterns without any category\n\t\t\t\t// or with no available category.\n\t\t\t\tconst availablePatternCategories =\n\t\t\t\t\tpattern.categories?.filter( ( cat ) =>\n\t\t\t\t\t\tavailableCategories.find(\n\t\t\t\t\t\t\t( availableCategory ) =>\n\t\t\t\t\t\t\t\tavailableCategory.name === cat\n\t\t\t\t\t\t)\n\t\t\t\t\t) ?? [];\n\n\t\t\t\treturn availablePatternCategories.length === 0;\n\t\t\t} ),\n\t\t[\n\t\t\tallPatterns,\n\t\t\tavailableCategories,\n\t\t\tcategory.name,\n\t\t\tpatternSourceFilter,\n\t\t\tpatternSyncFilter,\n\t\t]\n\t);\n\n\tconst pagingProps = usePatternsPaging(\n\t\tcurrentCategoryPatterns,\n\t\tcategory,\n\t\tscrollContainerRef\n\t);\n\tconst { changePage } = pagingProps;\n\n\t// Hide block pattern preview on unmount.\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\tuseEffect( () => () => onHover( null ), [] );\n\n\tconst onSetPatternSyncFilter = useCallback(\n\t\t( value ) => {\n\t\t\tsetPatternSyncFilter( value );\n\t\t\tchangePage( 1 );\n\t\t},\n\t\t[ setPatternSyncFilter, changePage ]\n\t);\n\tconst onSetPatternSourceFilter = useCallback(\n\t\t( value ) => {\n\t\t\tsetPatternSourceFilter( value );\n\t\t\tchangePage( 1 );\n\t\t},\n\t\t[ setPatternSourceFilter, changePage ]\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-inserter__patterns-category-panel\">\n\t\t\t<VStack\n\t\t\t\tspacing={ 2 }\n\t\t\t\tclassName=\"block-editor-inserter__patterns-category-panel-header\"\n\t\t\t>\n\t\t\t\t<HStack>\n\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t<Heading level={ 4 } as=\"div\">\n\t\t\t\t\t\t\t{ category.label }\n\t\t\t\t\t\t</Heading>\n\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t<BlockPatternsSyncFilter\n\t\t\t\t\t\tpatternSyncFilter={ patternSyncFilter }\n\t\t\t\t\t\tpatternSourceFilter={ patternSourceFilter }\n\t\t\t\t\t\tsetPatternSyncFilter={ onSetPatternSyncFilter }\n\t\t\t\t\t\tsetPatternSourceFilter={ onSetPatternSourceFilter }\n\t\t\t\t\t\tscrollContainerRef={ scrollContainerRef }\n\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t\t{ ! currentCategoryPatterns.length && (\n\t\t\t\t\t<Text\n\t\t\t\t\t\tvariant=\"muted\"\n\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-category-no-results\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'No results found' ) }\n\t\t\t\t\t</Text>\n\t\t\t\t) }\n\t\t\t</VStack>\n\n\t\t\t{ currentCategoryPatterns.length > 0 && (\n\t\t\t\t<BlockPatternList\n\t\t\t\t\tref={ scrollContainerRef }\n\t\t\t\t\tshownPatterns={ pagingProps.categoryPatternsAsyncList }\n\t\t\t\t\tblockPatterns={ pagingProps.categoryPatterns }\n\t\t\t\t\tonClickPattern={ onClickPattern }\n\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\tlabel={ category.label }\n\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\tcategory={ category.name }\n\t\t\t\t\tisDraggable\n\t\t\t\t\tshowTitlesAsTooltip={ showTitlesAsTooltip }\n\t\t\t\t\tpatternFilter={ patternSourceFilter }\n\t\t\t\t\tpagingProps={ pagingProps }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction BlockPatternsTabs( {\n\tonSelectCategory,\n\tselectedCategory,\n\tonInsert,\n\trootClientId,\n} ) {\n\tconst [ showPatternsExplorer, setShowPatternsExplorer ] = useState( false );\n\n\tconst categories = usePatternsCategories( rootClientId );\n\n\tconst initialCategory = selectedCategory || categories[ 0 ];\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\treturn (\n\t\t<>\n\t\t\t{ ! isMobile && (\n\t\t\t\t<div className=\"block-editor-inserter__block-patterns-tabs-container\">\n\t\t\t\t\t<nav\n\t\t\t\t\t\taria-label={ __( 'Block pattern categories' ) }\n\t\t\t\t\t\tclassName=\"block-editor-inserter__block-patterns-tabs\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<ItemGroup role=\"list\">\n\t\t\t\t\t\t\t{ categories.map( ( category ) => (\n\t\t\t\t\t\t\t\t<Item\n\t\t\t\t\t\t\t\t\trole=\"listitem\"\n\t\t\t\t\t\t\t\t\tkey={ category.name }\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\tonSelectCategory( category )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\tcategory === selectedCategory\n\t\t\t\t\t\t\t\t\t\t\t? 'block-editor-inserter__patterns-category block-editor-inserter__patterns-selected-category'\n\t\t\t\t\t\t\t\t\t\t\t: 'block-editor-inserter__patterns-category'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\taria-label={ category.label }\n\t\t\t\t\t\t\t\t\taria-current={\n\t\t\t\t\t\t\t\t\t\tcategory === selectedCategory\n\t\t\t\t\t\t\t\t\t\t\t? 'true'\n\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<HStack>\n\t\t\t\t\t\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t\t\t\t\t\t{ category.label }\n\t\t\t\t\t\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tisRTL()\n\t\t\t\t\t\t\t\t\t\t\t\t\t? chevronLeft\n\t\t\t\t\t\t\t\t\t\t\t\t\t: chevronRight\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t</Item>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t<div role=\"listitem\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-explore-button\"\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\tsetShowPatternsExplorer( true )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Explore all patterns' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t</nav>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ isMobile && (\n\t\t\t\t<MobileTabNavigation categories={ categories }>\n\t\t\t\t\t{ ( category ) => (\n\t\t\t\t\t\t<BlockPatternsCategoryPanel\n\t\t\t\t\t\t\tkey={ category.name }\n\t\t\t\t\t\t\tonInsert={ onInsert }\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t\t\tshowTitlesAsTooltip={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</MobileTabNavigation>\n\t\t\t) }\n\t\t\t{ showPatternsExplorer && (\n\t\t\t\t<PatternsExplorerModal\n\t\t\t\t\tinitialCategory={ initialCategory }\n\t\t\t\t\tpatternCategories={ categories }\n\t\t\t\t\tonModalClose={ () => setShowPatternsExplorer( false ) }\n\t\t\t\t\trootClientId={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A,YAAc;IAC7BW,QAAQ,EAAGA,QAAU;IACrBa,mBAAmB,EAAG;EAAO,CAC7B,CAEkB,CACrB,EACC4C,oBAAoB,IACrBnC,aAAA,CAAC5D,qBAAqB;IACrBiG,eAAe,EAAGA,eAAiB;IACnCO,iBAAiB,EAAGtE,UAAY;IAChCuE,YAAY,EAAGA,CAAA,KAAMT,uBAAuB,CAAE,KAAM,CAAG;IACvDrE,YAAY,EAAGA;EAAc,CAC7B,CAED,CAAC;AAEL;AAEA,eAAeiE,iBAAiB"}
@@ -1,16 +0,0 @@
1
- /**
2
- * Helper function that maps attribute definition properties to the
3
- * ones used by RichText utils like `create, toHTMLString, etc..`.
4
- *
5
- * @param {Object} attributeDefinition A block's attribute definition object.
6
- * @return {Object} The mapped object.
7
- */
8
- export function mapRichTextSettings(attributeDefinition) {
9
- const {
10
- __unstablePreserveWhiteSpace: preserveWhiteSpace
11
- } = attributeDefinition;
12
- return {
13
- preserveWhiteSpace
14
- };
15
- }
16
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["mapRichTextSettings","attributeDefinition","__unstablePreserveWhiteSpace","preserveWhiteSpace"],"sources":["@wordpress/block-editor/src/store/utils.js"],"sourcesContent":["/**\n * Helper function that maps attribute definition properties to the\n * ones used by RichText utils like `create, toHTMLString, etc..`.\n *\n * @param {Object} attributeDefinition A block's attribute definition object.\n * @return {Object} The mapped object.\n */\nexport function mapRichTextSettings( attributeDefinition ) {\n\tconst { __unstablePreserveWhiteSpace: preserveWhiteSpace } =\n\t\tattributeDefinition;\n\treturn { preserveWhiteSpace };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,mBAAmBA,CAAEC,mBAAmB,EAAG;EAC1D,MAAM;IAAEC,4BAA4B,EAAEC;EAAmB,CAAC,GACzDF,mBAAmB;EACpB,OAAO;IAAEE;EAAmB,CAAC;AAC9B"}
@@ -1,265 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import classnames from 'classnames';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { useRef, useEffect } from '@wordpress/element';
10
- import { isUnmodifiedDefaultBlock } from '@wordpress/blocks';
11
- import { useDispatch, useSelect } from '@wordpress/data';
12
- import { useShortcut } from '@wordpress/keyboard-shortcuts';
13
-
14
- /**
15
- * Internal dependencies
16
- */
17
- import BlockSelectionButton from './block-selection-button';
18
- import BlockContextualToolbar from './block-contextual-toolbar';
19
- import { store as blockEditorStore } from '../../store';
20
- import BlockPopover from '../block-popover';
21
- import useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';
22
- import Inserter from '../inserter';
23
- import { useShouldContextualToolbarShow } from '../../utils/use-should-contextual-toolbar-show';
24
-
25
- function selector( select ) {
26
- const {
27
- __unstableGetEditorMode,
28
- hasMultiSelection,
29
- isTyping,
30
- getLastMultiSelectedBlockClientId,
31
- } = select( blockEditorStore );
32
-
33
- return {
34
- editorMode: __unstableGetEditorMode(),
35
- hasMultiSelection: hasMultiSelection(),
36
- isTyping: isTyping(),
37
- lastClientId: hasMultiSelection()
38
- ? getLastMultiSelectedBlockClientId()
39
- : null,
40
- };
41
- }
42
-
43
- function SelectedBlockPopover( {
44
- clientId,
45
- rootClientId,
46
- isEmptyDefaultBlock,
47
- capturingClientId,
48
- __unstablePopoverSlot,
49
- __unstableContentRef,
50
- } ) {
51
- const { editorMode, hasMultiSelection, isTyping, lastClientId } = useSelect(
52
- selector,
53
- []
54
- );
55
-
56
- const isInsertionPointVisible = useSelect(
57
- ( select ) => {
58
- const {
59
- isBlockInsertionPointVisible,
60
- getBlockInsertionPoint,
61
- getBlockOrder,
62
- } = select( blockEditorStore );
63
-
64
- if ( ! isBlockInsertionPointVisible() ) {
65
- return false;
66
- }
67
-
68
- const insertionPoint = getBlockInsertionPoint();
69
- const order = getBlockOrder( insertionPoint.rootClientId );
70
- return order[ insertionPoint.index ] === clientId;
71
- },
72
- [ clientId ]
73
- );
74
- const isToolbarForced = useRef( false );
75
- const { shouldShowContextualToolbar, canFocusHiddenToolbar } =
76
- useShouldContextualToolbarShow();
77
-
78
- const { stopTyping } = useDispatch( blockEditorStore );
79
-
80
- const showEmptyBlockSideInserter =
81
- ! isTyping && editorMode === 'edit' && isEmptyDefaultBlock;
82
- const shouldShowBreadcrumb =
83
- ! hasMultiSelection &&
84
- ( editorMode === 'navigation' || editorMode === 'zoom-out' );
85
-
86
- useShortcut(
87
- 'core/block-editor/focus-toolbar',
88
- () => {
89
- isToolbarForced.current = true;
90
- stopTyping( true );
91
- },
92
- {
93
- isDisabled: ! canFocusHiddenToolbar,
94
- }
95
- );
96
-
97
- useEffect( () => {
98
- isToolbarForced.current = false;
99
- } );
100
-
101
- // Stores the active toolbar item index so the block toolbar can return focus
102
- // to it when re-mounting.
103
- const initialToolbarItemIndexRef = useRef();
104
-
105
- useEffect( () => {
106
- // Resets the index whenever the active block changes so this is not
107
- // persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
108
- initialToolbarItemIndexRef.current = undefined;
109
- }, [ clientId ] );
110
-
111
- const popoverProps = useBlockToolbarPopoverProps( {
112
- contentElement: __unstableContentRef?.current,
113
- clientId,
114
- } );
115
-
116
- if ( showEmptyBlockSideInserter ) {
117
- return (
118
- <BlockPopover
119
- clientId={ capturingClientId || clientId }
120
- __unstableCoverTarget
121
- bottomClientId={ lastClientId }
122
- className={ classnames(
123
- 'block-editor-block-list__block-side-inserter-popover',
124
- {
125
- 'is-insertion-point-visible': isInsertionPointVisible,
126
- }
127
- ) }
128
- __unstablePopoverSlot={ __unstablePopoverSlot }
129
- __unstableContentRef={ __unstableContentRef }
130
- resize={ false }
131
- shift={ false }
132
- { ...popoverProps }
133
- >
134
- <div className="block-editor-block-list__empty-block-inserter">
135
- <Inserter
136
- position="bottom right"
137
- rootClientId={ rootClientId }
138
- clientId={ clientId }
139
- __experimentalIsQuick
140
- />
141
- </div>
142
- </BlockPopover>
143
- );
144
- }
145
-
146
- if ( shouldShowBreadcrumb || shouldShowContextualToolbar ) {
147
- return (
148
- <BlockPopover
149
- clientId={ capturingClientId || clientId }
150
- bottomClientId={ lastClientId }
151
- className={ classnames(
152
- 'block-editor-block-list__block-popover',
153
- {
154
- 'is-insertion-point-visible': isInsertionPointVisible,
155
- }
156
- ) }
157
- __unstablePopoverSlot={ __unstablePopoverSlot }
158
- __unstableContentRef={ __unstableContentRef }
159
- resize={ false }
160
- { ...popoverProps }
161
- >
162
- { shouldShowContextualToolbar && (
163
- <BlockContextualToolbar
164
- // If the toolbar is being shown because of being forced
165
- // it should focus the toolbar right after the mount.
166
- focusOnMount={ isToolbarForced.current }
167
- __experimentalInitialIndex={
168
- initialToolbarItemIndexRef.current
169
- }
170
- __experimentalOnIndexChange={ ( index ) => {
171
- initialToolbarItemIndexRef.current = index;
172
- } }
173
- // Resets the index whenever the active block changes so
174
- // this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
175
- key={ clientId }
176
- />
177
- ) }
178
- { shouldShowBreadcrumb && (
179
- <BlockSelectionButton
180
- clientId={ clientId }
181
- rootClientId={ rootClientId }
182
- />
183
- ) }
184
- </BlockPopover>
185
- );
186
- }
187
-
188
- return null;
189
- }
190
-
191
- function wrapperSelector( select ) {
192
- const {
193
- getSelectedBlockClientId,
194
- getFirstMultiSelectedBlockClientId,
195
- getBlockRootClientId,
196
- getBlock,
197
- getBlockParents,
198
- __experimentalGetBlockListSettingsForBlocks,
199
- } = select( blockEditorStore );
200
-
201
- const clientId =
202
- getSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();
203
-
204
- if ( ! clientId ) {
205
- return;
206
- }
207
-
208
- const { name, attributes = {} } = getBlock( clientId ) || {};
209
- const blockParentsClientIds = getBlockParents( clientId );
210
-
211
- // Get Block List Settings for all ancestors of the current Block clientId.
212
- const parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(
213
- blockParentsClientIds
214
- );
215
-
216
- // Get the clientId of the topmost parent with the capture toolbars setting.
217
- const capturingClientId = blockParentsClientIds.find(
218
- ( parentClientId ) =>
219
- parentBlockListSettings[ parentClientId ]
220
- ?.__experimentalCaptureToolbars
221
- );
222
-
223
- return {
224
- clientId,
225
- rootClientId: getBlockRootClientId( clientId ),
226
- name,
227
- isEmptyDefaultBlock:
228
- name && isUnmodifiedDefaultBlock( { name, attributes } ),
229
- capturingClientId,
230
- };
231
- }
232
-
233
- export default function WrappedBlockPopover( {
234
- __unstablePopoverSlot,
235
- __unstableContentRef,
236
- } ) {
237
- const selected = useSelect( wrapperSelector, [] );
238
-
239
- if ( ! selected ) {
240
- return null;
241
- }
242
-
243
- const {
244
- clientId,
245
- rootClientId,
246
- name,
247
- isEmptyDefaultBlock,
248
- capturingClientId,
249
- } = selected;
250
-
251
- if ( ! name ) {
252
- return null;
253
- }
254
-
255
- return (
256
- <SelectedBlockPopover
257
- clientId={ clientId }
258
- rootClientId={ rootClientId }
259
- isEmptyDefaultBlock={ isEmptyDefaultBlock }
260
- capturingClientId={ capturingClientId }
261
- __unstablePopoverSlot={ __unstablePopoverSlot }
262
- __unstableContentRef={ __unstableContentRef }
263
- />
264
- );
265
- }