@wordpress/editor 14.3.0 → 14.4.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 (400) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +2 -1
  3. package/build/bindings/api.js +65 -0
  4. package/build/bindings/api.js.map +1 -0
  5. package/build/bindings/pattern-overrides.js +23 -13
  6. package/build/bindings/pattern-overrides.js.map +1 -1
  7. package/build/bindings/post-meta.js +23 -12
  8. package/build/bindings/post-meta.js.map +1 -1
  9. package/build/components/block-settings-menu/content-only-settings-menu.js +4 -1
  10. package/build/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
  11. package/build/components/blog-title/index.js +6 -2
  12. package/build/components/blog-title/index.js.map +1 -1
  13. package/build/components/collapsible-block-toolbar/index.js +2 -3
  14. package/build/components/collapsible-block-toolbar/index.js.map +1 -1
  15. package/build/components/global-styles-provider/index.js +15 -3
  16. package/build/components/global-styles-provider/index.js.map +1 -1
  17. package/build/components/header/back-button.js +7 -8
  18. package/build/components/header/back-button.js.map +1 -1
  19. package/build/components/header/index.js +19 -17
  20. package/build/components/header/index.js.map +1 -1
  21. package/build/components/page-attributes/order.js +1 -67
  22. package/build/components/page-attributes/order.js.map +1 -1
  23. package/build/components/page-attributes/panel.js +1 -4
  24. package/build/components/page-attributes/panel.js.map +1 -1
  25. package/build/components/post-actions/actions.js +126 -33
  26. package/build/components/post-actions/actions.js.map +1 -1
  27. package/build/components/post-card-panel/index.js +8 -2
  28. package/build/components/post-card-panel/index.js.map +1 -1
  29. package/build/components/post-comments/index.js +1 -1
  30. package/build/components/post-comments/index.js.map +1 -1
  31. package/build/components/post-content-information/index.js +7 -1
  32. package/build/components/post-content-information/index.js.map +1 -1
  33. package/build/components/post-discussion/panel.js +2 -2
  34. package/build/components/post-discussion/panel.js.map +1 -1
  35. package/build/components/post-excerpt/panel.js +1 -1
  36. package/build/components/post-excerpt/panel.js.map +1 -1
  37. package/build/components/post-featured-image/index.js +3 -1
  38. package/build/components/post-featured-image/index.js.map +1 -1
  39. package/build/components/post-last-revision/index.js +2 -1
  40. package/build/components/post-last-revision/index.js.map +1 -1
  41. package/build/components/post-publish-button/index.js +4 -11
  42. package/build/components/post-publish-button/index.js.map +1 -1
  43. package/build/components/post-publish-panel/maybe-category-panel.js +4 -1
  44. package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  45. package/build/components/post-publish-panel/maybe-tags-panel.js +2 -1
  46. package/build/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  47. package/build/components/post-status/index.js +30 -10
  48. package/build/components/post-status/index.js.map +1 -1
  49. package/build/components/post-taxonomies/flat-term-selector.js +17 -6
  50. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  51. package/build/components/post-taxonomies/index.js +7 -1
  52. package/build/components/post-taxonomies/index.js.map +1 -1
  53. package/build/components/post-template/block-theme.js +4 -4
  54. package/build/components/post-template/block-theme.js.map +1 -1
  55. package/build/components/post-template/classic-theme.js +8 -2
  56. package/build/components/post-template/classic-theme.js.map +1 -1
  57. package/build/components/post-template/create-new-template.js +4 -1
  58. package/build/components/post-template/create-new-template.js.map +1 -1
  59. package/build/components/post-template/hooks.js +5 -1
  60. package/build/components/post-template/hooks.js.map +1 -1
  61. package/build/components/post-template/panel.js +8 -2
  62. package/build/components/post-template/panel.js.map +1 -1
  63. package/build/components/post-trash/check.js +6 -4
  64. package/build/components/post-trash/check.js.map +1 -1
  65. package/build/components/post-url/panel.js +6 -2
  66. package/build/components/post-url/panel.js.map +1 -1
  67. package/build/components/posts-per-page/index.js +6 -2
  68. package/build/components/posts-per-page/index.js.map +1 -1
  69. package/build/components/provider/use-block-editor-settings.js +15 -6
  70. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  71. package/build/components/save-publish-panels/index.js +1 -2
  72. package/build/components/save-publish-panels/index.js.map +1 -1
  73. package/build/components/sidebar/index.js +3 -9
  74. package/build/components/sidebar/index.js.map +1 -1
  75. package/build/components/site-discussion/index.js +7 -3
  76. package/build/components/site-discussion/index.js.map +1 -1
  77. package/build/components/template-content-panel/index.js +5 -5
  78. package/build/components/template-content-panel/index.js.map +1 -1
  79. package/build/components/visual-editor/edit-template-blocks-notification.js +4 -4
  80. package/build/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
  81. package/build/components/visual-editor/index.js +5 -2
  82. package/build/components/visual-editor/index.js.map +1 -1
  83. package/build/{hooks → components/visual-editor}/use-select-nearest-editable-block.js +1 -1
  84. package/build/components/visual-editor/use-select-nearest-editable-block.js.map +1 -0
  85. package/build/dataviews/actions/delete-post.js +2 -0
  86. package/build/dataviews/actions/delete-post.js.map +1 -1
  87. package/build/hooks/pattern-overrides.js +1 -1
  88. package/build/hooks/pattern-overrides.js.map +1 -1
  89. package/build/index.js +0 -1
  90. package/build/index.js.map +1 -1
  91. package/build/private-apis.js +3 -0
  92. package/build/private-apis.js.map +1 -1
  93. package/build/utils/media-upload/index.js +35 -2
  94. package/build/utils/media-upload/index.js.map +1 -1
  95. package/build-module/bindings/api.js +57 -0
  96. package/build-module/bindings/api.js.map +1 -0
  97. package/build-module/bindings/pattern-overrides.js +23 -13
  98. package/build-module/bindings/pattern-overrides.js.map +1 -1
  99. package/build-module/bindings/post-meta.js +23 -12
  100. package/build-module/bindings/post-meta.js.map +1 -1
  101. package/build-module/components/block-settings-menu/content-only-settings-menu.js +4 -1
  102. package/build-module/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
  103. package/build-module/components/blog-title/index.js +6 -2
  104. package/build-module/components/blog-title/index.js.map +1 -1
  105. package/build-module/components/collapsible-block-toolbar/index.js +1 -2
  106. package/build-module/components/collapsible-block-toolbar/index.js.map +1 -1
  107. package/build-module/components/global-styles-provider/index.js +15 -3
  108. package/build-module/components/global-styles-provider/index.js.map +1 -1
  109. package/build-module/components/header/back-button.js +5 -7
  110. package/build-module/components/header/back-button.js.map +1 -1
  111. package/build-module/components/header/index.js +19 -19
  112. package/build-module/components/header/index.js.map +1 -1
  113. package/build-module/components/page-attributes/order.js +4 -70
  114. package/build-module/components/page-attributes/order.js.map +1 -1
  115. package/build-module/components/page-attributes/panel.js +1 -6
  116. package/build-module/components/page-attributes/panel.js.map +1 -1
  117. package/build-module/components/post-actions/actions.js +127 -34
  118. package/build-module/components/post-actions/actions.js.map +1 -1
  119. package/build-module/components/post-card-panel/index.js +8 -2
  120. package/build-module/components/post-card-panel/index.js.map +1 -1
  121. package/build-module/components/post-comments/index.js +2 -2
  122. package/build-module/components/post-comments/index.js.map +1 -1
  123. package/build-module/components/post-content-information/index.js +7 -1
  124. package/build-module/components/post-content-information/index.js.map +1 -1
  125. package/build-module/components/post-discussion/panel.js +3 -3
  126. package/build-module/components/post-discussion/panel.js.map +1 -1
  127. package/build-module/components/post-excerpt/panel.js +1 -1
  128. package/build-module/components/post-excerpt/panel.js.map +1 -1
  129. package/build-module/components/post-featured-image/index.js +3 -1
  130. package/build-module/components/post-featured-image/index.js.map +1 -1
  131. package/build-module/components/post-last-revision/index.js +2 -1
  132. package/build-module/components/post-last-revision/index.js.map +1 -1
  133. package/build-module/components/post-publish-button/index.js +4 -11
  134. package/build-module/components/post-publish-button/index.js.map +1 -1
  135. package/build-module/components/post-publish-panel/maybe-category-panel.js +4 -1
  136. package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  137. package/build-module/components/post-publish-panel/maybe-tags-panel.js +2 -1
  138. package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  139. package/build-module/components/post-status/index.js +30 -10
  140. package/build-module/components/post-status/index.js.map +1 -1
  141. package/build-module/components/post-taxonomies/flat-term-selector.js +17 -6
  142. package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
  143. package/build-module/components/post-taxonomies/index.js +7 -1
  144. package/build-module/components/post-taxonomies/index.js.map +1 -1
  145. package/build-module/components/post-template/block-theme.js +4 -4
  146. package/build-module/components/post-template/block-theme.js.map +1 -1
  147. package/build-module/components/post-template/classic-theme.js +8 -2
  148. package/build-module/components/post-template/classic-theme.js.map +1 -1
  149. package/build-module/components/post-template/create-new-template.js +4 -1
  150. package/build-module/components/post-template/create-new-template.js.map +1 -1
  151. package/build-module/components/post-template/hooks.js +5 -1
  152. package/build-module/components/post-template/hooks.js.map +1 -1
  153. package/build-module/components/post-template/panel.js +8 -2
  154. package/build-module/components/post-template/panel.js.map +1 -1
  155. package/build-module/components/post-trash/check.js +6 -4
  156. package/build-module/components/post-trash/check.js.map +1 -1
  157. package/build-module/components/post-url/panel.js +6 -2
  158. package/build-module/components/post-url/panel.js.map +1 -1
  159. package/build-module/components/posts-per-page/index.js +6 -2
  160. package/build-module/components/posts-per-page/index.js.map +1 -1
  161. package/build-module/components/provider/use-block-editor-settings.js +15 -6
  162. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  163. package/build-module/components/save-publish-panels/index.js +1 -2
  164. package/build-module/components/save-publish-panels/index.js.map +1 -1
  165. package/build-module/components/sidebar/index.js +3 -9
  166. package/build-module/components/sidebar/index.js.map +1 -1
  167. package/build-module/components/site-discussion/index.js +8 -4
  168. package/build-module/components/site-discussion/index.js.map +1 -1
  169. package/build-module/components/template-content-panel/index.js +5 -5
  170. package/build-module/components/template-content-panel/index.js.map +1 -1
  171. package/build-module/components/visual-editor/edit-template-blocks-notification.js +4 -4
  172. package/build-module/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
  173. package/build-module/components/visual-editor/index.js +5 -2
  174. package/build-module/components/visual-editor/index.js.map +1 -1
  175. package/build-module/{hooks → components/visual-editor}/use-select-nearest-editable-block.js +1 -1
  176. package/build-module/components/visual-editor/use-select-nearest-editable-block.js.map +1 -0
  177. package/build-module/dataviews/actions/delete-post.js +2 -0
  178. package/build-module/dataviews/actions/delete-post.js.map +1 -1
  179. package/build-module/hooks/pattern-overrides.js +1 -1
  180. package/build-module/hooks/pattern-overrides.js.map +1 -1
  181. package/build-module/index.js +0 -1
  182. package/build-module/index.js.map +1 -1
  183. package/build-module/private-apis.js +3 -0
  184. package/build-module/private-apis.js.map +1 -1
  185. package/build-module/utils/media-upload/index.js +36 -3
  186. package/build-module/utils/media-upload/index.js.map +1 -1
  187. package/build-style/style-rtl.css +78 -42
  188. package/build-style/style.css +78 -42
  189. package/build-types/bindings/api.d.ts +25 -0
  190. package/build-types/bindings/api.d.ts.map +1 -0
  191. package/build-types/bindings/pattern-overrides.d.ts +5 -6
  192. package/build-types/bindings/pattern-overrides.d.ts.map +1 -1
  193. package/build-types/bindings/post-meta.d.ts +5 -7
  194. package/build-types/bindings/post-meta.d.ts.map +1 -1
  195. package/build-types/components/autocompleters/user.d.ts +2 -2
  196. package/build-types/components/autocompleters/user.d.ts.map +1 -1
  197. package/build-types/components/block-settings-menu/plugin-block-settings-menu-item.d.ts.map +1 -1
  198. package/build-types/components/blog-title/index.d.ts.map +1 -1
  199. package/build-types/components/collapsible-block-toolbar/index.d.ts +1 -2
  200. package/build-types/components/collapsible-block-toolbar/index.d.ts.map +1 -1
  201. package/build-types/components/document-bar/index.d.ts.map +1 -1
  202. package/build-types/components/document-outline/check.d.ts.map +1 -1
  203. package/build-types/components/document-outline/index.d.ts.map +1 -1
  204. package/build-types/components/editor-history/redo.d.ts +1 -1
  205. package/build-types/components/editor-history/undo.d.ts +1 -1
  206. package/build-types/components/editor-notices/index.d.ts.map +1 -1
  207. package/build-types/components/editor-snackbars/index.d.ts.map +1 -1
  208. package/build-types/components/entities-saved-states/index.d.ts.map +1 -1
  209. package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
  210. package/build-types/components/header/back-button.d.ts +1 -0
  211. package/build-types/components/header/back-button.d.ts.map +1 -1
  212. package/build-types/components/header/index.d.ts.map +1 -1
  213. package/build-types/components/local-autosave-monitor/index.d.ts.map +1 -1
  214. package/build-types/components/media-categories/index.d.ts.map +1 -1
  215. package/build-types/components/more-menu/tools-more-menu-group.d.ts.map +1 -1
  216. package/build-types/components/more-menu/view-more-menu-group.d.ts.map +1 -1
  217. package/build-types/components/page-attributes/check.d.ts.map +1 -1
  218. package/build-types/components/page-attributes/order.d.ts +1 -1
  219. package/build-types/components/page-attributes/order.d.ts.map +1 -1
  220. package/build-types/components/page-attributes/panel.d.ts.map +1 -1
  221. package/build-types/components/page-attributes/parent.d.ts.map +1 -1
  222. package/build-types/components/plugin-document-setting-panel/index.d.ts.map +1 -1
  223. package/build-types/components/plugin-post-publish-panel/index.d.ts.map +1 -1
  224. package/build-types/components/plugin-post-status-info/index.d.ts.map +1 -1
  225. package/build-types/components/plugin-pre-publish-panel/index.d.ts.map +1 -1
  226. package/build-types/components/plugin-sidebar/index.d.ts.map +1 -1
  227. package/build-types/components/plugin-sidebar-more-menu-item/index.d.ts.map +1 -1
  228. package/build-types/components/post-actions/actions.d.ts.map +1 -1
  229. package/build-types/components/post-author/check.d.ts.map +1 -1
  230. package/build-types/components/post-author/index.d.ts.map +1 -1
  231. package/build-types/components/post-author/panel.d.ts.map +1 -1
  232. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  233. package/build-types/components/post-content-information/index.d.ts.map +1 -1
  234. package/build-types/components/post-discussion/panel.d.ts.map +1 -1
  235. package/build-types/components/post-excerpt/check.d.ts.map +1 -1
  236. package/build-types/components/post-excerpt/index.d.ts.map +1 -1
  237. package/build-types/components/post-excerpt/panel.d.ts.map +1 -1
  238. package/build-types/components/post-excerpt/plugin.d.ts.map +1 -1
  239. package/build-types/components/post-featured-image/check.d.ts.map +1 -1
  240. package/build-types/components/post-featured-image/panel.d.ts.map +1 -1
  241. package/build-types/components/post-format/index.d.ts.map +1 -1
  242. package/build-types/components/post-format/panel.d.ts.map +1 -1
  243. package/build-types/components/post-last-revision/check.d.ts.map +1 -1
  244. package/build-types/components/post-last-revision/index.d.ts.map +1 -1
  245. package/build-types/components/post-last-revision/panel.d.ts.map +1 -1
  246. package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
  247. package/build-types/components/post-pending-status/check.d.ts.map +1 -1
  248. package/build-types/components/post-pending-status/index.d.ts.map +1 -1
  249. package/build-types/components/post-preview-button/index.d.ts.map +1 -1
  250. package/build-types/components/post-publish-button/index.d.ts.map +1 -1
  251. package/build-types/components/post-publish-panel/maybe-category-panel.d.ts.map +1 -1
  252. package/build-types/components/post-saved-state/index.d.ts +1 -1
  253. package/build-types/components/post-saved-state/index.d.ts.map +1 -1
  254. package/build-types/components/post-schedule/check.d.ts.map +1 -1
  255. package/build-types/components/post-schedule/index.d.ts.map +1 -1
  256. package/build-types/components/post-schedule/label.d.ts.map +1 -1
  257. package/build-types/components/post-schedule/panel.d.ts.map +1 -1
  258. package/build-types/components/post-slug/check.d.ts.map +1 -1
  259. package/build-types/components/post-slug/index.d.ts.map +1 -1
  260. package/build-types/components/post-status/index.d.ts.map +1 -1
  261. package/build-types/components/post-sticky/check.d.ts.map +1 -1
  262. package/build-types/components/post-sticky/index.d.ts.map +1 -1
  263. package/build-types/components/post-switch-to-draft-button/index.d.ts.map +1 -1
  264. package/build-types/components/post-sync-status/index.d.ts.map +1 -1
  265. package/build-types/components/post-taxonomies/check.d.ts.map +1 -1
  266. package/build-types/components/post-taxonomies/flat-term-selector.d.ts +9 -7
  267. package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -1
  268. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +13 -11
  269. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
  270. package/build-types/components/post-taxonomies/index.d.ts.map +1 -1
  271. package/build-types/components/post-template/block-theme.d.ts.map +1 -1
  272. package/build-types/components/post-template/classic-theme.d.ts.map +1 -1
  273. package/build-types/components/post-template/create-new-template.d.ts.map +1 -1
  274. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  275. package/build-types/components/post-template/panel.d.ts.map +1 -1
  276. package/build-types/components/post-text-editor/index.d.ts.map +1 -1
  277. package/build-types/components/post-trash/check.d.ts.map +1 -1
  278. package/build-types/components/post-trash/index.d.ts.map +1 -1
  279. package/build-types/components/post-type-support-check/index.d.ts.map +1 -1
  280. package/build-types/components/post-url/check.d.ts.map +1 -1
  281. package/build-types/components/post-url/index.d.ts.map +1 -1
  282. package/build-types/components/post-url/label.d.ts.map +1 -1
  283. package/build-types/components/post-url/panel.d.ts.map +1 -1
  284. package/build-types/components/post-visibility/check.d.ts.map +1 -1
  285. package/build-types/components/post-visibility/index.d.ts.map +1 -1
  286. package/build-types/components/posts-per-page/index.d.ts.map +1 -1
  287. package/build-types/components/preferences-modal/enable-plugin-document-setting-panel.d.ts.map +1 -1
  288. package/build-types/components/provider/index.d.ts.map +1 -1
  289. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  290. package/build-types/components/save-publish-panels/index.d.ts.map +1 -1
  291. package/build-types/components/sidebar/index.d.ts.map +1 -1
  292. package/build-types/components/site-discussion/index.d.ts.map +1 -1
  293. package/build-types/components/template-content-panel/index.d.ts +1 -3
  294. package/build-types/components/template-content-panel/index.d.ts.map +1 -1
  295. package/build-types/components/theme-support-check/index.d.ts.map +1 -1
  296. package/build-types/components/time-to-read/index.d.ts.map +1 -1
  297. package/build-types/components/unsaved-changes-warning/index.d.ts.map +1 -1
  298. package/build-types/components/visual-editor/edit-template-blocks-notification.d.ts +1 -1
  299. package/build-types/components/visual-editor/edit-template-blocks-notification.d.ts.map +1 -1
  300. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  301. package/build-types/components/visual-editor/use-select-nearest-editable-block.d.ts.map +1 -0
  302. package/build-types/components/word-count/index.d.ts.map +1 -1
  303. package/build-types/dataviews/actions/delete-post.d.ts.map +1 -1
  304. package/build-types/dataviews/api.d.ts +1 -1
  305. package/build-types/dataviews/api.d.ts.map +1 -1
  306. package/build-types/dataviews/store/private-selectors.d.ts +0 -1
  307. package/build-types/dataviews/store/private-selectors.d.ts.map +1 -1
  308. package/build-types/hooks/custom-sources-backwards-compatibility.d.ts +1 -1
  309. package/build-types/hooks/custom-sources-backwards-compatibility.d.ts.map +1 -1
  310. package/build-types/hooks/pattern-overrides.d.ts.map +1 -1
  311. package/build-types/private-apis.d.ts.map +1 -1
  312. package/build-types/store/actions.d.ts.map +1 -1
  313. package/build-types/store/private-actions.d.ts.map +1 -1
  314. package/build-types/store/reducer.d.ts.map +1 -1
  315. package/build-types/store/selectors.d.ts +0 -1
  316. package/build-types/store/selectors.d.ts.map +1 -1
  317. package/build-types/utils/media-upload/index.d.ts.map +1 -1
  318. package/package.json +38 -37
  319. package/src/bindings/api.js +57 -0
  320. package/src/bindings/pattern-overrides.js +28 -17
  321. package/src/bindings/post-meta.js +19 -14
  322. package/src/components/block-settings-menu/content-only-settings-menu.js +4 -4
  323. package/src/components/blog-title/index.js +7 -2
  324. package/src/components/collapsible-block-toolbar/index.js +1 -3
  325. package/src/components/collapsible-block-toolbar/style.scss +0 -3
  326. package/src/components/document-bar/style.scss +1 -5
  327. package/src/components/document-tools/style.scss +4 -4
  328. package/src/components/editor-interface/style.scss +4 -0
  329. package/src/components/global-styles-provider/index.js +22 -11
  330. package/src/components/header/back-button.js +6 -6
  331. package/src/components/header/index.js +26 -25
  332. package/src/components/header/style.scss +64 -21
  333. package/src/components/inserter-sidebar/style.scss +1 -6
  334. package/src/components/page-attributes/order.js +3 -77
  335. package/src/components/page-attributes/panel.js +1 -7
  336. package/src/components/post-actions/actions.js +150 -32
  337. package/src/components/post-card-panel/index.js +8 -2
  338. package/src/components/post-comments/index.js +2 -2
  339. package/src/components/post-content-information/index.js +7 -1
  340. package/src/components/post-discussion/panel.js +5 -3
  341. package/src/components/post-excerpt/panel.js +2 -1
  342. package/src/components/post-featured-image/index.js +5 -1
  343. package/src/components/post-last-revision/index.js +1 -0
  344. package/src/components/post-panel-row/style.scss +0 -1
  345. package/src/components/post-publish-button/index.js +4 -17
  346. package/src/components/post-publish-panel/maybe-category-panel.js +4 -1
  347. package/src/components/post-publish-panel/maybe-tags-panel.js +1 -1
  348. package/src/components/post-status/index.js +18 -10
  349. package/src/components/post-taxonomies/flat-term-selector.js +19 -5
  350. package/src/components/post-taxonomies/index.js +8 -1
  351. package/src/components/post-template/block-theme.js +5 -1
  352. package/src/components/post-template/classic-theme.js +8 -3
  353. package/src/components/post-template/create-new-template.js +4 -1
  354. package/src/components/post-template/hooks.js +8 -2
  355. package/src/components/post-template/panel.js +10 -2
  356. package/src/components/post-trash/check.js +9 -5
  357. package/src/components/post-url/panel.js +7 -2
  358. package/src/components/posts-per-page/index.js +7 -2
  359. package/src/components/provider/use-block-editor-settings.js +15 -6
  360. package/src/components/save-publish-panels/index.js +1 -4
  361. package/src/components/sidebar/index.js +2 -5
  362. package/src/components/site-discussion/index.js +9 -4
  363. package/src/components/template-content-panel/index.js +3 -2
  364. package/src/components/visual-editor/edit-template-blocks-notification.js +5 -1
  365. package/src/components/visual-editor/index.js +5 -2
  366. package/src/components/visual-editor/style.scss +0 -1
  367. package/src/{hooks → components/visual-editor}/use-select-nearest-editable-block.js +1 -1
  368. package/src/dataviews/actions/delete-post.tsx +2 -0
  369. package/src/hooks/pattern-overrides.js +1 -1
  370. package/src/index.js +0 -1
  371. package/src/private-apis.js +6 -0
  372. package/src/store/test/actions.js +9 -3
  373. package/src/utils/media-upload/index.js +38 -3
  374. package/tsconfig.tsbuildinfo +1 -1
  375. package/build/bindings/index.js +0 -22
  376. package/build/bindings/index.js.map +0 -1
  377. package/build/hooks/use-select-nearest-editable-block.js.map +0 -1
  378. package/build/store/utils/get-filtered-template-parts.js +0 -71
  379. package/build/store/utils/get-filtered-template-parts.js.map +0 -1
  380. package/build/utils/set-nested-value.js +0 -44
  381. package/build/utils/set-nested-value.js.map +0 -1
  382. package/build-module/bindings/index.js +0 -17
  383. package/build-module/bindings/index.js.map +0 -1
  384. package/build-module/hooks/use-select-nearest-editable-block.js.map +0 -1
  385. package/build-module/store/utils/get-filtered-template-parts.js +0 -64
  386. package/build-module/store/utils/get-filtered-template-parts.js.map +0 -1
  387. package/build-module/utils/set-nested-value.js +0 -38
  388. package/build-module/utils/set-nested-value.js.map +0 -1
  389. package/build-types/bindings/index.d.ts +0 -2
  390. package/build-types/bindings/index.d.ts.map +0 -1
  391. package/build-types/hooks/use-select-nearest-editable-block.d.ts.map +0 -1
  392. package/build-types/store/utils/get-filtered-template-parts.d.ts +0 -3
  393. package/build-types/store/utils/get-filtered-template-parts.d.ts.map +0 -1
  394. package/build-types/utils/set-nested-value.d.ts +0 -20
  395. package/build-types/utils/set-nested-value.d.ts.map +0 -1
  396. package/src/bindings/index.js +0 -15
  397. package/src/store/utils/get-filtered-template-parts.js +0 -69
  398. package/src/store/utils/test/get-filtered-template-parts.js +0 -189
  399. package/src/utils/set-nested-value.js +0 -39
  400. /package/build-types/{hooks → components/visual-editor}/use-select-nearest-editable-block.d.ts +0 -0
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _blocks = require("@wordpress/blocks");
5
- var _data = require("@wordpress/data");
6
- var _lockUnlock = require("../lock-unlock");
7
- var _patternOverrides = _interopRequireDefault(require("./pattern-overrides"));
8
- var _postMeta = _interopRequireDefault(require("./post-meta"));
9
- /**
10
- * WordPress dependencies
11
- */
12
-
13
- /**
14
- * Internal dependencies
15
- */
16
-
17
- const {
18
- registerBlockBindingsSource
19
- } = (0, _lockUnlock.unlock)((0, _data.dispatch)(_blocks.store));
20
- registerBlockBindingsSource(_postMeta.default);
21
- registerBlockBindingsSource(_patternOverrides.default);
22
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_blocks","require","_data","_lockUnlock","_patternOverrides","_interopRequireDefault","_postMeta","registerBlockBindingsSource","unlock","dispatch","blocksStore","postMeta","patternOverrides"],"sources":["@wordpress/editor/src/bindings/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { dispatch } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport patternOverrides from './pattern-overrides';\nimport postMeta from './post-meta';\n\nconst { registerBlockBindingsSource } = unlock( dispatch( blocksStore ) );\nregisterBlockBindingsSource( postMeta );\nregisterBlockBindingsSource( patternOverrides );\n"],"mappings":";;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAIA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAD,sBAAA,CAAAJ,OAAA;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKA,MAAM;EAAEM;AAA4B,CAAC,GAAG,IAAAC,kBAAM,EAAE,IAAAC,cAAQ,EAAEC,aAAY,CAAE,CAAC;AACzEH,2BAA2B,CAAEI,iBAAS,CAAC;AACvCJ,2BAA2B,CAAEK,yBAAiB,CAAC","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["_compose","require","_data","_blockEditor","_lockUnlock","DISTANCE_THRESHOLD","clamp","value","min","max","Math","distanceFromRect","x","y","rect","dx","left","right","dy","top","bottom","sqrt","useSelectNearestEditableBlock","isEnabled","getEnabledClientIdsTree","getBlockName","getBlockOrder","unlock","useSelect","blockEditorStore","selectBlock","useDispatch","useRefEffect","element","selectNearestEditableBlock","editableBlockClientIds","flatMap","clientId","blockName","innerBlocks","length","nearestDistance","Infinity","nearestClientId","block","querySelector","getBoundingClientRect","distance","handleClick","event","shouldSelect","target","classList","contains","clientX","clientY","addEventListener","removeEventListener"],"sources":["@wordpress/editor/src/hooks/use-select-nearest-editable-block.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst DISTANCE_THRESHOLD = 500;\n\nfunction clamp( value, min, max ) {\n\treturn Math.min( Math.max( value, min ), max );\n}\n\nfunction distanceFromRect( x, y, rect ) {\n\tconst dx = x - clamp( x, rect.left, rect.right );\n\tconst dy = y - clamp( y, rect.top, rect.bottom );\n\treturn Math.sqrt( dx * dx + dy * dy );\n}\n\nexport default function useSelectNearestEditableBlock( {\n\tisEnabled = true,\n} = {} ) {\n\tconst { getEnabledClientIdsTree, getBlockName, getBlockOrder } = unlock(\n\t\tuseSelect( blockEditorStore )\n\t);\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\n\treturn useRefEffect(\n\t\t( element ) => {\n\t\t\tif ( ! isEnabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectNearestEditableBlock = ( x, y ) => {\n\t\t\t\tconst editableBlockClientIds =\n\t\t\t\t\tgetEnabledClientIdsTree().flatMap( ( { clientId } ) => {\n\t\t\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t\t\tif ( blockName === 'core/template-part' ) {\n\t\t\t\t\t\t\treturn [];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( blockName === 'core/post-content' ) {\n\t\t\t\t\t\t\tconst innerBlocks = getBlockOrder( clientId );\n\t\t\t\t\t\t\tif ( innerBlocks.length ) {\n\t\t\t\t\t\t\t\treturn innerBlocks;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn [ clientId ];\n\t\t\t\t\t} );\n\n\t\t\t\tlet nearestDistance = Infinity,\n\t\t\t\t\tnearestClientId = null;\n\n\t\t\t\tfor ( const clientId of editableBlockClientIds ) {\n\t\t\t\t\tconst block = element.querySelector(\n\t\t\t\t\t\t`[data-block=\"${ clientId }\"]`\n\t\t\t\t\t);\n\t\t\t\t\tif ( ! block ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst rect = block.getBoundingClientRect();\n\t\t\t\t\tconst distance = distanceFromRect( x, y, rect );\n\t\t\t\t\tif (\n\t\t\t\t\t\tdistance < nearestDistance &&\n\t\t\t\t\t\tdistance < DISTANCE_THRESHOLD\n\t\t\t\t\t) {\n\t\t\t\t\t\tnearestDistance = distance;\n\t\t\t\t\t\tnearestClientId = clientId;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( nearestClientId ) {\n\t\t\t\t\tselectBlock( nearestClientId );\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst handleClick = ( event ) => {\n\t\t\t\tconst shouldSelect =\n\t\t\t\t\tevent.target === element ||\n\t\t\t\t\tevent.target.classList.contains( 'is-root-container' );\n\t\t\t\tif ( shouldSelect ) {\n\t\t\t\t\tselectNearestEditableBlock( event.clientX, event.clientY );\n\t\t\t\t}\n\t\t\t};\n\n\t\t\telement.addEventListener( 'click', handleClick );\n\t\t\treturn () => element.removeEventListener( 'click', handleClick );\n\t\t},\n\t\t[ isEnabled ]\n\t);\n}\n"],"mappings":"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","ignoreList":[]}
@@ -1,71 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.getFilteredTemplatePartBlocks = void 0;
8
- var _memize = _interopRequireDefault(require("memize"));
9
- var _blocks = require("@wordpress/blocks");
10
- /**
11
- * External dependencies
12
- */
13
-
14
- /**
15
- * WordPress dependencies
16
- */
17
-
18
- const EMPTY_ARRAY = [];
19
-
20
- /**
21
- * Get a flattened and filtered list of template parts and the matching block for that template part.
22
- *
23
- * Takes a list of blocks defined within a template, and a list of template parts, and returns a
24
- * flattened list of template parts and the matching block for that template part.
25
- *
26
- * @param {Array} blocks Blocks to flatten.
27
- * @param {?Array} templateParts Available template parts.
28
- * @return {Array} An array of template parts and their blocks.
29
- */
30
- function getFilteredTemplatePartBlocks(blocks = EMPTY_ARRAY, templateParts) {
31
- const templatePartsById = templateParts ?
32
- // Key template parts by their ID.
33
- templateParts.reduce((newTemplateParts, part) => ({
34
- ...newTemplateParts,
35
- [part.id]: part
36
- }), {}) : {};
37
- const result = [];
38
-
39
- // Iterate over all blocks, recursing into inner blocks.
40
- // Output will be based on a depth-first traversal.
41
- const stack = [...blocks];
42
- while (stack.length) {
43
- const {
44
- innerBlocks,
45
- ...block
46
- } = stack.shift();
47
- // Place inner blocks at the beginning of the stack to preserve order.
48
- stack.unshift(...innerBlocks);
49
- if ((0, _blocks.isTemplatePart)(block)) {
50
- const {
51
- attributes: {
52
- theme,
53
- slug
54
- }
55
- } = block;
56
- const templatePartId = `${theme}//${slug}`;
57
- const templatePart = templatePartsById[templatePartId];
58
-
59
- // Only add to output if the found template part block is in the list of available template parts.
60
- if (templatePart) {
61
- result.push({
62
- templatePart,
63
- block
64
- });
65
- }
66
- }
67
- }
68
- return result;
69
- }
70
- const memoizedGetFilteredTemplatePartBlocks = exports.getFilteredTemplatePartBlocks = (0, _memize.default)(getFilteredTemplatePartBlocks);
71
- //# sourceMappingURL=get-filtered-template-parts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_memize","_interopRequireDefault","require","_blocks","EMPTY_ARRAY","getFilteredTemplatePartBlocks","blocks","templateParts","templatePartsById","reduce","newTemplateParts","part","id","result","stack","length","innerBlocks","block","shift","unshift","isTemplatePart","attributes","theme","slug","templatePartId","templatePart","push","memoizedGetFilteredTemplatePartBlocks","exports","memoize"],"sources":["@wordpress/editor/src/store/utils/get-filtered-template-parts.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { isTemplatePart } from '@wordpress/blocks';\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Get a flattened and filtered list of template parts and the matching block for that template part.\n *\n * Takes a list of blocks defined within a template, and a list of template parts, and returns a\n * flattened list of template parts and the matching block for that template part.\n *\n * @param {Array} blocks Blocks to flatten.\n * @param {?Array} templateParts Available template parts.\n * @return {Array} An array of template parts and their blocks.\n */\nfunction getFilteredTemplatePartBlocks( blocks = EMPTY_ARRAY, templateParts ) {\n\tconst templatePartsById = templateParts\n\t\t? // Key template parts by their ID.\n\t\t templateParts.reduce(\n\t\t\t\t( newTemplateParts, part ) => ( {\n\t\t\t\t\t...newTemplateParts,\n\t\t\t\t\t[ part.id ]: part,\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t )\n\t\t: {};\n\n\tconst result = [];\n\n\t// Iterate over all blocks, recursing into inner blocks.\n\t// Output will be based on a depth-first traversal.\n\tconst stack = [ ...blocks ];\n\twhile ( stack.length ) {\n\t\tconst { innerBlocks, ...block } = stack.shift();\n\t\t// Place inner blocks at the beginning of the stack to preserve order.\n\t\tstack.unshift( ...innerBlocks );\n\n\t\tif ( isTemplatePart( block ) ) {\n\t\t\tconst {\n\t\t\t\tattributes: { theme, slug },\n\t\t\t} = block;\n\t\t\tconst templatePartId = `${ theme }//${ slug }`;\n\t\t\tconst templatePart = templatePartsById[ templatePartId ];\n\n\t\t\t// Only add to output if the found template part block is in the list of available template parts.\n\t\t\tif ( templatePart ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\ttemplatePart,\n\t\t\t\t\tblock,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}\n\nconst memoizedGetFilteredTemplatePartBlocks = memoize(\n\tgetFilteredTemplatePartBlocks\n);\n\nexport { memoizedGetFilteredTemplatePartBlocks as getFilteredTemplatePartBlocks };\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,OAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA,MAAME,WAAW,GAAG,EAAE;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,6BAA6BA,CAAEC,MAAM,GAAGF,WAAW,EAAEG,aAAa,EAAG;EAC7E,MAAMC,iBAAiB,GAAGD,aAAa;EACpC;EACAA,aAAa,CAACE,MAAM,CACpB,CAAEC,gBAAgB,EAAEC,IAAI,MAAQ;IAC/B,GAAGD,gBAAgB;IACnB,CAAEC,IAAI,CAACC,EAAE,GAAID;EACd,CAAC,CAAE,EACH,CAAC,CACD,CAAC,GACD,CAAC,CAAC;EAEL,MAAME,MAAM,GAAG,EAAE;;EAEjB;EACA;EACA,MAAMC,KAAK,GAAG,CAAE,GAAGR,MAAM,CAAE;EAC3B,OAAQQ,KAAK,CAACC,MAAM,EAAG;IACtB,MAAM;MAAEC,WAAW;MAAE,GAAGC;IAAM,CAAC,GAAGH,KAAK,CAACI,KAAK,CAAC,CAAC;IAC/C;IACAJ,KAAK,CAACK,OAAO,CAAE,GAAGH,WAAY,CAAC;IAE/B,IAAK,IAAAI,sBAAc,EAAEH,KAAM,CAAC,EAAG;MAC9B,MAAM;QACLI,UAAU,EAAE;UAAEC,KAAK;UAAEC;QAAK;MAC3B,CAAC,GAAGN,KAAK;MACT,MAAMO,cAAc,GAAI,GAAGF,KAAO,KAAKC,IAAM,EAAC;MAC9C,MAAME,YAAY,GAAGjB,iBAAiB,CAAEgB,cAAc,CAAE;;MAExD;MACA,IAAKC,YAAY,EAAG;QACnBZ,MAAM,CAACa,IAAI,CAAE;UACZD,YAAY;UACZR;QACD,CAAE,CAAC;MACJ;IACD;EACD;EAEA,OAAOJ,MAAM;AACd;AAEA,MAAMc,qCAAqC,GAAAC,OAAA,CAAAvB,6BAAA,GAAG,IAAAwB,eAAO,EACpDxB,6BACD,CAAC","ignoreList":[]}
@@ -1,44 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = setNestedValue;
7
- /**
8
- * Sets the value at path of object.
9
- * If a portion of path doesn’t exist, it’s created.
10
- * Arrays are created for missing index properties while objects are created
11
- * for all other missing properties.
12
- *
13
- * This function intentionally mutates the input object.
14
- *
15
- * Inspired by _.set().
16
- *
17
- * @see https://lodash.com/docs/4.17.15#set
18
- *
19
- * @todo Needs to be deduplicated with its copy in `@wordpress/core-data`.
20
- *
21
- * @param {Object} object Object to modify
22
- * @param {Array} path Path of the property to set.
23
- * @param {*} value Value to set.
24
- */
25
- function setNestedValue(object, path, value) {
26
- if (!object || typeof object !== 'object') {
27
- return object;
28
- }
29
- path.reduce((acc, key, idx) => {
30
- if (acc[key] === undefined) {
31
- if (Number.isInteger(path[idx + 1])) {
32
- acc[key] = [];
33
- } else {
34
- acc[key] = {};
35
- }
36
- }
37
- if (idx === path.length - 1) {
38
- acc[key] = value;
39
- }
40
- return acc[key];
41
- }, object);
42
- return object;
43
- }
44
- //# sourceMappingURL=set-nested-value.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["setNestedValue","object","path","value","reduce","acc","key","idx","undefined","Number","isInteger","length"],"sources":["@wordpress/editor/src/utils/set-nested-value.js"],"sourcesContent":["/**\n * Sets the value at path of object.\n * If a portion of path doesn’t exist, it’s created.\n * Arrays are created for missing index properties while objects are created\n * for all other missing properties.\n *\n * This function intentionally mutates the input object.\n *\n * Inspired by _.set().\n *\n * @see https://lodash.com/docs/4.17.15#set\n *\n * @todo Needs to be deduplicated with its copy in `@wordpress/core-data`.\n *\n * @param {Object} object Object to modify\n * @param {Array} path Path of the property to set.\n * @param {*} value Value to set.\n */\nexport default function setNestedValue( object, path, value ) {\n\tif ( ! object || typeof object !== 'object' ) {\n\t\treturn object;\n\t}\n\n\tpath.reduce( ( acc, key, idx ) => {\n\t\tif ( acc[ key ] === undefined ) {\n\t\t\tif ( Number.isInteger( path[ idx + 1 ] ) ) {\n\t\t\t\tacc[ key ] = [];\n\t\t\t} else {\n\t\t\t\tacc[ key ] = {};\n\t\t\t}\n\t\t}\n\t\tif ( idx === path.length - 1 ) {\n\t\t\tacc[ key ] = value;\n\t\t}\n\t\treturn acc[ key ];\n\t}, object );\n\n\treturn object;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAcA,CAAEC,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAG;EAC7D,IAAK,CAAEF,MAAM,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAG;IAC7C,OAAOA,MAAM;EACd;EAEAC,IAAI,CAACE,MAAM,CAAE,CAAEC,GAAG,EAAEC,GAAG,EAAEC,GAAG,KAAM;IACjC,IAAKF,GAAG,CAAEC,GAAG,CAAE,KAAKE,SAAS,EAAG;MAC/B,IAAKC,MAAM,CAACC,SAAS,CAAER,IAAI,CAAEK,GAAG,GAAG,CAAC,CAAG,CAAC,EAAG;QAC1CF,GAAG,CAAEC,GAAG,CAAE,GAAG,EAAE;MAChB,CAAC,MAAM;QACND,GAAG,CAAEC,GAAG,CAAE,GAAG,CAAC,CAAC;MAChB;IACD;IACA,IAAKC,GAAG,KAAKL,IAAI,CAACS,MAAM,GAAG,CAAC,EAAG;MAC9BN,GAAG,CAAEC,GAAG,CAAE,GAAGH,KAAK;IACnB;IACA,OAAOE,GAAG,CAAEC,GAAG,CAAE;EAClB,CAAC,EAAEL,MAAO,CAAC;EAEX,OAAOA,MAAM;AACd","ignoreList":[]}
@@ -1,17 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { store as blocksStore } from '@wordpress/blocks';
5
- import { dispatch } from '@wordpress/data';
6
- /**
7
- * Internal dependencies
8
- */
9
- import { unlock } from '../lock-unlock';
10
- import patternOverrides from './pattern-overrides';
11
- import postMeta from './post-meta';
12
- const {
13
- registerBlockBindingsSource
14
- } = unlock(dispatch(blocksStore));
15
- registerBlockBindingsSource(postMeta);
16
- registerBlockBindingsSource(patternOverrides);
17
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["store","blocksStore","dispatch","unlock","patternOverrides","postMeta","registerBlockBindingsSource"],"sources":["@wordpress/editor/src/bindings/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { dispatch } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport patternOverrides from './pattern-overrides';\nimport postMeta from './post-meta';\n\nconst { registerBlockBindingsSource } = unlock( dispatch( blocksStore ) );\nregisterBlockBindingsSource( postMeta );\nregisterBlockBindingsSource( patternOverrides );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C;AACA;AACA;AACA,SAASC,MAAM,QAAQ,gBAAgB;AACvC,OAAOC,gBAAgB,MAAM,qBAAqB;AAClD,OAAOC,QAAQ,MAAM,aAAa;AAElC,MAAM;EAAEC;AAA4B,CAAC,GAAGH,MAAM,CAAED,QAAQ,CAAED,WAAY,CAAE,CAAC;AACzEK,2BAA2B,CAAED,QAAS,CAAC;AACvCC,2BAA2B,CAAEF,gBAAiB,CAAC","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["useRefEffect","useSelect","useDispatch","store","blockEditorStore","unlock","DISTANCE_THRESHOLD","clamp","value","min","max","Math","distanceFromRect","x","y","rect","dx","left","right","dy","top","bottom","sqrt","useSelectNearestEditableBlock","isEnabled","getEnabledClientIdsTree","getBlockName","getBlockOrder","selectBlock","element","selectNearestEditableBlock","editableBlockClientIds","flatMap","clientId","blockName","innerBlocks","length","nearestDistance","Infinity","nearestClientId","block","querySelector","getBoundingClientRect","distance","handleClick","event","shouldSelect","target","classList","contains","clientX","clientY","addEventListener","removeEventListener"],"sources":["@wordpress/editor/src/hooks/use-select-nearest-editable-block.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst DISTANCE_THRESHOLD = 500;\n\nfunction clamp( value, min, max ) {\n\treturn Math.min( Math.max( value, min ), max );\n}\n\nfunction distanceFromRect( x, y, rect ) {\n\tconst dx = x - clamp( x, rect.left, rect.right );\n\tconst dy = y - clamp( y, rect.top, rect.bottom );\n\treturn Math.sqrt( dx * dx + dy * dy );\n}\n\nexport default function useSelectNearestEditableBlock( {\n\tisEnabled = true,\n} = {} ) {\n\tconst { getEnabledClientIdsTree, getBlockName, getBlockOrder } = unlock(\n\t\tuseSelect( blockEditorStore )\n\t);\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\n\treturn useRefEffect(\n\t\t( element ) => {\n\t\t\tif ( ! isEnabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectNearestEditableBlock = ( x, y ) => {\n\t\t\t\tconst editableBlockClientIds =\n\t\t\t\t\tgetEnabledClientIdsTree().flatMap( ( { clientId } ) => {\n\t\t\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t\t\tif ( blockName === 'core/template-part' ) {\n\t\t\t\t\t\t\treturn [];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( blockName === 'core/post-content' ) {\n\t\t\t\t\t\t\tconst innerBlocks = getBlockOrder( clientId );\n\t\t\t\t\t\t\tif ( innerBlocks.length ) {\n\t\t\t\t\t\t\t\treturn innerBlocks;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn [ clientId ];\n\t\t\t\t\t} );\n\n\t\t\t\tlet nearestDistance = Infinity,\n\t\t\t\t\tnearestClientId = null;\n\n\t\t\t\tfor ( const clientId of editableBlockClientIds ) {\n\t\t\t\t\tconst block = element.querySelector(\n\t\t\t\t\t\t`[data-block=\"${ clientId }\"]`\n\t\t\t\t\t);\n\t\t\t\t\tif ( ! block ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst rect = block.getBoundingClientRect();\n\t\t\t\t\tconst distance = distanceFromRect( x, y, rect );\n\t\t\t\t\tif (\n\t\t\t\t\t\tdistance < nearestDistance &&\n\t\t\t\t\t\tdistance < DISTANCE_THRESHOLD\n\t\t\t\t\t) {\n\t\t\t\t\t\tnearestDistance = distance;\n\t\t\t\t\t\tnearestClientId = clientId;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( nearestClientId ) {\n\t\t\t\t\tselectBlock( nearestClientId );\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst handleClick = ( event ) => {\n\t\t\t\tconst shouldSelect =\n\t\t\t\t\tevent.target === element ||\n\t\t\t\t\tevent.target.classList.contains( 'is-root-container' );\n\t\t\t\tif ( shouldSelect ) {\n\t\t\t\t\tselectNearestEditableBlock( event.clientX, event.clientY );\n\t\t\t\t}\n\t\t\t};\n\n\t\t\telement.addEventListener( 'click', handleClick );\n\t\t\treturn () => element.removeEventListener( 'click', handleClick );\n\t\t},\n\t\t[ isEnabled ]\n\t);\n}\n"],"mappings":"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","ignoreList":[]}
@@ -1,64 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import memoize from 'memize';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { isTemplatePart } from '@wordpress/blocks';
10
- const EMPTY_ARRAY = [];
11
-
12
- /**
13
- * Get a flattened and filtered list of template parts and the matching block for that template part.
14
- *
15
- * Takes a list of blocks defined within a template, and a list of template parts, and returns a
16
- * flattened list of template parts and the matching block for that template part.
17
- *
18
- * @param {Array} blocks Blocks to flatten.
19
- * @param {?Array} templateParts Available template parts.
20
- * @return {Array} An array of template parts and their blocks.
21
- */
22
- function getFilteredTemplatePartBlocks(blocks = EMPTY_ARRAY, templateParts) {
23
- const templatePartsById = templateParts ?
24
- // Key template parts by their ID.
25
- templateParts.reduce((newTemplateParts, part) => ({
26
- ...newTemplateParts,
27
- [part.id]: part
28
- }), {}) : {};
29
- const result = [];
30
-
31
- // Iterate over all blocks, recursing into inner blocks.
32
- // Output will be based on a depth-first traversal.
33
- const stack = [...blocks];
34
- while (stack.length) {
35
- const {
36
- innerBlocks,
37
- ...block
38
- } = stack.shift();
39
- // Place inner blocks at the beginning of the stack to preserve order.
40
- stack.unshift(...innerBlocks);
41
- if (isTemplatePart(block)) {
42
- const {
43
- attributes: {
44
- theme,
45
- slug
46
- }
47
- } = block;
48
- const templatePartId = `${theme}//${slug}`;
49
- const templatePart = templatePartsById[templatePartId];
50
-
51
- // Only add to output if the found template part block is in the list of available template parts.
52
- if (templatePart) {
53
- result.push({
54
- templatePart,
55
- block
56
- });
57
- }
58
- }
59
- }
60
- return result;
61
- }
62
- const memoizedGetFilteredTemplatePartBlocks = memoize(getFilteredTemplatePartBlocks);
63
- export { memoizedGetFilteredTemplatePartBlocks as getFilteredTemplatePartBlocks };
64
- //# sourceMappingURL=get-filtered-template-parts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["memoize","isTemplatePart","EMPTY_ARRAY","getFilteredTemplatePartBlocks","blocks","templateParts","templatePartsById","reduce","newTemplateParts","part","id","result","stack","length","innerBlocks","block","shift","unshift","attributes","theme","slug","templatePartId","templatePart","push","memoizedGetFilteredTemplatePartBlocks"],"sources":["@wordpress/editor/src/store/utils/get-filtered-template-parts.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { isTemplatePart } from '@wordpress/blocks';\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Get a flattened and filtered list of template parts and the matching block for that template part.\n *\n * Takes a list of blocks defined within a template, and a list of template parts, and returns a\n * flattened list of template parts and the matching block for that template part.\n *\n * @param {Array} blocks Blocks to flatten.\n * @param {?Array} templateParts Available template parts.\n * @return {Array} An array of template parts and their blocks.\n */\nfunction getFilteredTemplatePartBlocks( blocks = EMPTY_ARRAY, templateParts ) {\n\tconst templatePartsById = templateParts\n\t\t? // Key template parts by their ID.\n\t\t templateParts.reduce(\n\t\t\t\t( newTemplateParts, part ) => ( {\n\t\t\t\t\t...newTemplateParts,\n\t\t\t\t\t[ part.id ]: part,\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t )\n\t\t: {};\n\n\tconst result = [];\n\n\t// Iterate over all blocks, recursing into inner blocks.\n\t// Output will be based on a depth-first traversal.\n\tconst stack = [ ...blocks ];\n\twhile ( stack.length ) {\n\t\tconst { innerBlocks, ...block } = stack.shift();\n\t\t// Place inner blocks at the beginning of the stack to preserve order.\n\t\tstack.unshift( ...innerBlocks );\n\n\t\tif ( isTemplatePart( block ) ) {\n\t\t\tconst {\n\t\t\t\tattributes: { theme, slug },\n\t\t\t} = block;\n\t\t\tconst templatePartId = `${ theme }//${ slug }`;\n\t\t\tconst templatePart = templatePartsById[ templatePartId ];\n\n\t\t\t// Only add to output if the found template part block is in the list of available template parts.\n\t\t\tif ( templatePart ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\ttemplatePart,\n\t\t\t\t\tblock,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}\n\nconst memoizedGetFilteredTemplatePartBlocks = memoize(\n\tgetFilteredTemplatePartBlocks\n);\n\nexport { memoizedGetFilteredTemplatePartBlocks as getFilteredTemplatePartBlocks };\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,OAAO,MAAM,QAAQ;;AAE5B;AACA;AACA;AACA,SAASC,cAAc,QAAQ,mBAAmB;AAElD,MAAMC,WAAW,GAAG,EAAE;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,6BAA6BA,CAAEC,MAAM,GAAGF,WAAW,EAAEG,aAAa,EAAG;EAC7E,MAAMC,iBAAiB,GAAGD,aAAa;EACpC;EACAA,aAAa,CAACE,MAAM,CACpB,CAAEC,gBAAgB,EAAEC,IAAI,MAAQ;IAC/B,GAAGD,gBAAgB;IACnB,CAAEC,IAAI,CAACC,EAAE,GAAID;EACd,CAAC,CAAE,EACH,CAAC,CACD,CAAC,GACD,CAAC,CAAC;EAEL,MAAME,MAAM,GAAG,EAAE;;EAEjB;EACA;EACA,MAAMC,KAAK,GAAG,CAAE,GAAGR,MAAM,CAAE;EAC3B,OAAQQ,KAAK,CAACC,MAAM,EAAG;IACtB,MAAM;MAAEC,WAAW;MAAE,GAAGC;IAAM,CAAC,GAAGH,KAAK,CAACI,KAAK,CAAC,CAAC;IAC/C;IACAJ,KAAK,CAACK,OAAO,CAAE,GAAGH,WAAY,CAAC;IAE/B,IAAKb,cAAc,CAAEc,KAAM,CAAC,EAAG;MAC9B,MAAM;QACLG,UAAU,EAAE;UAAEC,KAAK;UAAEC;QAAK;MAC3B,CAAC,GAAGL,KAAK;MACT,MAAMM,cAAc,GAAI,GAAGF,KAAO,KAAKC,IAAM,EAAC;MAC9C,MAAME,YAAY,GAAGhB,iBAAiB,CAAEe,cAAc,CAAE;;MAExD;MACA,IAAKC,YAAY,EAAG;QACnBX,MAAM,CAACY,IAAI,CAAE;UACZD,YAAY;UACZP;QACD,CAAE,CAAC;MACJ;IACD;EACD;EAEA,OAAOJ,MAAM;AACd;AAEA,MAAMa,qCAAqC,GAAGxB,OAAO,CACpDG,6BACD,CAAC;AAED,SAASqB,qCAAqC,IAAIrB,6BAA6B","ignoreList":[]}
@@ -1,38 +0,0 @@
1
- /**
2
- * Sets the value at path of object.
3
- * If a portion of path doesn’t exist, it’s created.
4
- * Arrays are created for missing index properties while objects are created
5
- * for all other missing properties.
6
- *
7
- * This function intentionally mutates the input object.
8
- *
9
- * Inspired by _.set().
10
- *
11
- * @see https://lodash.com/docs/4.17.15#set
12
- *
13
- * @todo Needs to be deduplicated with its copy in `@wordpress/core-data`.
14
- *
15
- * @param {Object} object Object to modify
16
- * @param {Array} path Path of the property to set.
17
- * @param {*} value Value to set.
18
- */
19
- export default function setNestedValue(object, path, value) {
20
- if (!object || typeof object !== 'object') {
21
- return object;
22
- }
23
- path.reduce((acc, key, idx) => {
24
- if (acc[key] === undefined) {
25
- if (Number.isInteger(path[idx + 1])) {
26
- acc[key] = [];
27
- } else {
28
- acc[key] = {};
29
- }
30
- }
31
- if (idx === path.length - 1) {
32
- acc[key] = value;
33
- }
34
- return acc[key];
35
- }, object);
36
- return object;
37
- }
38
- //# sourceMappingURL=set-nested-value.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["setNestedValue","object","path","value","reduce","acc","key","idx","undefined","Number","isInteger","length"],"sources":["@wordpress/editor/src/utils/set-nested-value.js"],"sourcesContent":["/**\n * Sets the value at path of object.\n * If a portion of path doesn’t exist, it’s created.\n * Arrays are created for missing index properties while objects are created\n * for all other missing properties.\n *\n * This function intentionally mutates the input object.\n *\n * Inspired by _.set().\n *\n * @see https://lodash.com/docs/4.17.15#set\n *\n * @todo Needs to be deduplicated with its copy in `@wordpress/core-data`.\n *\n * @param {Object} object Object to modify\n * @param {Array} path Path of the property to set.\n * @param {*} value Value to set.\n */\nexport default function setNestedValue( object, path, value ) {\n\tif ( ! object || typeof object !== 'object' ) {\n\t\treturn object;\n\t}\n\n\tpath.reduce( ( acc, key, idx ) => {\n\t\tif ( acc[ key ] === undefined ) {\n\t\t\tif ( Number.isInteger( path[ idx + 1 ] ) ) {\n\t\t\t\tacc[ key ] = [];\n\t\t\t} else {\n\t\t\t\tacc[ key ] = {};\n\t\t\t}\n\t\t}\n\t\tif ( idx === path.length - 1 ) {\n\t\t\tacc[ key ] = value;\n\t\t}\n\t\treturn acc[ key ];\n\t}, object );\n\n\treturn object;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,cAAcA,CAAEC,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAG;EAC7D,IAAK,CAAEF,MAAM,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAG;IAC7C,OAAOA,MAAM;EACd;EAEAC,IAAI,CAACE,MAAM,CAAE,CAAEC,GAAG,EAAEC,GAAG,EAAEC,GAAG,KAAM;IACjC,IAAKF,GAAG,CAAEC,GAAG,CAAE,KAAKE,SAAS,EAAG;MAC/B,IAAKC,MAAM,CAACC,SAAS,CAAER,IAAI,CAAEK,GAAG,GAAG,CAAC,CAAG,CAAC,EAAG;QAC1CF,GAAG,CAAEC,GAAG,CAAE,GAAG,EAAE;MAChB,CAAC,MAAM;QACND,GAAG,CAAEC,GAAG,CAAE,GAAG,CAAC,CAAC;MAChB;IACD;IACA,IAAKC,GAAG,KAAKL,IAAI,CAACS,MAAM,GAAG,CAAC,EAAG;MAC9BN,GAAG,CAAEC,GAAG,CAAE,GAAGH,KAAK;IACnB;IACA,OAAOE,GAAG,CAAEC,GAAG,CAAE;EAClB,CAAC,EAAEL,MAAO,CAAC;EAEX,OAAOA,MAAM;AACd","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bindings/index.js"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-select-nearest-editable-block.d.ts","sourceRoot":"","sources":["../../src/hooks/use-select-nearest-editable-block.js"],"names":[],"mappings":"AAwBA;;6CAsEC"}
@@ -1,3 +0,0 @@
1
- export { memoizedGetFilteredTemplatePartBlocks as getFilteredTemplatePartBlocks };
2
- declare const memoizedGetFilteredTemplatePartBlocks: ((blocks: any[] | undefined, templateParts: any[] | null) => any[]) & import("memize").MemizeMemoizedFunction;
3
- //# sourceMappingURL=get-filtered-template-parts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-filtered-template-parts.d.ts","sourceRoot":"","sources":["../../../src/store/utils/get-filtered-template-parts.js"],"names":[],"mappings":";AAgEA,mKAEE"}
@@ -1,20 +0,0 @@
1
- /**
2
- * Sets the value at path of object.
3
- * If a portion of path doesn’t exist, it’s created.
4
- * Arrays are created for missing index properties while objects are created
5
- * for all other missing properties.
6
- *
7
- * This function intentionally mutates the input object.
8
- *
9
- * Inspired by _.set().
10
- *
11
- * @see https://lodash.com/docs/4.17.15#set
12
- *
13
- * @todo Needs to be deduplicated with its copy in `@wordpress/core-data`.
14
- *
15
- * @param {Object} object Object to modify
16
- * @param {Array} path Path of the property to set.
17
- * @param {*} value Value to set.
18
- */
19
- export default function setNestedValue(object: Object, path: any[], value: any): Object;
20
- //# sourceMappingURL=set-nested-value.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"set-nested-value.d.ts","sourceRoot":"","sources":["../../src/utils/set-nested-value.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,+CAJW,MAAM,mCAwBhB"}
@@ -1,15 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { store as blocksStore } from '@wordpress/blocks';
5
- import { dispatch } from '@wordpress/data';
6
- /**
7
- * Internal dependencies
8
- */
9
- import { unlock } from '../lock-unlock';
10
- import patternOverrides from './pattern-overrides';
11
- import postMeta from './post-meta';
12
-
13
- const { registerBlockBindingsSource } = unlock( dispatch( blocksStore ) );
14
- registerBlockBindingsSource( postMeta );
15
- registerBlockBindingsSource( patternOverrides );
@@ -1,69 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import memoize from 'memize';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { isTemplatePart } from '@wordpress/blocks';
10
-
11
- const EMPTY_ARRAY = [];
12
-
13
- /**
14
- * Get a flattened and filtered list of template parts and the matching block for that template part.
15
- *
16
- * Takes a list of blocks defined within a template, and a list of template parts, and returns a
17
- * flattened list of template parts and the matching block for that template part.
18
- *
19
- * @param {Array} blocks Blocks to flatten.
20
- * @param {?Array} templateParts Available template parts.
21
- * @return {Array} An array of template parts and their blocks.
22
- */
23
- function getFilteredTemplatePartBlocks( blocks = EMPTY_ARRAY, templateParts ) {
24
- const templatePartsById = templateParts
25
- ? // Key template parts by their ID.
26
- templateParts.reduce(
27
- ( newTemplateParts, part ) => ( {
28
- ...newTemplateParts,
29
- [ part.id ]: part,
30
- } ),
31
- {}
32
- )
33
- : {};
34
-
35
- const result = [];
36
-
37
- // Iterate over all blocks, recursing into inner blocks.
38
- // Output will be based on a depth-first traversal.
39
- const stack = [ ...blocks ];
40
- while ( stack.length ) {
41
- const { innerBlocks, ...block } = stack.shift();
42
- // Place inner blocks at the beginning of the stack to preserve order.
43
- stack.unshift( ...innerBlocks );
44
-
45
- if ( isTemplatePart( block ) ) {
46
- const {
47
- attributes: { theme, slug },
48
- } = block;
49
- const templatePartId = `${ theme }//${ slug }`;
50
- const templatePart = templatePartsById[ templatePartId ];
51
-
52
- // Only add to output if the found template part block is in the list of available template parts.
53
- if ( templatePart ) {
54
- result.push( {
55
- templatePart,
56
- block,
57
- } );
58
- }
59
- }
60
- }
61
-
62
- return result;
63
- }
64
-
65
- const memoizedGetFilteredTemplatePartBlocks = memoize(
66
- getFilteredTemplatePartBlocks
67
- );
68
-
69
- export { memoizedGetFilteredTemplatePartBlocks as getFilteredTemplatePartBlocks };
@@ -1,189 +0,0 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import { getFilteredTemplatePartBlocks } from '../get-filtered-template-parts';
5
-
6
- const NESTED_BLOCKS = [
7
- {
8
- clientId: '1',
9
- name: 'core/group',
10
- innerBlocks: [
11
- {
12
- clientId: '2',
13
- name: 'core/template-part',
14
- attributes: {
15
- slug: 'header',
16
- theme: 'my-theme',
17
- },
18
- innerBlocks: [
19
- {
20
- clientId: '3',
21
- name: 'core/group',
22
- innerBlocks: [],
23
- },
24
- ],
25
- },
26
- {
27
- clientId: '4',
28
- name: 'core/template-part',
29
- attributes: {
30
- slug: 'aside',
31
- theme: 'my-theme',
32
- },
33
- innerBlocks: [],
34
- },
35
- ],
36
- },
37
- {
38
- clientId: '5',
39
- name: 'core/paragraph',
40
- innerBlocks: [],
41
- },
42
- {
43
- clientId: '6',
44
- name: 'core/template-part',
45
- attributes: {
46
- slug: 'footer',
47
- theme: 'my-theme',
48
- },
49
- innerBlocks: [],
50
- },
51
- ];
52
-
53
- const FLATTENED_BLOCKS = [
54
- {
55
- block: {
56
- clientId: '2',
57
- name: 'core/template-part',
58
- attributes: {
59
- slug: 'header',
60
- theme: 'my-theme',
61
- },
62
- },
63
- templatePart: {
64
- id: 'my-theme//header',
65
- slug: 'header',
66
- theme: 'my-theme',
67
- },
68
- },
69
- {
70
- block: {
71
- clientId: '4',
72
- name: 'core/template-part',
73
- attributes: {
74
- slug: 'aside',
75
- theme: 'my-theme',
76
- },
77
- },
78
- templatePart: {
79
- id: 'my-theme//aside',
80
- slug: 'aside',
81
- theme: 'my-theme',
82
- },
83
- },
84
- {
85
- block: {
86
- clientId: '6',
87
- name: 'core/template-part',
88
- attributes: {
89
- slug: 'footer',
90
- theme: 'my-theme',
91
- },
92
- },
93
- templatePart: {
94
- id: 'my-theme//footer',
95
- slug: 'footer',
96
- theme: 'my-theme',
97
- },
98
- },
99
- ];
100
-
101
- const SINGLE_TEMPLATE_PART_BLOCK = {
102
- clientId: '1',
103
- name: 'core/template-part',
104
- innerBlocks: [],
105
- attributes: {
106
- slug: 'aside',
107
- theme: 'my-theme',
108
- },
109
- };
110
-
111
- const TEMPLATE_PARTS = [
112
- {
113
- id: 'my-theme//header',
114
- slug: 'header',
115
- theme: 'my-theme',
116
- },
117
- {
118
- id: 'my-theme//aside',
119
- slug: 'aside',
120
- theme: 'my-theme',
121
- },
122
- {
123
- id: 'my-theme//footer',
124
- slug: 'footer',
125
- theme: 'my-theme',
126
- },
127
- ];
128
-
129
- describe( 'getFilteredTemplatePartBlocks', () => {
130
- it( 'returns a flattened list of filtered template parts preserving a depth-first order', () => {
131
- const flattenedFilteredTemplateParts = getFilteredTemplatePartBlocks(
132
- NESTED_BLOCKS,
133
- TEMPLATE_PARTS
134
- );
135
- expect( flattenedFilteredTemplateParts ).toEqual( FLATTENED_BLOCKS );
136
- } );
137
-
138
- it( 'returns a cached result when passed the same params', () => {
139
- // Clear the cache and call the function twice.
140
- getFilteredTemplatePartBlocks.clear();
141
- getFilteredTemplatePartBlocks( NESTED_BLOCKS, TEMPLATE_PARTS );
142
- expect(
143
- getFilteredTemplatePartBlocks( NESTED_BLOCKS, TEMPLATE_PARTS )
144
- ).toEqual( FLATTENED_BLOCKS );
145
-
146
- // The function has been called twice with the same params, so the cache size should be 1.
147
- /**
148
- * TODO what should be done about this?
149
- * Can it be tested another way?
150
- * Is it necessary?
151
- */
152
- // const [ , , originalSize ] =
153
- // getFilteredTemplatePartBlocks.getCache();
154
- // expect( originalSize ).toBe( 1 );
155
-
156
- // Call the function again, with different params.
157
- expect(
158
- getFilteredTemplatePartBlocks(
159
- [ SINGLE_TEMPLATE_PART_BLOCK ],
160
- TEMPLATE_PARTS
161
- )
162
- ).toEqual( [
163
- {
164
- block: {
165
- clientId: '1',
166
- name: 'core/template-part',
167
- attributes: {
168
- slug: 'aside',
169
- theme: 'my-theme',
170
- },
171
- },
172
- templatePart: {
173
- id: 'my-theme//aside',
174
- slug: 'aside',
175
- theme: 'my-theme',
176
- },
177
- },
178
- ] );
179
-
180
- // The function has been called with different params, so the cache size should now be 2.
181
- /**
182
- * TODO what should be done about this?
183
- * Can it be tested another way?
184
- * Is it necessary?
185
- */
186
- // const [ , , finalSize ] = getFilteredTemplatePartBlocks.getCache();
187
- // expect( finalSize ).toBe( 2 );
188
- } );
189
- } );