@wordpress/edit-site 5.23.0 → 5.24.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 (320) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/actions/index.js +56 -38
  3. package/build/components/actions/index.js.map +1 -1
  4. package/build/components/block-editor/site-editor-canvas.js +7 -2
  5. package/build/components/block-editor/site-editor-canvas.js.map +1 -1
  6. package/build/components/dataviews/add-filter.js +21 -20
  7. package/build/components/dataviews/add-filter.js.map +1 -1
  8. package/build/components/dataviews/constants.js +14 -0
  9. package/build/components/dataviews/constants.js.map +1 -0
  10. package/build/components/dataviews/dataviews.js +9 -7
  11. package/build/components/dataviews/dataviews.js.map +1 -1
  12. package/build/components/dataviews/filter-summary.js +62 -0
  13. package/build/components/dataviews/filter-summary.js.map +1 -0
  14. package/build/components/dataviews/filters.js +15 -30
  15. package/build/components/dataviews/filters.js.map +1 -1
  16. package/build/components/dataviews/item-actions.js +84 -30
  17. package/build/components/dataviews/item-actions.js.map +1 -1
  18. package/build/components/dataviews/pagination.js +4 -0
  19. package/build/components/dataviews/pagination.js.map +1 -1
  20. package/build/components/dataviews/view-actions.js +24 -24
  21. package/build/components/dataviews/view-actions.js.map +1 -1
  22. package/build/components/dataviews/view-grid.js +48 -25
  23. package/build/components/dataviews/view-grid.js.map +1 -1
  24. package/build/components/dataviews/view-list.js +28 -33
  25. package/build/components/dataviews/view-list.js.map +1 -1
  26. package/build/components/editor/index.js +23 -27
  27. package/build/components/editor/index.js.map +1 -1
  28. package/build/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +1 -1
  29. package/build/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js.map +1 -1
  30. package/build/components/global-styles/font-library-modal/utils/index.js +15 -2
  31. package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  32. package/build/components/global-styles/header.js +4 -2
  33. package/build/components/global-styles/header.js.map +1 -1
  34. package/build/components/global-styles/screen-block-list.js +22 -16
  35. package/build/components/global-styles/screen-block-list.js.map +1 -1
  36. package/build/components/global-styles/screen-revisions/index.js +26 -5
  37. package/build/components/global-styles/screen-revisions/index.js.map +1 -1
  38. package/build/components/global-styles/screen-revisions/revisions-buttons.js +52 -24
  39. package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  40. package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js +9 -3
  41. package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
  42. package/build/components/global-styles/ui.js +28 -36
  43. package/build/components/global-styles/ui.js.map +1 -1
  44. package/build/components/header-edit-mode/document-actions/index.js +21 -16
  45. package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
  46. package/build/components/header-edit-mode/index.js +2 -1
  47. package/build/components/header-edit-mode/index.js.map +1 -1
  48. package/build/components/header-edit-mode/more-menu/index.js +1 -1
  49. package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
  50. package/build/components/list/added-by.js +43 -54
  51. package/build/components/list/added-by.js.map +1 -1
  52. package/build/components/{page-content-focus-manager → page-content-focus-notifications}/back-to-page-notification.js +9 -8
  53. package/build/components/page-content-focus-notifications/back-to-page-notification.js.map +1 -0
  54. package/build/components/{page-content-focus-manager → page-content-focus-notifications}/edit-template-notification.js +9 -13
  55. package/build/components/page-content-focus-notifications/edit-template-notification.js.map +1 -0
  56. package/build/components/page-content-focus-notifications/index.js +22 -0
  57. package/build/components/page-content-focus-notifications/index.js.map +1 -0
  58. package/build/components/page-pages/index.js +9 -15
  59. package/build/components/page-pages/index.js.map +1 -1
  60. package/build/components/page-patterns/use-patterns.js +1 -1
  61. package/build/components/page-patterns/use-patterns.js.map +1 -1
  62. package/build/components/page-templates/dataviews-templates.js +166 -51
  63. package/build/components/page-templates/dataviews-templates.js.map +1 -1
  64. package/build/components/preferences-modal/index.js +1 -1
  65. package/build/components/preferences-modal/index.js.map +1 -1
  66. package/build/components/save-button/index.js +9 -6
  67. package/build/components/save-button/index.js.map +1 -1
  68. package/build/components/save-hub/index.js +14 -0
  69. package/build/components/save-hub/index.js.map +1 -1
  70. package/build/components/sidebar-dataviews/custom-dataviews-list.js +3 -1
  71. package/build/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
  72. package/build/components/sidebar-dataviews/default-views.js +7 -2
  73. package/build/components/sidebar-dataviews/default-views.js.map +1 -1
  74. package/build/components/sidebar-edit-mode/index.js +6 -5
  75. package/build/components/sidebar-edit-mode/index.js.map +1 -1
  76. package/build/components/sidebar-edit-mode/page-panels/edit-template.js +15 -26
  77. package/build/components/sidebar-edit-mode/page-panels/edit-template.js.map +1 -1
  78. package/build/components/sidebar-edit-mode/page-panels/hooks.js +22 -8
  79. package/build/components/sidebar-edit-mode/page-panels/hooks.js.map +1 -1
  80. package/build/components/sidebar-edit-mode/page-panels/page-status.js +8 -5
  81. package/build/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
  82. package/build/components/sidebar-edit-mode/page-panels/page-summary.js +4 -8
  83. package/build/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
  84. package/build/components/sidebar-edit-mode/page-panels/reset-default-template.js +2 -2
  85. package/build/components/sidebar-edit-mode/page-panels/reset-default-template.js.map +1 -1
  86. package/build/components/sidebar-edit-mode/settings-header/index.js +10 -6
  87. package/build/components/sidebar-edit-mode/settings-header/index.js.map +1 -1
  88. package/build/components/sidebar-navigation-screen-page/index.js +23 -4
  89. package/build/components/sidebar-navigation-screen-page/index.js.map +1 -1
  90. package/build/components/style-book/index.js +22 -12
  91. package/build/components/style-book/index.js.map +1 -1
  92. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +41 -9
  93. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  94. package/build/components/welcome-guide/page.js +2 -2
  95. package/build/components/welcome-guide/page.js.map +1 -1
  96. package/build/components/welcome-guide/template.js +6 -3
  97. package/build/components/welcome-guide/template.js.map +1 -1
  98. package/build/hooks/commands/use-edit-mode-commands.js +24 -14
  99. package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
  100. package/build/store/actions.js +4 -1
  101. package/build/store/actions.js.map +1 -1
  102. package/build/store/private-actions.js +2 -27
  103. package/build/store/private-actions.js.map +1 -1
  104. package/build/store/private-selectors.js +0 -23
  105. package/build/store/private-selectors.js.map +1 -1
  106. package/build/store/reducer.js +1 -40
  107. package/build/store/reducer.js.map +1 -1
  108. package/build/store/selectors.js +8 -4
  109. package/build/store/selectors.js.map +1 -1
  110. package/build/utils/constants.js +1 -12
  111. package/build/utils/constants.js.map +1 -1
  112. package/build-module/components/actions/index.js +55 -36
  113. package/build-module/components/actions/index.js.map +1 -1
  114. package/build-module/components/block-editor/site-editor-canvas.js +7 -2
  115. package/build-module/components/block-editor/site-editor-canvas.js.map +1 -1
  116. package/build-module/components/dataviews/add-filter.js +21 -20
  117. package/build-module/components/dataviews/add-filter.js.map +1 -1
  118. package/build-module/components/dataviews/constants.js +6 -0
  119. package/build-module/components/dataviews/constants.js.map +1 -0
  120. package/build-module/components/dataviews/dataviews.js +9 -7
  121. package/build-module/components/dataviews/dataviews.js.map +1 -1
  122. package/build-module/components/dataviews/filter-summary.js +55 -0
  123. package/build-module/components/dataviews/filter-summary.js.map +1 -0
  124. package/build-module/components/dataviews/filters.js +15 -28
  125. package/build-module/components/dataviews/filters.js.map +1 -1
  126. package/build-module/components/dataviews/item-actions.js +84 -30
  127. package/build-module/components/dataviews/item-actions.js.map +1 -1
  128. package/build-module/components/dataviews/pagination.js +4 -0
  129. package/build-module/components/dataviews/pagination.js.map +1 -1
  130. package/build-module/components/dataviews/view-actions.js +24 -24
  131. package/build-module/components/dataviews/view-actions.js.map +1 -1
  132. package/build-module/components/dataviews/view-grid.js +49 -26
  133. package/build-module/components/dataviews/view-grid.js.map +1 -1
  134. package/build-module/components/dataviews/view-list.js +28 -33
  135. package/build-module/components/dataviews/view-list.js.map +1 -1
  136. package/build-module/components/editor/index.js +26 -30
  137. package/build-module/components/editor/index.js.map +1 -1
  138. package/build-module/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +1 -1
  139. package/build-module/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js.map +1 -1
  140. package/build-module/components/global-styles/font-library-modal/utils/index.js +14 -2
  141. package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  142. package/build-module/components/global-styles/header.js +4 -2
  143. package/build-module/components/global-styles/header.js.map +1 -1
  144. package/build-module/components/global-styles/screen-block-list.js +23 -17
  145. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  146. package/build-module/components/global-styles/screen-revisions/index.js +27 -6
  147. package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
  148. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +51 -24
  149. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  150. package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js +9 -3
  151. package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
  152. package/build-module/components/global-styles/ui.js +28 -36
  153. package/build-module/components/global-styles/ui.js.map +1 -1
  154. package/build-module/components/header-edit-mode/document-actions/index.js +21 -16
  155. package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
  156. package/build-module/components/header-edit-mode/index.js +2 -1
  157. package/build-module/components/header-edit-mode/index.js.map +1 -1
  158. package/build-module/components/header-edit-mode/more-menu/index.js +1 -1
  159. package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
  160. package/build-module/components/list/added-by.js +44 -55
  161. package/build-module/components/list/added-by.js.map +1 -1
  162. package/build-module/components/{page-content-focus-manager → page-content-focus-notifications}/back-to-page-notification.js +9 -8
  163. package/build-module/components/page-content-focus-notifications/back-to-page-notification.js.map +1 -0
  164. package/build-module/components/{page-content-focus-manager → page-content-focus-notifications}/edit-template-notification.js +9 -13
  165. package/build-module/components/page-content-focus-notifications/edit-template-notification.js.map +1 -0
  166. package/build-module/components/page-content-focus-notifications/index.js +14 -0
  167. package/build-module/components/page-content-focus-notifications/index.js.map +1 -0
  168. package/build-module/components/page-pages/index.js +10 -16
  169. package/build-module/components/page-pages/index.js.map +1 -1
  170. package/build-module/components/page-patterns/use-patterns.js +1 -1
  171. package/build-module/components/page-patterns/use-patterns.js.map +1 -1
  172. package/build-module/components/page-templates/dataviews-templates.js +168 -53
  173. package/build-module/components/page-templates/dataviews-templates.js.map +1 -1
  174. package/build-module/components/preferences-modal/index.js +1 -1
  175. package/build-module/components/preferences-modal/index.js.map +1 -1
  176. package/build-module/components/save-button/index.js +11 -8
  177. package/build-module/components/save-button/index.js.map +1 -1
  178. package/build-module/components/save-hub/index.js +14 -0
  179. package/build-module/components/save-hub/index.js.map +1 -1
  180. package/build-module/components/sidebar-dataviews/custom-dataviews-list.js +3 -1
  181. package/build-module/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
  182. package/build-module/components/sidebar-dataviews/default-views.js +7 -2
  183. package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
  184. package/build-module/components/sidebar-edit-mode/index.js +6 -5
  185. package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
  186. package/build-module/components/sidebar-edit-mode/page-panels/edit-template.js +16 -27
  187. package/build-module/components/sidebar-edit-mode/page-panels/edit-template.js.map +1 -1
  188. package/build-module/components/sidebar-edit-mode/page-panels/hooks.js +21 -7
  189. package/build-module/components/sidebar-edit-mode/page-panels/hooks.js.map +1 -1
  190. package/build-module/components/sidebar-edit-mode/page-panels/page-status.js +9 -6
  191. package/build-module/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
  192. package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js +5 -9
  193. package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
  194. package/build-module/components/sidebar-edit-mode/page-panels/reset-default-template.js +3 -3
  195. package/build-module/components/sidebar-edit-mode/page-panels/reset-default-template.js.map +1 -1
  196. package/build-module/components/sidebar-edit-mode/settings-header/index.js +10 -6
  197. package/build-module/components/sidebar-edit-mode/settings-header/index.js.map +1 -1
  198. package/build-module/components/sidebar-navigation-screen-page/index.js +23 -4
  199. package/build-module/components/sidebar-navigation-screen-page/index.js.map +1 -1
  200. package/build-module/components/style-book/index.js +22 -12
  201. package/build-module/components/style-book/index.js.map +1 -1
  202. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +41 -9
  203. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  204. package/build-module/components/welcome-guide/page.js +2 -2
  205. package/build-module/components/welcome-guide/page.js.map +1 -1
  206. package/build-module/components/welcome-guide/template.js +6 -3
  207. package/build-module/components/welcome-guide/template.js.map +1 -1
  208. package/build-module/hooks/commands/use-edit-mode-commands.js +24 -14
  209. package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
  210. package/build-module/store/actions.js +4 -1
  211. package/build-module/store/actions.js.map +1 -1
  212. package/build-module/store/private-actions.js +1 -25
  213. package/build-module/store/private-actions.js.map +1 -1
  214. package/build-module/store/private-selectors.js +0 -22
  215. package/build-module/store/private-selectors.js.map +1 -1
  216. package/build-module/store/reducer.js +1 -38
  217. package/build-module/store/reducer.js.map +1 -1
  218. package/build-module/store/selectors.js +8 -4
  219. package/build-module/store/selectors.js.map +1 -1
  220. package/build-module/utils/constants.js +0 -10
  221. package/build-module/utils/constants.js.map +1 -1
  222. package/build-style/style-rtl.css +152 -62
  223. package/build-style/style.css +152 -62
  224. package/package.json +41 -41
  225. package/src/components/actions/index.js +76 -48
  226. package/src/components/block-editor/site-editor-canvas.js +8 -2
  227. package/src/components/dataviews/README.md +14 -11
  228. package/src/components/dataviews/add-filter.js +21 -24
  229. package/src/components/dataviews/constants.js +5 -0
  230. package/src/components/dataviews/dataviews.js +10 -10
  231. package/src/components/dataviews/filter-summary.js +79 -0
  232. package/src/components/dataviews/filters.js +18 -35
  233. package/src/components/dataviews/item-actions.js +106 -42
  234. package/src/components/dataviews/pagination.js +4 -0
  235. package/src/components/dataviews/style.scss +84 -8
  236. package/src/components/dataviews/view-actions.js +39 -41
  237. package/src/components/dataviews/view-grid.js +63 -38
  238. package/src/components/dataviews/view-list.js +50 -57
  239. package/src/components/editor/index.js +18 -34
  240. package/src/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +1 -1
  241. package/src/components/global-styles/font-library-modal/utils/index.js +20 -9
  242. package/src/components/global-styles/font-library-modal/utils/test/getIntersectingFontFaces.spec.js +46 -15
  243. package/src/components/global-styles/font-library-modal/utils/test/wpKebabCase.spec.js +28 -0
  244. package/src/components/global-styles/header.js +2 -1
  245. package/src/components/global-styles/screen-block-list.js +37 -26
  246. package/src/components/global-styles/screen-revisions/index.js +39 -10
  247. package/src/components/global-styles/screen-revisions/revisions-buttons.js +65 -45
  248. package/src/components/global-styles/screen-revisions/style.scss +52 -28
  249. package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +15 -6
  250. package/src/components/global-styles/style.scss +0 -11
  251. package/src/components/global-styles/ui.js +59 -74
  252. package/src/components/header-edit-mode/document-actions/index.js +20 -18
  253. package/src/components/header-edit-mode/index.js +1 -0
  254. package/src/components/header-edit-mode/more-menu/index.js +1 -1
  255. package/src/components/list/added-by.js +23 -63
  256. package/src/components/list/style.scss +11 -13
  257. package/src/components/{page-content-focus-manager → page-content-focus-notifications}/back-to-page-notification.js +12 -13
  258. package/src/components/{page-content-focus-manager → page-content-focus-notifications}/edit-template-notification.js +9 -13
  259. package/src/components/page-content-focus-notifications/index.js +14 -0
  260. package/src/components/page-pages/index.js +15 -20
  261. package/src/components/page-patterns/use-patterns.js +1 -1
  262. package/src/components/page-templates/dataviews-templates.js +169 -48
  263. package/src/components/page-templates/style.scss +13 -0
  264. package/src/components/preferences-modal/index.js +1 -1
  265. package/src/components/save-button/index.js +37 -24
  266. package/src/components/save-hub/index.js +15 -0
  267. package/src/components/save-hub/style.scss +7 -0
  268. package/src/components/sidebar-dataviews/custom-dataviews-list.js +2 -0
  269. package/src/components/sidebar-dataviews/default-views.js +7 -2
  270. package/src/components/sidebar-dataviews/style.scss +7 -0
  271. package/src/components/sidebar-edit-mode/index.js +13 -9
  272. package/src/components/sidebar-edit-mode/page-panels/edit-template.js +33 -52
  273. package/src/components/sidebar-edit-mode/page-panels/hooks.js +20 -9
  274. package/src/components/sidebar-edit-mode/page-panels/page-status.js +6 -6
  275. package/src/components/sidebar-edit-mode/page-panels/page-summary.js +8 -9
  276. package/src/components/sidebar-edit-mode/page-panels/reset-default-template.js +3 -3
  277. package/src/components/sidebar-edit-mode/page-panels/style.scss +9 -19
  278. package/src/components/sidebar-edit-mode/settings-header/index.js +8 -9
  279. package/src/components/sidebar-navigation-screen/style.scss +1 -0
  280. package/src/components/sidebar-navigation-screen-page/index.js +24 -3
  281. package/src/components/sidebar-navigation-screen-template/style.scss +6 -1
  282. package/src/components/style-book/index.js +48 -35
  283. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +69 -17
  284. package/src/components/welcome-guide/page.js +2 -2
  285. package/src/components/welcome-guide/template.js +4 -2
  286. package/src/hooks/commands/use-edit-mode-commands.js +22 -16
  287. package/src/store/actions.js +5 -1
  288. package/src/store/private-actions.js +1 -24
  289. package/src/store/private-selectors.js +0 -22
  290. package/src/store/reducer.js +0 -39
  291. package/src/store/selectors.js +12 -4
  292. package/src/store/test/actions.js +3 -32
  293. package/src/store/test/reducer.js +0 -62
  294. package/src/store/test/selectors.js +0 -35
  295. package/src/style.scss +1 -0
  296. package/src/utils/constants.js +0 -10
  297. package/build/components/dataviews/in-filter.js +0 -51
  298. package/build/components/dataviews/in-filter.js.map +0 -1
  299. package/build/components/page-content-focus-manager/back-to-page-notification.js.map +0 -1
  300. package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js +0 -63
  301. package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +0 -1
  302. package/build/components/page-content-focus-manager/edit-template-notification.js.map +0 -1
  303. package/build/components/page-content-focus-manager/index.js +0 -61
  304. package/build/components/page-content-focus-manager/index.js.map +0 -1
  305. package/build/components/sidebar-edit-mode/page-panels/publish-date.js +0 -87
  306. package/build/components/sidebar-edit-mode/page-panels/publish-date.js.map +0 -1
  307. package/build-module/components/dataviews/in-filter.js +0 -42
  308. package/build-module/components/dataviews/in-filter.js.map +0 -1
  309. package/build-module/components/page-content-focus-manager/back-to-page-notification.js.map +0 -1
  310. package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js +0 -56
  311. package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +0 -1
  312. package/build-module/components/page-content-focus-manager/edit-template-notification.js.map +0 -1
  313. package/build-module/components/page-content-focus-manager/index.js +0 -52
  314. package/build-module/components/page-content-focus-manager/index.js.map +0 -1
  315. package/build-module/components/sidebar-edit-mode/page-panels/publish-date.js +0 -80
  316. package/build-module/components/sidebar-edit-mode/page-panels/publish-date.js.map +0 -1
  317. package/src/components/dataviews/in-filter.js +0 -63
  318. package/src/components/page-content-focus-manager/disable-non-page-content-blocks.js +0 -57
  319. package/src/components/page-content-focus-manager/index.js +0 -51
  320. package/src/components/sidebar-edit-mode/page-panels/publish-date.js +0 -94
@@ -7,16 +7,16 @@ import classnames from 'classnames';
7
7
  /**
8
8
  * WordPress dependencies
9
9
  */
10
- import { useSelect } from '@wordpress/data';
10
+ import { useSelect, useDispatch } from '@wordpress/data';
11
11
  import { Notice } from '@wordpress/components';
12
12
  import { useInstanceId } from '@wordpress/compose';
13
13
  import { store as preferencesStore } from '@wordpress/preferences';
14
14
  import { BlockBreadcrumb, store as blockEditorStore, privateApis as blockEditorPrivateApis, BlockInspector } from '@wordpress/block-editor';
15
15
  import { InterfaceSkeleton, ComplementaryArea, store as interfaceStore } from '@wordpress/interface';
16
- import { EditorNotices, EditorSnackbars, privateApis as editorPrivateApis } from '@wordpress/editor';
16
+ import { EditorNotices, EditorSnackbars, privateApis as editorPrivateApis, store as editorStore } from '@wordpress/editor';
17
17
  import { __, sprintf } from '@wordpress/i18n';
18
18
  import { store as coreDataStore } from '@wordpress/core-data';
19
- import { useMemo } from '@wordpress/element';
19
+ import { useEffect } from '@wordpress/element';
20
20
 
21
21
  /**
22
22
  * Internal dependencies
@@ -81,23 +81,20 @@ export default function Editor({
81
81
  contextPost,
82
82
  editorMode,
83
83
  canvasMode,
84
+ renderingMode,
84
85
  blockEditorMode,
85
86
  isRightSidebarOpen,
86
87
  isInserterOpen,
87
88
  isListViewOpen,
88
89
  showIconLabels,
89
- showBlockBreadcrumbs,
90
- hasPageContentFocus,
91
- pageContentFocusType
90
+ showBlockBreadcrumbs
92
91
  } = useSelect(select => {
93
92
  const {
94
93
  getEditedPostContext,
95
94
  getEditorMode,
96
95
  getCanvasMode,
97
96
  isInserterOpened,
98
- isListViewOpened,
99
- hasPageContentFocus: _hasPageContentFocus,
100
- getPageContentFocusType
97
+ isListViewOpened
101
98
  } = unlock(select(editSiteStore));
102
99
  const {
103
100
  __unstableGetEditorMode
@@ -108,6 +105,9 @@ export default function Editor({
108
105
  const {
109
106
  getEntityRecord
110
107
  } = select(coreDataStore);
108
+ const {
109
+ getRenderingMode
110
+ } = select(editorStore);
111
111
  const _context = getEditedPostContext();
112
112
 
113
113
  // The currently selected entity to display.
@@ -117,16 +117,18 @@ export default function Editor({
117
117
  contextPost: _context?.postId ? getEntityRecord('postType', _context.postType, _context.postId) : undefined,
118
118
  editorMode: getEditorMode(),
119
119
  canvasMode: getCanvasMode(),
120
+ renderingMode: getRenderingMode(),
120
121
  blockEditorMode: __unstableGetEditorMode(),
121
122
  isInserterOpen: isInserterOpened(),
122
123
  isListViewOpen: isListViewOpened(),
123
124
  isRightSidebarOpen: getActiveComplementaryArea(editSiteStore.name),
124
125
  showIconLabels: select(preferencesStore).get('core/edit-site', 'showIconLabels'),
125
- showBlockBreadcrumbs: select(preferencesStore).get('core/edit-site', 'showBlockBreadcrumbs'),
126
- hasPageContentFocus: _hasPageContentFocus(),
127
- pageContentFocusType: getPageContentFocusType()
126
+ showBlockBreadcrumbs: select(preferencesStore).get('core/edit-site', 'showBlockBreadcrumbs')
128
127
  };
129
128
  }, []);
129
+ const {
130
+ setRenderingMode
131
+ } = useDispatch(editorStore);
130
132
  const isViewMode = canvasMode === 'view';
131
133
  const isEditMode = canvasMode === 'edit';
132
134
  const showVisualEditor = isViewMode || editorMode === 'visual';
@@ -134,7 +136,7 @@ export default function Editor({
134
136
  const shouldShowInserter = isEditMode && showVisualEditor && isInserterOpen;
135
137
  const shouldShowListView = isEditMode && showVisualEditor && isListViewOpen;
136
138
  const secondarySidebarLabel = isListViewOpen ? __('List View') : __('Block Library');
137
- const postWithTemplate = context?.postId;
139
+ const postWithTemplate = !!context?.postId;
138
140
  let title;
139
141
  if (hasLoadedPost) {
140
142
  var _POST_TYPE_LABELS$edi;
@@ -149,21 +151,16 @@ export default function Editor({
149
151
  const loadingProgressId = useInstanceId(CanvasLoader, 'edit-site-editor__loading-progress');
150
152
  const settings = useSpecificEditorSettings();
151
153
  const isReady = !isLoading && (postWithTemplate && !!contextPost && !!editedPost || !postWithTemplate && !!editedPost);
152
- const mode = useMemo(() => {
153
- if (isViewMode) {
154
- return postWithTemplate ? 'template-locked' : 'all';
155
- }
156
- if (isEditMode && pageContentFocusType === 'hideTemplate') {
157
- return 'post-only';
158
- }
159
- if (postWithTemplate && hasPageContentFocus) {
160
- return 'template-locked';
161
- }
162
- if (postWithTemplate && !hasPageContentFocus) {
163
- return 'template-only';
154
+
155
+ // This is the only reliable way I've found to reinitialize the rendering mode
156
+ // when the canvas mode or the edited entity changes.
157
+ useEffect(() => {
158
+ if (canvasMode === 'edit' && postWithTemplate) {
159
+ setRenderingMode('template-locked');
160
+ } else {
161
+ setRenderingMode('all');
164
162
  }
165
- return 'all';
166
- }, [isViewMode, isEditMode, postWithTemplate, pageContentFocusType, hasPageContentFocus]);
163
+ }, [canvasMode, postWithTemplate, setRenderingMode]);
167
164
  return createElement(Fragment, null, !isReady ? createElement(CanvasLoader, {
168
165
  id: loadingProgressId
169
166
  }) : null, isEditMode && createElement(WelcomeGuide, null), hasLoadedPost && !editedPost && createElement(Notice, {
@@ -173,8 +170,7 @@ export default function Editor({
173
170
  post: postWithTemplate ? contextPost : editedPost,
174
171
  __unstableTemplate: postWithTemplate ? editedPost : undefined,
175
172
  settings: settings,
176
- useSubRegistry: false,
177
- mode: mode
173
+ useSubRegistry: false
178
174
  }, createElement(SidebarComplementaryAreaFills, null), isEditMode && createElement(StartTemplateOptions, null), createElement(InterfaceSkeleton, {
179
175
  isDistractionFree: true,
180
176
  enableRegionNavigation: false,
@@ -192,7 +188,7 @@ export default function Editor({
192
188
  scope: "core/edit-site"
193
189
  }), createElement(SidebarFixedBottomSlot, null)),
194
190
  footer: shouldShowBlockBreadcrumbs && createElement(BlockBreadcrumb, {
195
- rootLabelText: hasPageContentFocus ? __('Page') : __('Template')
191
+ rootLabelText: postWithTemplate && renderingMode !== 'template-only' ? __('Page') : __('Template')
196
192
  }),
197
193
  labels: {
198
194
  ...interfaceLabels,
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","useSelect","Notice","useInstanceId","store","preferencesStore","BlockBreadcrumb","blockEditorStore","privateApis","blockEditorPrivateApis","BlockInspector","InterfaceSkeleton","ComplementaryArea","interfaceStore","EditorNotices","EditorSnackbars","editorPrivateApis","__","sprintf","coreDataStore","useMemo","SidebarComplementaryAreaFills","SidebarInspectorFill","CodeEditor","KeyboardShortcutsEditMode","InserterSidebar","ListViewSidebar","WelcomeGuide","StartTemplateOptions","editSiteStore","GlobalStylesRenderer","useTitle","CanvasLoader","unlock","useEditedEntityRecord","SidebarFixedBottomSlot","PatternModal","POST_TYPE_LABELS","TEMPLATE_POST_TYPE","SiteEditorCanvas","TemplatePartConverter","useSpecificEditorSettings","BlockRemovalWarningModal","ExperimentalEditorProvider","EditorProvider","interfaceLabels","body","sidebar","actions","footer","blockRemovalRules","Editor","listViewToggleElement","isLoading","record","editedPost","getTitle","isLoaded","hasLoadedPost","type","editedPostType","context","contextPost","editorMode","canvasMode","blockEditorMode","isRightSidebarOpen","isInserterOpen","isListViewOpen","showIconLabels","showBlockBreadcrumbs","hasPageContentFocus","pageContentFocusType","select","getEditedPostContext","getEditorMode","getCanvasMode","isInserterOpened","isListViewOpened","_hasPageContentFocus","getPageContentFocusType","__unstableGetEditorMode","getActiveComplementaryArea","getEntityRecord","_context","postId","postType","undefined","name","get","isViewMode","isEditMode","showVisualEditor","shouldShowBlockBreadcrumbs","shouldShowInserter","shouldShowListView","secondarySidebarLabel","postWithTemplate","title","_POST_TYPE_LABELS$edi","loadingProgressId","settings","isReady","mode","createElement","Fragment","id","status","isDismissible","post","__unstableTemplate","useSubRegistry","isDistractionFree","enableRegionNavigation","className","notices","content","rules","secondarySidebar","Slot","scope","rootLabelText","labels"],"sources":["@wordpress/edit-site/src/components/editor/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { Notice } from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tBlockBreadcrumb,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n\tBlockInspector,\n} from '@wordpress/block-editor';\nimport {\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport {\n\tEditorNotices,\n\tEditorSnackbars,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tSidebarComplementaryAreaFills,\n\tSidebarInspectorFill,\n} from '../sidebar-edit-mode';\nimport CodeEditor from '../code-editor';\nimport KeyboardShortcutsEditMode from '../keyboard-shortcuts/edit-mode';\nimport InserterSidebar from '../secondary-sidebar/inserter-sidebar';\nimport ListViewSidebar from '../secondary-sidebar/list-view-sidebar';\nimport WelcomeGuide from '../welcome-guide';\nimport StartTemplateOptions from '../start-template-options';\nimport { store as editSiteStore } from '../../store';\nimport { GlobalStylesRenderer } from '../global-styles-renderer';\nimport useTitle from '../routes/use-title';\nimport CanvasLoader from '../canvas-loader';\nimport { unlock } from '../../lock-unlock';\nimport useEditedEntityRecord from '../use-edited-entity-record';\nimport { SidebarFixedBottomSlot } from '../sidebar-edit-mode/sidebar-fixed-bottom';\nimport PatternModal from '../pattern-modal';\nimport { POST_TYPE_LABELS, TEMPLATE_POST_TYPE } from '../../utils/constants';\nimport SiteEditorCanvas from '../block-editor/site-editor-canvas';\nimport TemplatePartConverter from '../template-part-converter';\nimport { useSpecificEditorSettings } from '../block-editor/use-site-editor-settings';\n\nconst { BlockRemovalWarningModal } = unlock( blockEditorPrivateApis );\nconst { ExperimentalEditorProvider: EditorProvider } =\n\tunlock( editorPrivateApis );\n\nconst interfaceLabels = {\n\t/* translators: accessibility text for the editor content landmark region. */\n\tbody: __( 'Editor content' ),\n\t/* translators: accessibility text for the editor settings landmark region. */\n\tsidebar: __( 'Editor settings' ),\n\t/* translators: accessibility text for the editor publish landmark region. */\n\tactions: __( 'Editor publish' ),\n\t/* translators: accessibility text for the editor footer landmark region. */\n\tfooter: __( 'Editor footer' ),\n};\n\n// Prevent accidental removal of certain blocks, asking the user for\n// confirmation.\nconst blockRemovalRules = {\n\t'core/query': __( 'Query Loop displays a list of posts or pages.' ),\n\t'core/post-content': __(\n\t\t'Post Content displays the content of a post or page.'\n\t),\n\t'core/post-template': __(\n\t\t'Post Template displays each post or page in a Query Loop.'\n\t),\n};\n\nexport default function Editor( { listViewToggleElement, isLoading } ) {\n\tconst {\n\t\trecord: editedPost,\n\t\tgetTitle,\n\t\tisLoaded: hasLoadedPost,\n\t} = useEditedEntityRecord();\n\n\tconst { type: editedPostType } = editedPost;\n\n\tconst {\n\t\tcontext,\n\t\tcontextPost,\n\t\teditorMode,\n\t\tcanvasMode,\n\t\tblockEditorMode,\n\t\tisRightSidebarOpen,\n\t\tisInserterOpen,\n\t\tisListViewOpen,\n\t\tshowIconLabels,\n\t\tshowBlockBreadcrumbs,\n\t\thasPageContentFocus,\n\t\tpageContentFocusType,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetEditedPostContext,\n\t\t\tgetEditorMode,\n\t\t\tgetCanvasMode,\n\t\t\tisInserterOpened,\n\t\t\tisListViewOpened,\n\t\t\thasPageContentFocus: _hasPageContentFocus,\n\t\t\tgetPageContentFocusType,\n\t\t} = unlock( select( editSiteStore ) );\n\t\tconst { __unstableGetEditorMode } = select( blockEditorStore );\n\t\tconst { getActiveComplementaryArea } = select( interfaceStore );\n\t\tconst { getEntityRecord } = select( coreDataStore );\n\t\tconst _context = getEditedPostContext();\n\n\t\t// The currently selected entity to display.\n\t\t// Typically template or template part in the site editor.\n\t\treturn {\n\t\t\tcontext: _context,\n\t\t\tcontextPost: _context?.postId\n\t\t\t\t? getEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t_context.postType,\n\t\t\t\t\t\t_context.postId\n\t\t\t\t )\n\t\t\t\t: undefined,\n\t\t\teditorMode: getEditorMode(),\n\t\t\tcanvasMode: getCanvasMode(),\n\t\t\tblockEditorMode: __unstableGetEditorMode(),\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tisRightSidebarOpen: getActiveComplementaryArea(\n\t\t\t\teditSiteStore.name\n\t\t\t),\n\t\t\tshowIconLabels: select( preferencesStore ).get(\n\t\t\t\t'core/edit-site',\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t\tshowBlockBreadcrumbs: select( preferencesStore ).get(\n\t\t\t\t'core/edit-site',\n\t\t\t\t'showBlockBreadcrumbs'\n\t\t\t),\n\t\t\thasPageContentFocus: _hasPageContentFocus(),\n\t\t\tpageContentFocusType: getPageContentFocusType(),\n\t\t};\n\t}, [] );\n\n\tconst isViewMode = canvasMode === 'view';\n\tconst isEditMode = canvasMode === 'edit';\n\tconst showVisualEditor = isViewMode || editorMode === 'visual';\n\tconst shouldShowBlockBreadcrumbs =\n\t\tshowBlockBreadcrumbs &&\n\t\tisEditMode &&\n\t\tshowVisualEditor &&\n\t\tblockEditorMode !== 'zoom-out';\n\tconst shouldShowInserter = isEditMode && showVisualEditor && isInserterOpen;\n\tconst shouldShowListView = isEditMode && showVisualEditor && isListViewOpen;\n\tconst secondarySidebarLabel = isListViewOpen\n\t\t? __( 'List View' )\n\t\t: __( 'Block Library' );\n\tconst postWithTemplate = context?.postId;\n\n\tlet title;\n\tif ( hasLoadedPost ) {\n\t\ttitle = sprintf(\n\t\t\t// translators: A breadcrumb trail in browser tab. %1$s: title of template being edited, %2$s: type of template (Template or Template Part).\n\t\t\t__( '%1$s ‹ %2$s ‹ Editor' ),\n\t\t\tgetTitle(),\n\t\t\tPOST_TYPE_LABELS[ editedPostType ] ??\n\t\t\t\tPOST_TYPE_LABELS[ TEMPLATE_POST_TYPE ]\n\t\t);\n\t}\n\n\t// Only announce the title once the editor is ready to prevent \"Replace\"\n\t// action in <URLQueryController> from double-announcing.\n\tuseTitle( hasLoadedPost && title );\n\n\tconst loadingProgressId = useInstanceId(\n\t\tCanvasLoader,\n\t\t'edit-site-editor__loading-progress'\n\t);\n\n\tconst settings = useSpecificEditorSettings();\n\tconst isReady =\n\t\t! isLoading &&\n\t\t( ( postWithTemplate && !! contextPost && !! editedPost ) ||\n\t\t\t( ! postWithTemplate && !! editedPost ) );\n\tconst mode = useMemo( () => {\n\t\tif ( isViewMode ) {\n\t\t\treturn postWithTemplate ? 'template-locked' : 'all';\n\t\t}\n\n\t\tif ( isEditMode && pageContentFocusType === 'hideTemplate' ) {\n\t\t\treturn 'post-only';\n\t\t}\n\n\t\tif ( postWithTemplate && hasPageContentFocus ) {\n\t\t\treturn 'template-locked';\n\t\t}\n\n\t\tif ( postWithTemplate && ! hasPageContentFocus ) {\n\t\t\treturn 'template-only';\n\t\t}\n\n\t\treturn 'all';\n\t}, [\n\t\tisViewMode,\n\t\tisEditMode,\n\t\tpostWithTemplate,\n\t\tpageContentFocusType,\n\t\thasPageContentFocus,\n\t] );\n\n\treturn (\n\t\t<>\n\t\t\t{ ! isReady ? <CanvasLoader id={ loadingProgressId } /> : null }\n\t\t\t{ isEditMode && <WelcomeGuide /> }\n\t\t\t{ hasLoadedPost && ! editedPost && (\n\t\t\t\t<Notice status=\"warning\" isDismissible={ false }>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t\"You attempted to edit an item that doesn't exist. Perhaps it was deleted?\"\n\t\t\t\t\t) }\n\t\t\t\t</Notice>\n\t\t\t) }\n\t\t\t{ isReady && (\n\t\t\t\t<EditorProvider\n\t\t\t\t\tpost={ postWithTemplate ? contextPost : editedPost }\n\t\t\t\t\t__unstableTemplate={\n\t\t\t\t\t\tpostWithTemplate ? editedPost : undefined\n\t\t\t\t\t}\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\tmode={ mode }\n\t\t\t\t>\n\t\t\t\t\t<SidebarComplementaryAreaFills />\n\t\t\t\t\t{ isEditMode && <StartTemplateOptions /> }\n\t\t\t\t\t<InterfaceSkeleton\n\t\t\t\t\t\tisDistractionFree={ true }\n\t\t\t\t\t\tenableRegionNavigation={ false }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'edit-site-editor__interface-skeleton',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'show-icon-labels': showIconLabels,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tnotices={ <EditorSnackbars /> }\n\t\t\t\t\t\tcontent={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<GlobalStylesRenderer />\n\t\t\t\t\t\t\t\t{ isEditMode && <EditorNotices /> }\n\t\t\t\t\t\t\t\t{ showVisualEditor && (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<TemplatePartConverter />\n\t\t\t\t\t\t\t\t\t\t<SidebarInspectorFill>\n\t\t\t\t\t\t\t\t\t\t\t<BlockInspector />\n\t\t\t\t\t\t\t\t\t\t</SidebarInspectorFill>\n\t\t\t\t\t\t\t\t\t\t<SiteEditorCanvas />\n\t\t\t\t\t\t\t\t\t\t<BlockRemovalWarningModal\n\t\t\t\t\t\t\t\t\t\t\trules={ blockRemovalRules }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<PatternModal />\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{ editorMode === 'text' && isEditMode && (\n\t\t\t\t\t\t\t\t\t<CodeEditor />\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ isEditMode && <KeyboardShortcutsEditMode /> }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsecondarySidebar={\n\t\t\t\t\t\t\tisEditMode &&\n\t\t\t\t\t\t\t( ( shouldShowInserter && <InserterSidebar /> ) ||\n\t\t\t\t\t\t\t\t( shouldShowListView && (\n\t\t\t\t\t\t\t\t\t<ListViewSidebar\n\t\t\t\t\t\t\t\t\t\tlistViewToggleElement={\n\t\t\t\t\t\t\t\t\t\t\tlistViewToggleElement\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}\n\t\t\t\t\t\tsidebar={\n\t\t\t\t\t\t\tisEditMode &&\n\t\t\t\t\t\t\tisRightSidebarOpen && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<ComplementaryArea.Slot scope=\"core/edit-site\" />\n\t\t\t\t\t\t\t\t\t<SidebarFixedBottomSlot />\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfooter={\n\t\t\t\t\t\t\tshouldShowBlockBreadcrumbs && (\n\t\t\t\t\t\t\t\t<BlockBreadcrumb\n\t\t\t\t\t\t\t\t\trootLabelText={\n\t\t\t\t\t\t\t\t\t\thasPageContentFocus\n\t\t\t\t\t\t\t\t\t\t\t? __( 'Page' )\n\t\t\t\t\t\t\t\t\t\t\t: __( 'Template' )\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}\n\t\t\t\t\t\tlabels={ {\n\t\t\t\t\t\t\t...interfaceLabels,\n\t\t\t\t\t\t\tsecondarySidebar: secondarySidebarLabel,\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</EditorProvider>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,wBAAwB;AAClE,SACCC,eAAe,EACfF,KAAK,IAAIG,gBAAgB,EACzBC,WAAW,IAAIC,sBAAsB,EACrCC,cAAc,QACR,yBAAyB;AAChC,SACCC,iBAAiB,EACjBC,iBAAiB,EACjBR,KAAK,IAAIS,cAAc,QACjB,sBAAsB;AAC7B,SACCC,aAAa,EACbC,eAAe,EACfP,WAAW,IAAIQ,iBAAiB,QAC1B,mBAAmB;AAC1B,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASd,KAAK,IAAIe,aAAa,QAAQ,sBAAsB;AAC7D,SAASC,OAAO,QAAQ,oBAAoB;;AAE5C;AACA;AACA;AACA,SACCC,6BAA6B,EAC7BC,oBAAoB,QACd,sBAAsB;AAC7B,OAAOC,UAAU,MAAM,gBAAgB;AACvC,OAAOC,yBAAyB,MAAM,iCAAiC;AACvE,OAAOC,eAAe,MAAM,uCAAuC;AACnE,OAAOC,eAAe,MAAM,wCA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ACjBsC,aAAA,CAAAC,QAAA,QACCD,aAAA,CAAC5F,iBAAiB,CAAC2G,IAAI;MAACC,KAAK,EAAC;IAAgB,CAAE,CAAC,EACjDhB,aAAA,CAACrE,sBAAsB,MAAE,CACxB,CAEH;IACDc,MAAM,EACL4C,0BAA0B,IACzBW,aAAA,CAAClG,eAAe;MACfmH,aAAa,EACZlD,mBAAmB,GAChBtD,EAAE,CAAE,MAAO,CAAC,GACZA,EAAE,CAAE,UAAW;IAClB,CACD,CAEF;IACDyG,MAAM,EAAG;MACR,GAAG7E,eAAe;MAClByE,gBAAgB,EAAEtB;IACnB;EAAG,CACH,CACc,CAEhB,CAAC;AAEL"}
1
+ {"version":3,"names":["classnames","useSelect","useDispatch","Notice","useInstanceId","store","preferencesStore","BlockBreadcrumb","blockEditorStore","privateApis","blockEditorPrivateApis","BlockInspector","InterfaceSkeleton","ComplementaryArea","interfaceStore","EditorNotices","EditorSnackbars","editorPrivateApis","editorStore","__","sprintf","coreDataStore","useEffect","SidebarComplementaryAreaFills","SidebarInspectorFill","CodeEditor","KeyboardShortcutsEditMode","InserterSidebar","ListViewSidebar","WelcomeGuide","StartTemplateOptions","editSiteStore","GlobalStylesRenderer","useTitle","CanvasLoader","unlock","useEditedEntityRecord","SidebarFixedBottomSlot","PatternModal","POST_TYPE_LABELS","TEMPLATE_POST_TYPE","SiteEditorCanvas","TemplatePartConverter","useSpecificEditorSettings","BlockRemovalWarningModal","ExperimentalEditorProvider","EditorProvider","interfaceLabels","body","sidebar","actions","footer","blockRemovalRules","Editor","listViewToggleElement","isLoading","record","editedPost","getTitle","isLoaded","hasLoadedPost","type","editedPostType","context","contextPost","editorMode","canvasMode","renderingMode","blockEditorMode","isRightSidebarOpen","isInserterOpen","isListViewOpen","showIconLabels","showBlockBreadcrumbs","select","getEditedPostContext","getEditorMode","getCanvasMode","isInserterOpened","isListViewOpened","__unstableGetEditorMode","getActiveComplementaryArea","getEntityRecord","getRenderingMode","_context","postId","postType","undefined","name","get","setRenderingMode","isViewMode","isEditMode","showVisualEditor","shouldShowBlockBreadcrumbs","shouldShowInserter","shouldShowListView","secondarySidebarLabel","postWithTemplate","title","_POST_TYPE_LABELS$edi","loadingProgressId","settings","isReady","createElement","Fragment","id","status","isDismissible","post","__unstableTemplate","useSubRegistry","isDistractionFree","enableRegionNavigation","className","notices","content","rules","secondarySidebar","Slot","scope","rootLabelText","labels"],"sources":["@wordpress/edit-site/src/components/editor/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Notice } from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tBlockBreadcrumb,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n\tBlockInspector,\n} from '@wordpress/block-editor';\nimport {\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport {\n\tEditorNotices,\n\tEditorSnackbars,\n\tprivateApis as editorPrivateApis,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tSidebarComplementaryAreaFills,\n\tSidebarInspectorFill,\n} from '../sidebar-edit-mode';\nimport CodeEditor from '../code-editor';\nimport KeyboardShortcutsEditMode from '../keyboard-shortcuts/edit-mode';\nimport InserterSidebar from '../secondary-sidebar/inserter-sidebar';\nimport ListViewSidebar from '../secondary-sidebar/list-view-sidebar';\nimport WelcomeGuide from '../welcome-guide';\nimport StartTemplateOptions from '../start-template-options';\nimport { store as editSiteStore } from '../../store';\nimport { GlobalStylesRenderer } from '../global-styles-renderer';\nimport useTitle from '../routes/use-title';\nimport CanvasLoader from '../canvas-loader';\nimport { unlock } from '../../lock-unlock';\nimport useEditedEntityRecord from '../use-edited-entity-record';\nimport { SidebarFixedBottomSlot } from '../sidebar-edit-mode/sidebar-fixed-bottom';\nimport PatternModal from '../pattern-modal';\nimport { POST_TYPE_LABELS, TEMPLATE_POST_TYPE } from '../../utils/constants';\nimport SiteEditorCanvas from '../block-editor/site-editor-canvas';\nimport TemplatePartConverter from '../template-part-converter';\nimport { useSpecificEditorSettings } from '../block-editor/use-site-editor-settings';\n\nconst { BlockRemovalWarningModal } = unlock( blockEditorPrivateApis );\nconst { ExperimentalEditorProvider: EditorProvider } =\n\tunlock( editorPrivateApis );\n\nconst interfaceLabels = {\n\t/* translators: accessibility text for the editor content landmark region. */\n\tbody: __( 'Editor content' ),\n\t/* translators: accessibility text for the editor settings landmark region. */\n\tsidebar: __( 'Editor settings' ),\n\t/* translators: accessibility text for the editor publish landmark region. */\n\tactions: __( 'Editor publish' ),\n\t/* translators: accessibility text for the editor footer landmark region. */\n\tfooter: __( 'Editor footer' ),\n};\n\n// Prevent accidental removal of certain blocks, asking the user for\n// confirmation.\nconst blockRemovalRules = {\n\t'core/query': __( 'Query Loop displays a list of posts or pages.' ),\n\t'core/post-content': __(\n\t\t'Post Content displays the content of a post or page.'\n\t),\n\t'core/post-template': __(\n\t\t'Post Template displays each post or page in a Query Loop.'\n\t),\n};\n\nexport default function Editor( { listViewToggleElement, isLoading } ) {\n\tconst {\n\t\trecord: editedPost,\n\t\tgetTitle,\n\t\tisLoaded: hasLoadedPost,\n\t} = useEditedEntityRecord();\n\n\tconst { type: editedPostType } = editedPost;\n\n\tconst {\n\t\tcontext,\n\t\tcontextPost,\n\t\teditorMode,\n\t\tcanvasMode,\n\t\trenderingMode,\n\t\tblockEditorMode,\n\t\tisRightSidebarOpen,\n\t\tisInserterOpen,\n\t\tisListViewOpen,\n\t\tshowIconLabels,\n\t\tshowBlockBreadcrumbs,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetEditedPostContext,\n\t\t\tgetEditorMode,\n\t\t\tgetCanvasMode,\n\t\t\tisInserterOpened,\n\t\t\tisListViewOpened,\n\t\t} = unlock( select( editSiteStore ) );\n\t\tconst { __unstableGetEditorMode } = select( blockEditorStore );\n\t\tconst { getActiveComplementaryArea } = select( interfaceStore );\n\t\tconst { getEntityRecord } = select( coreDataStore );\n\t\tconst { getRenderingMode } = select( editorStore );\n\t\tconst _context = getEditedPostContext();\n\n\t\t// The currently selected entity to display.\n\t\t// Typically template or template part in the site editor.\n\t\treturn {\n\t\t\tcontext: _context,\n\t\t\tcontextPost: _context?.postId\n\t\t\t\t? getEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t_context.postType,\n\t\t\t\t\t\t_context.postId\n\t\t\t\t )\n\t\t\t\t: undefined,\n\t\t\teditorMode: getEditorMode(),\n\t\t\tcanvasMode: getCanvasMode(),\n\t\t\trenderingMode: getRenderingMode(),\n\t\t\tblockEditorMode: __unstableGetEditorMode(),\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tisRightSidebarOpen: getActiveComplementaryArea(\n\t\t\t\teditSiteStore.name\n\t\t\t),\n\t\t\tshowIconLabels: select( preferencesStore ).get(\n\t\t\t\t'core/edit-site',\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t\tshowBlockBreadcrumbs: select( preferencesStore ).get(\n\t\t\t\t'core/edit-site',\n\t\t\t\t'showBlockBreadcrumbs'\n\t\t\t),\n\t\t};\n\t}, [] );\n\tconst { setRenderingMode } = useDispatch( editorStore );\n\n\tconst isViewMode = canvasMode === 'view';\n\tconst isEditMode = canvasMode === 'edit';\n\tconst showVisualEditor = isViewMode || editorMode === 'visual';\n\tconst shouldShowBlockBreadcrumbs =\n\t\tshowBlockBreadcrumbs &&\n\t\tisEditMode &&\n\t\tshowVisualEditor &&\n\t\tblockEditorMode !== 'zoom-out';\n\tconst shouldShowInserter = isEditMode && showVisualEditor && isInserterOpen;\n\tconst shouldShowListView = isEditMode && showVisualEditor && isListViewOpen;\n\tconst secondarySidebarLabel = isListViewOpen\n\t\t? __( 'List View' )\n\t\t: __( 'Block Library' );\n\tconst postWithTemplate = !! context?.postId;\n\n\tlet title;\n\tif ( hasLoadedPost ) {\n\t\ttitle = sprintf(\n\t\t\t// translators: A breadcrumb trail in browser tab. %1$s: title of template being edited, %2$s: type of template (Template or Template Part).\n\t\t\t__( '%1$s ‹ %2$s ‹ Editor' ),\n\t\t\tgetTitle(),\n\t\t\tPOST_TYPE_LABELS[ editedPostType ] ??\n\t\t\t\tPOST_TYPE_LABELS[ TEMPLATE_POST_TYPE ]\n\t\t);\n\t}\n\n\t// Only announce the title once the editor is ready to prevent \"Replace\"\n\t// action in <URLQueryController> from double-announcing.\n\tuseTitle( hasLoadedPost && title );\n\n\tconst loadingProgressId = useInstanceId(\n\t\tCanvasLoader,\n\t\t'edit-site-editor__loading-progress'\n\t);\n\n\tconst settings = useSpecificEditorSettings();\n\tconst isReady =\n\t\t! isLoading &&\n\t\t( ( postWithTemplate && !! contextPost && !! editedPost ) ||\n\t\t\t( ! postWithTemplate && !! editedPost ) );\n\n\t// This is the only reliable way I've found to reinitialize the rendering mode\n\t// when the canvas mode or the edited entity changes.\n\tuseEffect( () => {\n\t\tif ( canvasMode === 'edit' && postWithTemplate ) {\n\t\t\tsetRenderingMode( 'template-locked' );\n\t\t} else {\n\t\t\tsetRenderingMode( 'all' );\n\t\t}\n\t}, [ canvasMode, postWithTemplate, setRenderingMode ] );\n\n\treturn (\n\t\t<>\n\t\t\t{ ! isReady ? <CanvasLoader id={ loadingProgressId } /> : null }\n\t\t\t{ isEditMode && <WelcomeGuide /> }\n\t\t\t{ hasLoadedPost && ! editedPost && (\n\t\t\t\t<Notice status=\"warning\" isDismissible={ false }>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t\"You attempted to edit an item that doesn't exist. Perhaps it was deleted?\"\n\t\t\t\t\t) }\n\t\t\t\t</Notice>\n\t\t\t) }\n\t\t\t{ isReady && (\n\t\t\t\t<EditorProvider\n\t\t\t\t\tpost={ postWithTemplate ? contextPost : editedPost }\n\t\t\t\t\t__unstableTemplate={\n\t\t\t\t\t\tpostWithTemplate ? editedPost : undefined\n\t\t\t\t\t}\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t>\n\t\t\t\t\t<SidebarComplementaryAreaFills />\n\t\t\t\t\t{ isEditMode && <StartTemplateOptions /> }\n\t\t\t\t\t<InterfaceSkeleton\n\t\t\t\t\t\tisDistractionFree={ true }\n\t\t\t\t\t\tenableRegionNavigation={ false }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'edit-site-editor__interface-skeleton',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'show-icon-labels': showIconLabels,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tnotices={ <EditorSnackbars /> }\n\t\t\t\t\t\tcontent={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<GlobalStylesRenderer />\n\t\t\t\t\t\t\t\t{ isEditMode && <EditorNotices /> }\n\t\t\t\t\t\t\t\t{ showVisualEditor && (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<TemplatePartConverter />\n\t\t\t\t\t\t\t\t\t\t<SidebarInspectorFill>\n\t\t\t\t\t\t\t\t\t\t\t<BlockInspector />\n\t\t\t\t\t\t\t\t\t\t</SidebarInspectorFill>\n\t\t\t\t\t\t\t\t\t\t<SiteEditorCanvas />\n\t\t\t\t\t\t\t\t\t\t<BlockRemovalWarningModal\n\t\t\t\t\t\t\t\t\t\t\trules={ blockRemovalRules }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<PatternModal />\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{ editorMode === 'text' && isEditMode && (\n\t\t\t\t\t\t\t\t\t<CodeEditor />\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ isEditMode && <KeyboardShortcutsEditMode /> }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsecondarySidebar={\n\t\t\t\t\t\t\tisEditMode &&\n\t\t\t\t\t\t\t( ( shouldShowInserter && <InserterSidebar /> ) ||\n\t\t\t\t\t\t\t\t( shouldShowListView && (\n\t\t\t\t\t\t\t\t\t<ListViewSidebar\n\t\t\t\t\t\t\t\t\t\tlistViewToggleElement={\n\t\t\t\t\t\t\t\t\t\t\tlistViewToggleElement\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}\n\t\t\t\t\t\tsidebar={\n\t\t\t\t\t\t\tisEditMode &&\n\t\t\t\t\t\t\tisRightSidebarOpen && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<ComplementaryArea.Slot scope=\"core/edit-site\" />\n\t\t\t\t\t\t\t\t\t<SidebarFixedBottomSlot />\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfooter={\n\t\t\t\t\t\t\tshouldShowBlockBreadcrumbs && (\n\t\t\t\t\t\t\t\t<BlockBreadcrumb\n\t\t\t\t\t\t\t\t\trootLabelText={\n\t\t\t\t\t\t\t\t\t\tpostWithTemplate &&\n\t\t\t\t\t\t\t\t\t\trenderingMode !== 'template-only'\n\t\t\t\t\t\t\t\t\t\t\t? __( 'Page' )\n\t\t\t\t\t\t\t\t\t\t\t: __( 'Template' )\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}\n\t\t\t\t\t\tlabels={ {\n\t\t\t\t\t\t\t...interfaceLabels,\n\t\t\t\t\t\t\tsecondarySidebar: secondarySidebarLabel,\n\t\t\t\t\t\t} }\n\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,CAACzF,aAAa,MAAE,CAAC,EAC/B8E,gBAAgB,IACjBW,aAAA,CAAAC,QAAA,QACCD,aAAA,CAAC9D,qBAAqB,MAAE,CAAC,EACzB8D,aAAA,CAAChF,oBAAoB,QACpBgF,aAAA,CAAC7F,cAAc,MAAE,CACI,CAAC,EACvB6F,aAAA,CAAC/D,gBAAgB,MAAE,CAAC,EACpB+D,aAAA,CAAC5D,wBAAwB;MACxByE,KAAK,EAAGjE;IAAmB,CAC3B,CAAC,EACFoD,aAAA,CAAClE,YAAY,MAAE,CACd,CACF,EACC2B,UAAU,KAAK,MAAM,IAAI2B,UAAU,IACpCY,aAAA,CAAC/E,UAAU,MAAE,CACb,EACCmE,UAAU,IAAIY,aAAA,CAAC9E,yBAAyB,MAAE,CAC3C,CACF;IACD4F,gBAAgB,EACf1B,UAAU,KACNG,kBAAkB,IAAIS,aAAA,CAAC7E,eAAe,MAAE,CAAC,IAC1CqE,kBAAkB,IACnBQ,aAAA,CAAC5E,eAAe;MACf0B,qBAAqB,EACpBA;IACA,CACD,CACC,CACJ;IACDL,OAAO,EACN2C,UAAU,IACVvB,kBAAkB,IACjBmC,aAAA,CAAAC,QAAA,QACCD,aAAA,CAAC3F,iBAAiB,CAAC0G,IAAI;MAACC,KAAK,EAAC;IAAgB,CAAE,CAAC,EACjDhB,aAAA,CAACnE,sBAAsB,MAAE,CACxB,CAEH;IACDc,MAAM,EACL2C,0BAA0B,IACzBU,aAAA,CAACjG,eAAe;MACfkH,aAAa,EACZvB,gBAAgB,IAChB/B,aAAa,KAAK,eAAe,GAC9BhD,EAAE,CAAE,MAAO,CAAC,GACZA,EAAE,CAAE,UAAW;IAClB,CACD,CAEF;IACDuG,MAAM,EAAG;MACR,GAAG3E,eAAe;MAClBuE,gBAAgB,EAAErB;IACnB;EAAG,CACH,CACc,CAEhB,CAAC;AAEL"}
@@ -39,7 +39,7 @@ export default function getIntersectingFontFaces(incoming, existing) {
39
39
  });
40
40
  });
41
41
  matches.push({
42
- ...existingFont,
42
+ ...incomingFont,
43
43
  fontFace: matchingFaces
44
44
  });
45
45
  } else {
@@ -1 +1 @@
1
- {"version":3,"names":["getIntersectingFontFaces","incoming","existing","matches","incomingFont","existingFont","find","f","slug","fontFace","matchingFaces","filter","face","fontWeight","fontStyle","push"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js"],"sourcesContent":["/**\n * Retrieves intersecting font faces between two sets of fonts.\n *\n * For each font in the `incoming` list, the function checks for a corresponding match\n * in the `existing` list based on the `slug` property. If a match is found and both\n * have `fontFace` properties, it further narrows down to matching font faces based on\n * the `fontWeight` and `fontStyle`. The result includes the properties of the matched\n * existing font but only with intersecting font faces.\n *\n * @param {Array.<{ slug: string, fontFace?: Array.<{ fontWeight: string, fontStyle: string }> }>} incoming - The list of fonts to compare.\n * @param {Array.<{ slug: string, fontFace?: Array.<{ fontWeight: string, fontStyle: string }> }>} existing - The reference list of fonts.\n *\n * @return {Array.<{ slug: string, fontFace?: Array.<{ fontWeight: string, fontStyle: string }> }>} An array of fonts from the `existing` list with intersecting font faces.\n *\n * @example\n * const incomingFonts = [\n * { slug: 'arial', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }] },\n * { slug: 'times-new', fontFace: [{ fontWeight: '700', fontStyle: 'italic' }] }\n * ];\n *\n * const existingFonts = [\n * { slug: 'arial', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }, { fontWeight: '700', fontStyle: 'italic' }] },\n * { slug: 'helvetica', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }] }\n * ];\n *\n * getIntersectingFontFaces(incomingFonts, existingFonts);\n * // Returns:\n * // [{ slug: 'arial', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }] }]\n */\nexport default function getIntersectingFontFaces( incoming, existing ) {\n\tconst matches = [];\n\n\tfor ( const incomingFont of incoming ) {\n\t\tconst existingFont = existing.find(\n\t\t\t( f ) => f.slug === incomingFont.slug\n\t\t);\n\n\t\tif ( existingFont ) {\n\t\t\tif ( incomingFont?.fontFace ) {\n\t\t\t\tconst matchingFaces = incomingFont.fontFace.filter(\n\t\t\t\t\t( face ) => {\n\t\t\t\t\t\treturn ( existingFont?.fontFace || [] ).find( ( f ) => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\tf.fontWeight === face.fontWeight &&\n\t\t\t\t\t\t\t\tf.fontStyle === face.fontStyle\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\tmatches.push( { ...existingFont, fontFace: matchingFaces } );\n\t\t\t} else {\n\t\t\t\tmatches.push( incomingFont );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn matches;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,wBAAwBA,CAAEC,QAAQ,EAAEC,QAAQ,EAAG;EACtE,MAAMC,OAAO,GAAG,EAAE;EAElB,KAAM,MAAMC,YAAY,IAAIH,QAAQ,EAAG;IACtC,MAAMI,YAAY,GAAGH,QAAQ,CAACI,IAAI,CAC/BC,CAAC,IAAMA,CAAC,CAACC,IAAI,KAAKJ,YAAY,CAACI,IAClC,CAAC;IAED,IAAKH,YAAY,EAAG;MACnB,IAAKD,YAAY,EAAEK,QAAQ,EAAG;QAC7B,MAAMC,aAAa,GAAGN,YAAY,CAACK,QAAQ,CAACE,MAAM,CAC/CC,IAAI,IAAM;UACX,OAAO,CAAEP,YAAY,EAAEI,QAAQ,IAAI,EAAE,EAAGH,IAAI,CAAIC,CAAC,IAAM;YACtD,OACCA,CAAC,CAACM,UAAU,KAAKD,IAAI,CAACC,UAAU,IAChCN,CAAC,CAACO,SAAS,KAAKF,IAAI,CAACE,SAAS;UAEhC,CAAE,CAAC;QACJ,CACD,CAAC;QACDX,OAAO,CAACY,IAAI,CAAE;UAAE,GAAGV,YAAY;UAAEI,QAAQ,EAAEC;QAAc,CAAE,CAAC;MAC7D,CAAC,MAAM;QACNP,OAAO,CAACY,IAAI,CAAEX,YAAa,CAAC;MAC7B;IACD;EACD;EAEA,OAAOD,OAAO;AACf"}
1
+ {"version":3,"names":["getIntersectingFontFaces","incoming","existing","matches","incomingFont","existingFont","find","f","slug","fontFace","matchingFaces","filter","face","fontWeight","fontStyle","push"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js"],"sourcesContent":["/**\n * Retrieves intersecting font faces between two sets of fonts.\n *\n * For each font in the `incoming` list, the function checks for a corresponding match\n * in the `existing` list based on the `slug` property. If a match is found and both\n * have `fontFace` properties, it further narrows down to matching font faces based on\n * the `fontWeight` and `fontStyle`. The result includes the properties of the matched\n * existing font but only with intersecting font faces.\n *\n * @param {Array.<{ slug: string, fontFace?: Array.<{ fontWeight: string, fontStyle: string }> }>} incoming - The list of fonts to compare.\n * @param {Array.<{ slug: string, fontFace?: Array.<{ fontWeight: string, fontStyle: string }> }>} existing - The reference list of fonts.\n *\n * @return {Array.<{ slug: string, fontFace?: Array.<{ fontWeight: string, fontStyle: string }> }>} An array of fonts from the `existing` list with intersecting font faces.\n *\n * @example\n * const incomingFonts = [\n * { slug: 'arial', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }] },\n * { slug: 'times-new', fontFace: [{ fontWeight: '700', fontStyle: 'italic' }] }\n * ];\n *\n * const existingFonts = [\n * { slug: 'arial', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }, { fontWeight: '700', fontStyle: 'italic' }] },\n * { slug: 'helvetica', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }] }\n * ];\n *\n * getIntersectingFontFaces(incomingFonts, existingFonts);\n * // Returns:\n * // [{ slug: 'arial', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }] }]\n */\nexport default function getIntersectingFontFaces( incoming, existing ) {\n\tconst matches = [];\n\n\tfor ( const incomingFont of incoming ) {\n\t\tconst existingFont = existing.find(\n\t\t\t( f ) => f.slug === incomingFont.slug\n\t\t);\n\n\t\tif ( existingFont ) {\n\t\t\tif ( incomingFont?.fontFace ) {\n\t\t\t\tconst matchingFaces = incomingFont.fontFace.filter(\n\t\t\t\t\t( face ) => {\n\t\t\t\t\t\treturn ( existingFont?.fontFace || [] ).find( ( f ) => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\tf.fontWeight === face.fontWeight &&\n\t\t\t\t\t\t\t\tf.fontStyle === face.fontStyle\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\tmatches.push( { ...incomingFont, fontFace: matchingFaces } );\n\t\t\t} else {\n\t\t\t\tmatches.push( incomingFont );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn matches;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,wBAAwBA,CAAEC,QAAQ,EAAEC,QAAQ,EAAG;EACtE,MAAMC,OAAO,GAAG,EAAE;EAElB,KAAM,MAAMC,YAAY,IAAIH,QAAQ,EAAG;IACtC,MAAMI,YAAY,GAAGH,QAAQ,CAACI,IAAI,CAC/BC,CAAC,IAAMA,CAAC,CAACC,IAAI,KAAKJ,YAAY,CAACI,IAClC,CAAC;IAED,IAAKH,YAAY,EAAG;MACnB,IAAKD,YAAY,EAAEK,QAAQ,EAAG;QAC7B,MAAMC,aAAa,GAAGN,YAAY,CAACK,QAAQ,CAACE,MAAM,CAC/CC,IAAI,IAAM;UACX,OAAO,CAAEP,YAAY,EAAEI,QAAQ,IAAI,EAAE,EAAGH,IAAI,CAAIC,CAAC,IAAM;YACtD,OACCA,CAAC,CAACM,UAAU,KAAKD,IAAI,CAACC,UAAU,IAChCN,CAAC,CAACO,SAAS,KAAKF,IAAI,CAACE,SAAS;UAEhC,CAAE,CAAC;QACJ,CACD,CAAC;QACDX,OAAO,CAACY,IAAI,CAAE;UAAE,GAAGX,YAAY;UAAEK,QAAQ,EAAEC;QAAc,CAAE,CAAC;MAC7D,CAAC,MAAM;QACNP,OAAO,CAACY,IAAI,CAAEX,YAAa,CAAC;MAC7B;IACD;EACD;EAEA,OAAOD,OAAO;AACf"}
@@ -1,8 +1,12 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { paramCase as kebabCase } from 'change-case';
5
+
1
6
  /**
2
7
  * Internal dependencies
3
8
  */
4
9
  import { FONT_WEIGHTS, FONT_STYLES } from './constants';
5
- import { formatFontFamily } from './preview-styles';
6
10
  export function setUIValuesNeeded(font, extraValues = {}) {
7
11
  if (!font.name && (font.fontFamily || font.slug)) {
8
12
  font.name = font.fontFamily || font.slug;
@@ -80,7 +84,7 @@ export async function loadFontFaceInBrowser(fontFace, source, addTo = 'all') {
80
84
  }
81
85
 
82
86
  // eslint-disable-next-line no-undef
83
- const newFont = new FontFace(formatFontFamily(fontFace.fontFamily), dataSource, {
87
+ const newFont = new FontFace(fontFace.fontFamily, dataSource, {
84
88
  style: fontFace.fontStyle,
85
89
  weight: fontFace.fontWeight
86
90
  });
@@ -112,9 +116,17 @@ export function getDisplaySrcFromFontFace(input, urlPrefix) {
112
116
  }
113
117
  return src;
114
118
  }
119
+
120
+ // This function replicates one behavior of _wp_to_kebab_case().
121
+ // Additional context: https://github.com/WordPress/gutenberg/issues/53695
122
+ export function wpKebabCase(str) {
123
+ // If a string contains a digit followed by a number, insert a dash between them.
124
+ return kebabCase(str).replace(/([a-zA-Z])(\d)|(\d)([a-zA-Z])/g, '$1$3-$2$4');
125
+ }
115
126
  export function makeFormDataFromFontFamilies(fontFamilies) {
116
127
  const formData = new FormData();
117
128
  const newFontFamilies = fontFamilies.map((family, familyIndex) => {
129
+ family.slug = wpKebabCase(family.slug);
118
130
  if (family?.fontFace) {
119
131
  family.fontFace = family.fontFace.map((face, faceIndex) => {
120
132
  if (face.file) {
@@ -1 +1 @@
1
- {"version":3,"names":["FONT_WEIGHTS","FONT_STYLES","formatFontFamily","setUIValuesNeeded","font","extraValues","name","fontFamily","slug","isUrlEncoded","url","decodeURIComponent","getFontFaceVariantName","face","weightName","fontWeight","styleName","fontStyle","mergeFontFaces","existing","incoming","map","Map","set","Array","from","values","mergeFontFamilies","has","fontFace","incomingFontFaces","restIncoming","existingFont","get","mergedFontFaces","loadFontFaceInBrowser","source","addTo","dataSource","File","arrayBuffer","newFont","FontFace","style","weight","loadedFace","load","document","fonts","add","iframeDocument","querySelector","contentDocument","getDisplaySrcFromFontFace","input","urlPrefix","src","isArray","startsWith","replace","encodeURI","makeFormDataFromFontFamilies","fontFamilies","formData","FormData","newFontFamilies","family","familyIndex","faceIndex","file","fileId","append","faceWithoutFileProperty","newFace","uploadedFile","JSON","stringify"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/utils/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { FONT_WEIGHTS, FONT_STYLES } from './constants';\nimport { formatFontFamily } from './preview-styles';\n\nexport function setUIValuesNeeded( font, extraValues = {} ) {\n\tif ( ! font.name && ( font.fontFamily || font.slug ) ) {\n\t\tfont.name = font.fontFamily || font.slug;\n\t}\n\treturn {\n\t\t...font,\n\t\t...extraValues,\n\t};\n}\n\nexport function isUrlEncoded( url ) {\n\tif ( typeof url !== 'string' ) {\n\t\treturn false;\n\t}\n\treturn url !== decodeURIComponent( url );\n}\n\nexport function getFontFaceVariantName( face ) {\n\tconst weightName = FONT_WEIGHTS[ face.fontWeight ] || face.fontWeight;\n\tconst styleName =\n\t\tface.fontStyle === 'normal'\n\t\t\t? ''\n\t\t\t: FONT_STYLES[ face.fontStyle ] || face.fontStyle;\n\treturn `${ weightName } ${ styleName }`;\n}\n\nexport function mergeFontFaces( existing = [], incoming = [] ) {\n\tconst map = new Map();\n\tfor ( const face of existing ) {\n\t\tmap.set( `${ face.fontWeight }${ face.fontStyle }`, face );\n\t}\n\tfor ( const face of incoming ) {\n\t\t// This will overwrite if the src already exists, keeping it unique.\n\t\tmap.set( `${ face.fontWeight }${ face.fontStyle }`, face );\n\t}\n\treturn Array.from( map.values() );\n}\n\nexport function mergeFontFamilies( existing = [], incoming = [] ) {\n\tconst map = new Map();\n\t// Add the existing array to the map.\n\tfor ( const font of existing ) {\n\t\tmap.set( font.slug, { ...font } );\n\t}\n\t// Add the incoming array to the map, overwriting existing values excepting fontFace that need to be merged.\n\tfor ( const font of incoming ) {\n\t\tif ( map.has( font.slug ) ) {\n\t\t\tconst { fontFace: incomingFontFaces, ...restIncoming } = font;\n\t\t\tconst existingFont = map.get( font.slug );\n\t\t\t// Merge the fontFaces existing with the incoming fontFaces.\n\t\t\tconst mergedFontFaces = mergeFontFaces(\n\t\t\t\texistingFont.fontFace,\n\t\t\t\tincomingFontFaces\n\t\t\t);\n\t\t\t// Except for the fontFace key all the other keys are overwritten with the incoming values.\n\t\t\tmap.set( font.slug, {\n\t\t\t\t...restIncoming,\n\t\t\t\tfontFace: mergedFontFaces,\n\t\t\t} );\n\t\t} else {\n\t\t\tmap.set( font.slug, { ...font } );\n\t\t}\n\t}\n\treturn Array.from( map.values() );\n}\n\n/*\n * Loads the font face from a URL and adds it to the browser.\n * It also adds it to the iframe document.\n */\nexport async function loadFontFaceInBrowser( fontFace, source, addTo = 'all' ) {\n\tlet dataSource;\n\n\tif ( typeof source === 'string' ) {\n\t\tdataSource = `url(${ source })`;\n\t\t// eslint-disable-next-line no-undef\n\t} else if ( source instanceof File ) {\n\t\tdataSource = await source.arrayBuffer();\n\t}\n\n\t// eslint-disable-next-line no-undef\n\tconst newFont = new FontFace(\n\t\tformatFontFamily( fontFace.fontFamily ),\n\t\tdataSource,\n\t\t{\n\t\t\tstyle: fontFace.fontStyle,\n\t\t\tweight: fontFace.fontWeight,\n\t\t}\n\t);\n\n\tconst loadedFace = await newFont.load();\n\n\tif ( addTo === 'document' || addTo === 'all' ) {\n\t\tdocument.fonts.add( loadedFace );\n\t}\n\n\tif ( addTo === 'iframe' || addTo === 'all' ) {\n\t\tconst iframeDocument = document.querySelector(\n\t\t\t'iframe[name=\"editor-canvas\"]'\n\t\t).contentDocument;\n\t\tiframeDocument.fonts.add( loadedFace );\n\t}\n}\n\nexport function getDisplaySrcFromFontFace( input, urlPrefix ) {\n\tif ( ! input ) {\n\t\treturn;\n\t}\n\n\tlet src;\n\tif ( Array.isArray( input ) ) {\n\t\tsrc = input[ 0 ];\n\t} else {\n\t\tsrc = input;\n\t}\n\t// If it is a theme font, we need to make the url absolute\n\tif ( src.startsWith( 'file:.' ) && urlPrefix ) {\n\t\tsrc = src.replace( 'file:.', urlPrefix );\n\t}\n\tif ( ! isUrlEncoded( src ) ) {\n\t\tsrc = encodeURI( src );\n\t}\n\treturn src;\n}\n\nexport function makeFormDataFromFontFamilies( fontFamilies ) {\n\tconst formData = new FormData();\n\tconst newFontFamilies = fontFamilies.map( ( family, familyIndex ) => {\n\t\tif ( family?.fontFace ) {\n\t\t\tfamily.fontFace = family.fontFace.map( ( face, faceIndex ) => {\n\t\t\t\tif ( face.file ) {\n\t\t\t\t\t// Slugified file name because the it might contain spaces or characters treated differently on the server.\n\t\t\t\t\tconst fileId = `file-${ familyIndex }-${ faceIndex }`;\n\t\t\t\t\t// Add the files to the formData\n\t\t\t\t\tformData.append( fileId, face.file, face.file.name );\n\t\t\t\t\t// remove the file object from the face object the file is referenced by the uploadedFile key\n\t\t\t\t\tconst { file, ...faceWithoutFileProperty } = face;\n\t\t\t\t\tconst newFace = {\n\t\t\t\t\t\t...faceWithoutFileProperty,\n\t\t\t\t\t\tuploadedFile: fileId,\n\t\t\t\t\t};\n\t\t\t\t\treturn newFace;\n\t\t\t\t}\n\t\t\t\treturn face;\n\t\t\t} );\n\t\t}\n\t\treturn family;\n\t} );\n\tformData.append( 'font_families', JSON.stringify( newFontFamilies ) );\n\tre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HTS","FONT_STYLES","setUIValuesNeeded","font","extraValues","name","fontFamily","slug","isUrlEncoded","url","decodeURIComponent","getFontFaceVariantName","face","weightName","fontWeight","styleName","fontStyle","mergeFontFaces","existing","incoming","map","Map","set","Array","from","values","mergeFontFamilies","has","fontFace","incomingFontFaces","restIncoming","existingFont","get","mergedFontFaces","loadFontFaceInBrowser","source","addTo","dataSource","File","arrayBuffer","newFont","FontFace","style","weight","loadedFace","load","document","fonts","add","iframeDocument","querySelector","contentDocument","getDisplaySrcFromFontFace","input","urlPrefix","src","isArray","startsWith","replace","encodeURI","wpKebabCase","str","makeFormDataFromFontFamilies","fontFamilies","formData","FormData","newFontFamilies","family","familyIndex","faceIndex","file","fileId","append","faceWithoutFileProperty","newFace","uploadedFile","JSON","stringify"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/utils/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\n * Internal dependencies\n */\nimport { FONT_WEIGHTS, FONT_STYLES } from './constants';\n\nexport function setUIValuesNeeded( font, extraValues = {} ) {\n\tif ( ! font.name && ( font.fontFamily || font.slug ) ) {\n\t\tfont.name = font.fontFamily || font.slug;\n\t}\n\treturn {\n\t\t...font,\n\t\t...extraValues,\n\t};\n}\n\nexport function isUrlEncoded( url ) {\n\tif ( typeof url !== 'string' ) {\n\t\treturn false;\n\t}\n\treturn url !== decodeURIComponent( url );\n}\n\nexport function getFontFaceVariantName( face ) {\n\tconst weightName = FONT_WEIGHTS[ face.fontWeight ] || face.fontWeight;\n\tconst styleName =\n\t\tface.fontStyle === 'normal'\n\t\t\t? ''\n\t\t\t: FONT_STYLES[ face.fontStyle ] || face.fontStyle;\n\treturn `${ weightName } ${ styleName }`;\n}\n\nexport function mergeFontFaces( existing = [], incoming = [] ) {\n\tconst map = new Map();\n\tfor ( const face of existing ) {\n\t\tmap.set( `${ face.fontWeight }${ face.fontStyle }`, face );\n\t}\n\tfor ( const face of incoming ) {\n\t\t// This will overwrite if the src already exists, keeping it unique.\n\t\tmap.set( `${ face.fontWeight }${ face.fontStyle }`, face );\n\t}\n\treturn Array.from( map.values() );\n}\n\nexport function mergeFontFamilies( existing = [], incoming = [] ) {\n\tconst map = new Map();\n\t// Add the existing array to the map.\n\tfor ( const font of existing ) {\n\t\tmap.set( font.slug, { ...font } );\n\t}\n\t// Add the incoming array to the map, overwriting existing values excepting fontFace that need to be merged.\n\tfor ( const font of incoming ) {\n\t\tif ( map.has( font.slug ) ) {\n\t\t\tconst { fontFace: incomingFontFaces, ...restIncoming } = font;\n\t\t\tconst existingFont = map.get( font.slug );\n\t\t\t// Merge the fontFaces existing with the incoming fontFaces.\n\t\t\tconst mergedFontFaces = mergeFontFaces(\n\t\t\t\texistingFont.fontFace,\n\t\t\t\tincomingFontFaces\n\t\t\t);\n\t\t\t// Except for the fontFace key all the other keys are overwritten with the incoming values.\n\t\t\tmap.set( font.slug, {\n\t\t\t\t...restIncoming,\n\t\t\t\tfontFace: mergedFontFaces,\n\t\t\t} );\n\t\t} else {\n\t\t\tmap.set( font.slug, { ...font } );\n\t\t}\n\t}\n\treturn Array.from( map.values() );\n}\n\n/*\n * Loads the font face from a URL and adds it to the browser.\n * It also adds it to the iframe document.\n */\nexport async function loadFontFaceInBrowser( fontFace, source, addTo = 'all' ) {\n\tlet dataSource;\n\n\tif ( typeof source === 'string' ) {\n\t\tdataSource = `url(${ source })`;\n\t\t// eslint-disable-next-line no-undef\n\t} else if ( source instanceof File ) {\n\t\tdataSource = await source.arrayBuffer();\n\t}\n\n\t// eslint-disable-next-line no-undef\n\tconst newFont = new FontFace( fontFace.fontFamily, dataSource, {\n\t\tstyle: fontFace.fontStyle,\n\t\tweight: fontFace.fontWeight,\n\t} );\n\n\tconst loadedFace = await newFont.load();\n\n\tif ( addTo === 'document' || addTo === 'all' ) {\n\t\tdocument.fonts.add( loadedFace );\n\t}\n\n\tif ( addTo === 'iframe' || addTo === 'all' ) {\n\t\tconst iframeDocument = document.querySelector(\n\t\t\t'iframe[name=\"editor-canvas\"]'\n\t\t).contentDocument;\n\t\tiframeDocument.fonts.add( loadedFace );\n\t}\n}\n\nexport function getDisplaySrcFromFontFace( input, urlPrefix ) {\n\tif ( ! input ) {\n\t\treturn;\n\t}\n\n\tlet src;\n\tif ( Array.isArray( input ) ) {\n\t\tsrc = input[ 0 ];\n\t} else {\n\t\tsrc = input;\n\t}\n\t// If it is a theme font, we need to make the url absolute\n\tif ( src.startsWith( 'file:.' ) && urlPrefix ) {\n\t\tsrc = src.replace( 'file:.', urlPrefix );\n\t}\n\tif ( ! isUrlEncoded( src ) ) {\n\t\tsrc = encodeURI( src );\n\t}\n\treturn src;\n}\n\n// This function replicates one behavior of _wp_to_kebab_case().\n// Additional context: https://github.com/WordPress/gutenberg/issues/53695\nexport function wpKebabCase( str ) {\n\t// If a string contains a digit followed by a number, insert a dash between them.\n\treturn kebabCase( str ).replace(\n\t\t/([a-zA-Z])(\\d)|(\\d)([a-zA-Z])/g,\n\t\t'$1$3-$2$4'\n\t);\n}\n\nexport function makeFormDataFromFontFamilies( fontFamilies ) {\n\tconst formData = new FormData();\n\tconst newFontFamilies = fontFamilies.map( ( family, familyIndex ) => {\n\t\tfamily.slug = wpKebabCase( family.slug );\n\t\tif ( family?.fontFace ) {\n\t\t\tfamily.fontFace = family.fontFace.map( ( face, faceIndex ) => {\n\t\t\t\tif ( face.file ) {\n\t\t\t\t\t// Slugified file name because the it might contain spaces or characters treated differently on the server.\n\t\t\t\t\tconst fileId = `file-${ familyIndex }-${ faceIndex }`;\n\t\t\t\t\t// Add the files to the formData\n\t\t\t\t\tformData.append( fileId, face.file, face.file.name );\n\t\t\t\t\t// remove the file object from the face object the file is referenced by the uploadedFile key\n\t\t\t\t\tconst { file, ...faceWithoutFileProperty } = face;\n\t\t\t\t\tconst newFace = {\n\t\t\t\t\t\t...faceWithoutFileProperty,\n\t\t\t\t\t\tuploadedFile: fileId,\n\t\t\t\t\t};\n\t\t\t\t\treturn newFace;\n\t\t\t\t}\n\t\t\t\treturn face;\n\t\t\t} );\n\t\t}\n\t\treturn family;\n\t} );\n\tformData.append( 'font_families', JSON.stringify( newFontFamilies ) );\n\treturn formData;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,IAAIC,SAAS,QAAQ,aAAa;;AAEpD;AACA;AACA;AACA,SAASC,YAAY,EAAEC,WAAW,QAAQ,aAAa;AAEvD,OAAO,SAASC,iBAAiBA,CAAEC,IAAI,EAAEC,WAAW,GAAG,CAAC,CAAC,EAAG;EAC3D,IAAK,CAAED,IAAI,CAACE,IAAI,KAAMF,IAAI,CAACG,UAAU,IAAIH,IAAI,CAACI,IAAI,CAAE,EAAG;IACtDJ,IAAI,CAACE,IAAI,GAAGF,IAAI,CAACG,UAAU,IAAIH,IAAI,CAACI,IAAI;EACzC;EACA,OAAO;IACN,GAAGJ,IAAI;IACP,GAAGC;EACJ,CAAC;AACF;AAEA,OAAO,SAASI,YAAYA,CAAEC,GAAG,EAAG;EACnC,IAAK,OAAOA,GAAG,KAAK,QAAQ,EAAG;IAC9B,OAAO,KAAK;EACb;EACA,OAAOA,GAAG,KAAKC,kBAAkB,CAAED,GAAI,CAAC;AACzC;AAEA,OAAO,SAASE,sBAAsBA,CAAEC,IAAI,EAAG;EAC9C,MAAMC,UAAU,GAAGb,YAAY,CAAEY,IAAI,CAACE,UAAU,CAAE,IAAIF,IAAI,CAACE,UAAU;EACrE,MAAMC,SAAS,GACdH,IAAI,CAACI,SAAS,KAAK,QAAQ,GACxB,EAAE,GACFf,WAAW,CAAEW,IAAI,CAACI,SAAS,CAAE,IAAIJ,IAAI,CAACI,SAAS;EACnD,OAAQ,GAAGH,UAAY,IAAIE,SAAW,EAAC;AACxC;AAEA,OAAO,SAASE,cAAcA,CAAEC,QAAQ,GAAG,EAAE,EAAEC,QAAQ,GAAG,EAAE,EAAG;EAC9D,MAAMC,GAAG,GAAG,IAAIC,GAAG,CAAC,CAAC;EACrB,KAAM,MAAMT,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G7D,IAAI;UACjD,MAAM8D,OAAO,GAAG;YACf,GAAGD,uBAAuB;YAC1BE,YAAY,EAAEJ;UACf,CAAC;UACD,OAAOG,OAAO;QACf;QACA,OAAO9D,IAAI;MACZ,CAAE,CAAC;IACJ;IACA,OAAOuD,MAAM;EACd,CAAE,CAAC;EACHH,QAAQ,CAACQ,MAAM,CAAE,eAAe,EAAEI,IAAI,CAACC,SAAS,CAAEX,eAAgB,CAAE,CAAC;EACrE,OAAOF,QAAQ;AAChB"}
@@ -7,7 +7,8 @@ import { isRTL, __ } from '@wordpress/i18n';
7
7
  import { chevronRight, chevronLeft } from '@wordpress/icons';
8
8
  function ScreenHeader({
9
9
  title,
10
- description
10
+ description,
11
+ onBack
11
12
  }) {
12
13
  return createElement(VStack, {
13
14
  spacing: 0
@@ -27,7 +28,8 @@ function ScreenHeader({
27
28
  },
28
29
  icon: isRTL() ? chevronRight : chevronLeft,
29
30
  isSmall: true,
30
- "aria-label": __('Navigate to the previous view')
31
+ "aria-label": __('Navigate to the previous view'),
32
+ onClick: onBack
31
33
  }), createElement(Spacer, null, createElement(Heading, {
32
34
  className: "edit-site-global-styles-header",
33
35
  level: 2,
@@ -1 +1 @@
1
- {"version":3,"names":["__experimentalHStack","HStack","__experimentalVStack","VStack","__experimentalSpacer","Spacer","__experimentalHeading","Heading","__experimentalView","View","__experimentalNavigatorToParentButton","NavigatorToParentButton","isRTL","__","chevronRight","chevronLeft","ScreenHeader","title","description","createElement","spacing","marginBottom","paddingX","paddingY","style","minWidth","padding","icon","isSmall","className","level","size"],"sources":["@wordpress/edit-site/src/components/global-styles/header.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalSpacer as Spacer,\n\t__experimentalHeading as Heading,\n\t__experimentalView as View,\n\t__experimentalNavigatorToParentButton as NavigatorToParentButton,\n} from '@wordpress/components';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { chevronRight, chevronLeft } from '@wordpress/icons';\n\nfunction ScreenHeader( { title, description } ) {\n\treturn (\n\t\t<VStack spacing={ 0 }>\n\t\t\t<View>\n\t\t\t\t<Spacer marginBottom={ 0 } paddingX={ 4 } paddingY={ 3 }>\n\t\t\t\t\t<HStack spacing={ 2 }>\n\t\t\t\t\t\t<NavigatorToParentButton\n\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t// TODO: This style override is also used in ToolsPanelHeader.\n\t\t\t\t\t\t\t\t// It should be supported out-of-the-box by Button.\n\t\t\t\t\t\t\t\t{ minWidth: 24, padding: 0 }\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\taria-label={ __( 'Navigate to the previous view' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Spacer>\n\t\t\t\t\t\t\t<Heading\n\t\t\t\t\t\t\t\tclassName=\"edit-site-global-styles-header\"\n\t\t\t\t\t\t\t\tlevel={ 2 }\n\t\t\t\t\t\t\t\tsize={ 13 }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t</Spacer>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Spacer>\n\t\t\t</View>\n\t\t\t{ description && (\n\t\t\t\t<p className=\"edit-site-global-styles-header__description\">\n\t\t\t\t\t{ description }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nexport default ScreenHeader;\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,qBAAqB,IAAIC,OAAO,EAChCC,kBAAkB,IAAIC,IAAI,EAC1BC,qCAAqC,IAAIC,uBAAuB,QAC1D,uBAAuB;AAC9B,SAASC,KAAK,EAAEC,EAAE,QAAQ,iBAAiB;AAC3C,SAASC,YAAY,EAAEC,WAAW,QAAQ,kBAAkB;AAE5D,SAASC,YAAYA,CAAE;EAAEC,KAAK;EAAEC;AAAY,CAAC,EAAG;EAC/C,OACCC,aAAA,CAAChB,MAAM;IAACiB,OAAO,EAAG;EAAG,GACpBD,aAAA,CAACV,IAAI,QACJU,aAAA,CAACd,MAAM;IAACgB,YAAY,EAAG,CAAG;IAACC,QAAQ,EAAG,CAAG;IAACC,QAAQ,EAAG;EAAG,GACvDJ,aAAA,CAAClB,MAAM;IAACmB,OAAO,EAAG;EAAG,GACpBD,aAAA,CAACR,uBAAuB;IACvBa,KAAK;IACJ;IACA;IACA;MAAEC,QAAQ,EAAE,EAAE;MAAEC,OAAO,EAAE;IAAE,CAC3B;IACDC,IAAI,EAAGf,KAAK,CAAC,CAAC,GAAGE,YAAY,GAAGC,WAAa;IAC7Ca,OAAO;IACP,cAAaf,EAAE,CAAE,+BAAgC;EAAG,CACpD,CAAC,EACFM,aAAA,CAACd,MAAM,QACNc,aAAA,CAACZ,OAAO;IACPsB,SAAS,EAAC,gCAAgC;IAC1CC,KAAK,EAAG,CAAG;IACXC,IAAI,EAAG;EAAI,GAETd,KACM,CACF,CACD,CACD,CACH,CAAC,EACLC,WAAW,IACZC,aAAA;IAAGU,SAAS,EAAC;EAA6C,GACvDX,WACA,CAEG,CAAC;AAEX;AAEA,eAAeF,YAAY"}
1
+ {"version":3,"names":["__experimentalHStack","HStack","__experimentalVStack","VStack","__experimentalSpacer","Spacer","__experimentalHeading","Heading","__experimentalView","View","__experimentalNavigatorToParentButton","NavigatorToParentButton","isRTL","__","chevronRight","chevronLeft","ScreenHeader","title","description","onBack","createElement","spacing","marginBottom","paddingX","paddingY","style","minWidth","padding","icon","isSmall","onClick","className","level","size"],"sources":["@wordpress/edit-site/src/components/global-styles/header.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalSpacer as Spacer,\n\t__experimentalHeading as Heading,\n\t__experimentalView as View,\n\t__experimentalNavigatorToParentButton as NavigatorToParentButton,\n} from '@wordpress/components';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { chevronRight, chevronLeft } from '@wordpress/icons';\n\nfunction ScreenHeader( { title, description, onBack } ) {\n\treturn (\n\t\t<VStack spacing={ 0 }>\n\t\t\t<View>\n\t\t\t\t<Spacer marginBottom={ 0 } paddingX={ 4 } paddingY={ 3 }>\n\t\t\t\t\t<HStack spacing={ 2 }>\n\t\t\t\t\t\t<NavigatorToParentButton\n\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t// TODO: This style override is also used in ToolsPanelHeader.\n\t\t\t\t\t\t\t\t// It should be supported out-of-the-box by Button.\n\t\t\t\t\t\t\t\t{ minWidth: 24, padding: 0 }\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\taria-label={ __( 'Navigate to the previous view' ) }\n\t\t\t\t\t\t\tonClick={ onBack }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Spacer>\n\t\t\t\t\t\t\t<Heading\n\t\t\t\t\t\t\t\tclassName=\"edit-site-global-styles-header\"\n\t\t\t\t\t\t\t\tlevel={ 2 }\n\t\t\t\t\t\t\t\tsize={ 13 }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t</Spacer>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Spacer>\n\t\t\t</View>\n\t\t\t{ description && (\n\t\t\t\t<p className=\"edit-site-global-styles-header__description\">\n\t\t\t\t\t{ description }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nexport default ScreenHeader;\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,qBAAqB,IAAIC,OAAO,EAChCC,kBAAkB,IAAIC,IAAI,EAC1BC,qCAAqC,IAAIC,uBAAuB,QAC1D,uBAAuB;AAC9B,SAASC,KAAK,EAAEC,EAAE,QAAQ,iBAAiB;AAC3C,SAASC,YAAY,EAAEC,WAAW,QAAQ,kBAAkB;AAE5D,SAASC,YAAYA,CAAE;EAAEC,KAAK;EAAEC,WAAW;EAAEC;AAAO,CAAC,EAAG;EACvD,OACCC,aAAA,CAACjB,MAAM;IAACkB,OAAO,EAAG;EAAG,GACpBD,aAAA,CAACX,IAAI,QACJW,aAAA,CAACf,MAAM;IAACiB,YAAY,EAAG,CAAG;IAACC,QAAQ,EAAG,CAAG;IAACC,QAAQ,EAAG;EAAG,GACvDJ,aAAA,CAACnB,MAAM;IAACoB,OAAO,EAAG;EAAG,GACpBD,aAAA,CAACT,uBAAuB;IACvBc,KAAK;IACJ;IACA;IACA;MAAEC,QAAQ,EAAE,EAAE;MAAEC,OAAO,EAAE;IAAE,CAC3B;IACDC,IAAI,EAAGhB,KAAK,CAAC,CAAC,GAAGE,YAAY,GAAGC,WAAa;IAC7Cc,OAAO;IACP,cAAahB,EAAE,CAAE,+BAAgC,CAAG;IACpDiB,OAAO,EAAGX;EAAQ,CAClB,CAAC,EACFC,aAAA,CAACf,MAAM,QACNe,aAAA,CAACb,OAAO;IACPwB,SAAS,EAAC,gCAAgC;IAC1CC,KAAK,EAAG,CAAG;IACXC,IAAI,EAAG;EAAI,GAEThB,KACM,CACF,CACD,CACD,CACH,CAAC,EACLC,WAAW,IACZE,aAAA;IAAGW,SAAS,EAAC;EAA6C,GACvDb,WACA,CAEG,CAAC;AAEX;AAEA,eAAeF,YAAY"}
@@ -6,7 +6,7 @@ import { store as blocksStore } from '@wordpress/blocks';
6
6
  import { __, sprintf, _n } from '@wordpress/i18n';
7
7
  import { FlexItem, SearchControl, __experimentalHStack as HStack } from '@wordpress/components';
8
8
  import { useSelect } from '@wordpress/data';
9
- import { useState, useMemo, useEffect, useRef } from '@wordpress/element';
9
+ import { useState, useEffect, useRef, useDeferredValue, memo } from '@wordpress/element';
10
10
  import { BlockIcon, privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
11
11
  import { useDebounce } from '@wordpress/compose';
12
12
  import { speak } from '@wordpress/a11y';
@@ -82,17 +82,15 @@ function BlockMenuItem({
82
82
  icon: block.icon
83
83
  }), createElement(FlexItem, null, block.title)));
84
84
  }
85
- function ScreenBlockList() {
85
+ function BlockList({
86
+ filterValue
87
+ }) {
86
88
  const sortedBlockTypes = useSortedBlockTypes();
87
- const [filterValue, setFilterValue] = useState('');
88
89
  const debouncedSpeak = useDebounce(speak, 500);
89
- const isMatchingSearchTerm = useSelect(select => select(blocksStore).isMatchingSearchTerm, []);
90
- const filteredBlockTypes = useMemo(() => {
91
- if (!filterValue) {
92
- return sortedBlockTypes;
93
- }
94
- return sortedBlockTypes.filter(blockType => isMatchingSearchTerm(blockType, filterValue));
95
- }, [filterValue, sortedBlockTypes, isMatchingSearchTerm]);
90
+ const {
91
+ isMatchingSearchTerm
92
+ } = useSelect(blocksStore);
93
+ const filteredBlockTypes = !filterValue ? sortedBlockTypes : sortedBlockTypes.filter(blockType => isMatchingSearchTerm(blockType, filterValue));
96
94
  const blockTypesListRef = useRef();
97
95
 
98
96
  // Announce search results on change
@@ -113,6 +111,18 @@ function ScreenBlockList() {
113
111
  _n('%d result found.', '%d results found.', count), count);
114
112
  debouncedSpeak(resultsFoundMessage, count);
115
113
  }, [filterValue, debouncedSpeak]);
114
+ return createElement("div", {
115
+ ref: blockTypesListRef,
116
+ className: "edit-site-block-types-item-list"
117
+ }, filteredBlockTypes.map(block => createElement(BlockMenuItem, {
118
+ block: block,
119
+ key: 'menu-itemblock-' + block.name
120
+ })));
121
+ }
122
+ const MemoizedBlockList = memo(BlockList);
123
+ function ScreenBlockList() {
124
+ const [filterValue, setFilterValue] = useState('');
125
+ const deferredFilterValue = useDeferredValue(filterValue);
116
126
  return createElement(Fragment, null, createElement(ScreenHeader, {
117
127
  title: __('Blocks'),
118
128
  description: __('Customize the appearance of specific blocks and for the whole site.')
@@ -123,13 +133,9 @@ function ScreenBlockList() {
123
133
  value: filterValue,
124
134
  label: __('Search for blocks'),
125
135
  placeholder: __('Search')
126
- }), createElement("div", {
127
- ref: blockTypesListRef,
128
- className: "edit-site-block-types-item-list"
129
- }, filteredBlockTypes.map(block => createElement(BlockMenuItem, {
130
- block: block,
131
- key: 'menu-itemblock-' + block.name
132
- }))));
136
+ }), createElement(MemoizedBlockList, {
137
+ filterValue: deferredFilterValue
138
+ }));
133
139
  }
134
140
  export default ScreenBlockList;
135
141
  //# sourceMappingURL=screen-block-list.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["store","blocksStore","__","sprintf","_n","FlexItem","SearchControl","__experimentalHStack","HStack","useSelect","useState","useMemo","useEffect","useRef","BlockIcon","privateApis","blockEditorPrivateApis","useDebounce","speak","useBlockVariations","ScreenHeader","NavigationButtonAsItem","unlock","useHasDimensionsPanel","useHasTypographyPanel","useHasBorderPanel","useGlobalSetting","useSettingsForBlockElement","useHasColorPanel","useSortedBlockTypes","blockItems","select","getBlockTypes","groupByType","blocks","block","core","noncore","type","name","startsWith","push","coreItems","nonCoreItems","reduce","useBlockHasGlobalStyles","blockName","rawSettings","settings","hasTypographyPanel","hasColorPanel","hasBorderPanel","hasDimensionsPanel","hasLayoutPanel","hasVariationsPanel","length","hasGlobalStyles","BlockMenuItem","hasBlockMenuItem","navigationButtonLabel","title","createElement","path","encodeURIComponent","justify","icon","ScreenBlockList","sortedBlockTypes","filterValue","setFilterValue","debouncedSpeak","isMatchingSearchTerm","filteredBlockTypes","filter","blockType","blockTypesListRef","count","current","childElementCount","resultsFoundMessage","Fragment","description","__nextHasNoMarginBottom","className","onChange","value","label","placeholder","ref","map","key"],"sources":["@wordpress/edit-site/src/components/global-styles/screen-block-list.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport {\n\tFlexItem,\n\tSearchControl,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useState, useMemo, useEffect, useRef } from '@wordpress/element';\nimport {\n\tBlockIcon,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { useDebounce } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { useBlockVariations } from './variations-panel';\nimport ScreenHeader from './header';\nimport { NavigationButtonAsItem } from './navigation-button';\nimport { unlock } from '../../lock-unlock';\n\nconst {\n\tuseHasDimensionsPanel,\n\tuseHasTypographyPanel,\n\tuseHasBorderPanel,\n\tuseGlobalSetting,\n\tuseSettingsForBlockElement,\n\tuseHasColorPanel,\n} = unlock( blockEditorPrivateApis );\n\nfunction useSortedBlockTypes() {\n\tconst blockItems = useSelect(\n\t\t( select ) => select( blocksStore ).getBlockTypes(),\n\t\t[]\n\t);\n\t// Ensure core blocks are prioritized in the returned results,\n\t// because third party blocks can be registered earlier than\n\t// the core blocks (usually by using the `init` action),\n\t// thus affecting the display order.\n\t// We don't sort reusable blocks as they are handled differently.\n\tconst groupByType = ( blocks, block ) => {\n\t\tconst { core, noncore } = blocks;\n\t\tconst type = block.name.startsWith( 'core/' ) ? core : noncore;\n\t\ttype.push( block );\n\t\treturn blocks;\n\t};\n\tconst { core: coreItems, noncore: nonCoreItems } = blockItems.reduce(\n\t\tgroupByType,\n\t\t{ core: [], noncore: [] }\n\t);\n\treturn [ ...coreItems, ...nonCoreItems ];\n}\n\nexport function useBlockHasGlobalStyles( blockName ) {\n\tconst [ rawSettings ] = useGlobalSetting( '', blockName );\n\tconst settings = useSettingsForBlockElement( rawSettings, blockName );\n\tconst hasTypographyPanel = useHasTypographyPanel( settings );\n\tconst hasColorPanel = useHasColorPanel( settings );\n\tconst hasBorderPanel = useHasBorderPanel( settings );\n\tconst hasDimensionsPanel = useHasDimensionsPanel( settings );\n\tconst hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;\n\tconst hasVariationsPanel = !! useBlockVariations( blockName )?.length;\n\tconst hasGlobalStyles =\n\t\thasTypographyPanel ||\n\t\thasColorPanel ||\n\t\thasLayoutPanel ||\n\t\thasVariationsPanel;\n\treturn hasGlobalStyles;\n}\n\nfunction BlockMenuItem( { block } ) {\n\tconst hasBlockMenuItem = useBlockHasGlobalStyles( block.name );\n\tif ( ! hasBlockMenuItem ) {\n\t\treturn null;\n\t}\n\n\tconst navigationButtonLabel = sprintf(\n\t\t// translators: %s: is the name of a block e.g., 'Image' or 'Table'.\n\t\t__( '%s block styles' ),\n\t\tblock.title\n\t);\n\n\treturn (\n\t\t<NavigationButtonAsItem\n\t\t\tpath={ '/blocks/' + encodeURIComponent( block.name ) }\n\t\t\taria-label={ navigationButtonLabel }\n\t\t>\n\t\t\t<HStack justify=\"flex-start\">\n\t\t\t\t<BlockIcon icon={ block.icon } />\n\t\t\t\t<FlexItem>{ block.title }</FlexItem>\n\t\t\t</HStack>\n\t\t</NavigationButtonAsItem>\n\t);\n}\n\nfunction ScreenBlockList() {\n\tconst sortedBlockTypes = useSortedBlockTypes();\n\tconst [ filterValue, setFilterValue ] = useState( '' );\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst isMatchingSearchTerm = useSelect(\n\t\t( select ) => select( blocksStore ).isMatchingSearchTerm,\n\t\t[]\n\t);\n\tconst filteredBlockTypes = useMemo( () => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn sortedBlockTypes;\n\t\t}\n\t\treturn sortedBlockTypes.filter( ( blockType ) =>\n\t\t\tisMatchingSearchTerm( blockType, filterValue )\n\t\t);\n\t}, [ filterValue, sortedBlockTypes, isMatchingSearchTerm ] );\n\n\tconst blockTypesListRef = useRef();\n\n\t// Announce search results on change\n\tuseEffect( () => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\t\t// We extract the results from the wrapper div's `ref` because\n\t\t// filtered items can contain items that will eventually not\n\t\t// render and there is no reliable way to detect when a child\n\t\t// will return `null`.\n\t\t// TODO: We should find a better way of handling this as it's\n\t\t// fragile and depends on the number of rendered elements of `BlockMenuItem`,\n\t\t// which is now one.\n\t\t// @see https://github.com/WordPress/gutenberg/pull/39117#discussion_r816022116\n\t\tconst count = blockTypesListRef.current.childElementCount;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage, count );\n\t}, [ filterValue, debouncedSpeak ] );\n\n\treturn (\n\t\t<>\n\t\t\t<ScreenHeader\n\t\t\t\ttitle={ __( 'Blocks' ) }\n\t\t\t\tdescription={ __(\n\t\t\t\t\t'Customize the appearance of specific blocks and for the whole site.'\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t<SearchControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tclassName=\"edit-site-block-types-search\"\n\t\t\t\tonChange={ setFilterValue }\n\t\t\t\tvalue={ filterValue }\n\t\t\t\tlabel={ __( 'Search for blocks' ) }\n\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t/>\n\t\t\t<div\n\t\t\t\tref={ blockTypesListRef }\n\t\t\t\tclassName=\"edit-site-block-types-item-list\"\n\t\t\t>\n\t\t\t\t{ filteredBlockTypes.map( ( block ) => (\n\t\t\t\t\t<BlockMenuItem\n\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\tkey={ 'menu-itemblock-' + block.name }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default ScreenBlockList;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,EAAE,EAAEC,OAAO,EAAEC,EAAE,Q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E,cAAc,CAAG,CAAC;EAEpC,OACCT,aAAA,CAAAmB,QAAA,QACCnB,aAAA,CAACzC,YAAY;IACZwC,KAAK,EAAG1D,EAAE,CAAE,QAAS,CAAG;IACxB+E,WAAW,EAAG/E,EAAE,CACf,qEACD;EAAG,CACH,CAAC,EACF2D,aAAA,CAACvD,aAAa;IACb4E,uBAAuB;IACvBC,SAAS,EAAC,8BAA8B;IACxCC,QAAQ,EAAGf,cAAgB;IAC3BgB,KAAK,EAAGjB,WAAa;IACrBkB,KAAK,EAAGpF,EAAE,CAAE,mBAAoB,CAAG;IACnCqF,WAAW,EAAGrF,EAAE,CAAE,QAAS;EAAG,CAC9B,CAAC,EACF2D,aAAA;IACC2B,GAAG,EAAGb,iBAAmB;IACzBQ,SAAS,EAAC;EAAiC,GAEzCX,kBAAkB,CAACiB,GAAG,CAAItD,KAAK,IAChC0B,aAAA,CAACJ,aAAa;IACbtB,KAAK,EAAGA,KAAO;IACfuD,GAAG,EAAG,iBAAiB,GAAGvD,KAAK,CAACI;EAAM,CACtC,CACA,CACE,CACJ,CAAC;AAEL;AAEA,eAAe2B,eAAe"}
1
+ {"version":3,"names":["store","blocksStore","__","sprintf","_n","FlexItem","SearchControl","__experimentalHStack","HStack","useSelect","useState","useEffect","useRef","useDeferredValue","memo","BlockIcon","privateApis","blockEditorPrivateApis","useDebounce","speak","useBlockVariations","ScreenHeader","NavigationButtonAsItem","unlock","useHasDimensionsPanel","useHasTypographyPanel","useHasBorderPanel","useGlobalSetting","useSettingsForBlockElement","useHasColorPanel","useSortedBlockTypes","blockItems","select","getBlockTypes","groupByType","blocks","block","core","noncore","type","name","startsWith","push","coreItems","nonCoreItems","reduce","useBlockHasGlobalStyles","blockName","rawSettings","settings","hasTypographyPanel","hasColorPanel","hasBorderPanel","hasDimensionsPanel","hasLayoutPanel","hasVariationsPanel","length","hasGlobalStyles","BlockMenuItem","hasBlockMenuItem","navigationButtonLabel","title","createElement","path","encodeURIComponent","justify","icon","BlockList","filterValue","sortedBlockTypes","debouncedSpeak","isMatchingSearchTerm","filteredBlockTypes","filter","blockType","blockTypesListRef","count","current","childElementCount","resultsFoundMessage","ref","className","map","key","MemoizedBlockList","ScreenBlockList","setFilterValue","deferredFilterValue","Fragment","description","__nextHasNoMarginBottom","onChange","value","label","placeholder"],"sources":["@wordpress/edit-site/src/components/global-styles/screen-block-list.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport {\n\tFlexItem,\n\tSearchControl,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseState,\n\tuseEffect,\n\tuseRef,\n\tuseDeferredValue,\n\tmemo,\n} from '@wordpress/element';\nimport {\n\tBlockIcon,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { useDebounce } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { useBlockVariations } from './variations-panel';\nimport ScreenHeader from './header';\nimport { NavigationButtonAsItem } from './navigation-button';\nimport { unlock } from '../../lock-unlock';\n\nconst {\n\tuseHasDimensionsPanel,\n\tuseHasTypographyPanel,\n\tuseHasBorderPanel,\n\tuseGlobalSetting,\n\tuseSettingsForBlockElement,\n\tuseHasColorPanel,\n} = unlock( blockEditorPrivateApis );\n\nfunction useSortedBlockTypes() {\n\tconst blockItems = useSelect(\n\t\t( select ) => select( blocksStore ).getBlockTypes(),\n\t\t[]\n\t);\n\t// Ensure core blocks are prioritized in the returned results,\n\t// because third party blocks can be registered earlier than\n\t// the core blocks (usually by using the `init` action),\n\t// thus affecting the display order.\n\t// We don't sort reusable blocks as they are handled differently.\n\tconst groupByType = ( blocks, block ) => {\n\t\tconst { core, noncore } = blocks;\n\t\tconst type = block.name.startsWith( 'core/' ) ? core : noncore;\n\t\ttype.push( block );\n\t\treturn blocks;\n\t};\n\tconst { core: coreItems, noncore: nonCoreItems } = blockItems.reduce(\n\t\tgroupByType,\n\t\t{ core: [], noncore: [] }\n\t);\n\treturn [ ...coreItems, ...nonCoreItems ];\n}\n\nexport function useBlockHasGlobalStyles( blockName ) {\n\tconst [ rawSettings ] = useGlobalSetting( '', blockName );\n\tconst settings = useSettingsForBlockElement( rawSettings, blockName );\n\tconst hasTypographyPanel = useHasTypographyPanel( settings );\n\tconst hasColorPanel = useHasColorPanel( settings );\n\tconst hasBorderPanel = useHasBorderPanel( settings );\n\tconst hasDimensionsPanel = useHasDimensionsPanel( settings );\n\tconst hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;\n\tconst hasVariationsPanel = !! useBlockVariations( blockName )?.length;\n\tconst hasGlobalStyles =\n\t\thasTypographyPanel ||\n\t\thasColorPanel ||\n\t\thasLayoutPanel ||\n\t\thasVariationsPanel;\n\treturn hasGlobalStyles;\n}\n\nfunction BlockMenuItem( { block } ) {\n\tconst hasBlockMenuItem = useBlockHasGlobalStyles( block.name );\n\tif ( ! hasBlockMenuItem ) {\n\t\treturn null;\n\t}\n\n\tconst navigationButtonLabel = sprintf(\n\t\t// translators: %s: is the name of a block e.g., 'Image' or 'Table'.\n\t\t__( '%s block styles' ),\n\t\tblock.title\n\t);\n\n\treturn (\n\t\t<NavigationButtonAsItem\n\t\t\tpath={ '/blocks/' + encodeURIComponent( block.name ) }\n\t\t\taria-label={ navigationButtonLabel }\n\t\t>\n\t\t\t<HStack justify=\"flex-start\">\n\t\t\t\t<BlockIcon icon={ block.icon } />\n\t\t\t\t<FlexItem>{ block.title }</FlexItem>\n\t\t\t</HStack>\n\t\t</NavigationButtonAsItem>\n\t);\n}\n\nfunction BlockList( { filterValue } ) {\n\tconst sortedBlockTypes = useSortedBlockTypes();\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst { isMatchingSearchTerm } = useSelect( blocksStore );\n\n\tconst filteredBlockTypes = ! filterValue\n\t\t? sortedBlockTypes\n\t\t: sortedBlockTypes.filter( ( blockType ) =>\n\t\t\t\tisMatchingSearchTerm( blockType, filterValue )\n\t\t );\n\n\tconst blockTypesListRef = useRef();\n\n\t// Announce search results on change\n\tuseEffect( () => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\t\t// We extract the results from the wrapper div's `ref` because\n\t\t// filtered items can contain items that will eventually not\n\t\t// render and there is no reliable way to detect when a child\n\t\t// will return `null`.\n\t\t// TODO: We should find a better way of handling this as it's\n\t\t// fragile and depends on the number of rendered elements of `BlockMenuItem`,\n\t\t// which is now one.\n\t\t// @see https://github.com/WordPress/gutenberg/pull/39117#discussion_r816022116\n\t\tconst count = blockTypesListRef.current.childElementCount;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage, count );\n\t}, [ filterValue, debouncedSpeak ] );\n\n\treturn (\n\t\t<div\n\t\t\tref={ blockTypesListRef }\n\t\t\tclassName=\"edit-site-block-types-item-list\"\n\t\t>\n\t\t\t{ filteredBlockTypes.map( ( block ) => (\n\t\t\t\t<BlockMenuItem\n\t\t\t\t\tblock={ block }\n\t\t\t\t\tkey={ 'menu-itemblock-' + block.name }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</div>\n\t);\n}\n\nconst MemoizedBlockList = memo( BlockList );\n\nfunction ScreenBlockList() {\n\tconst [ filterValue, setFilterValue ] = useState( '' );\n\tconst deferredFilterValue = useDeferredValue( filterValue );\n\n\treturn (\n\t\t<>\n\t\t\t<ScreenHeader\n\t\t\t\ttitle={ __( 'Blocks' ) }\n\t\t\t\tdescription={ __(\n\t\t\t\t\t'Customize the appearance of specific blocks and for the whole site.'\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t<SearchControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tclassName=\"edit-site-block-types-search\"\n\t\t\t\tonChange={ setFilterValue }\n\t\t\t\tvalue={ filterValue }\n\t\t\t\tlabel={ __( 'Search for blocks' ) }\n\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t/>\n\t\t\t<MemoizedBlockList filterValue={ deferredFilterValue } />\n\t\t</>\n\t);\n}\n\nexport default ScreenBlockList;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,EAAE,EAAEC,OAAO,EAAEC,EAAE,QAAQ,iBAAiB;AACjD,SACCC,QAAQ,EACRC,aAAa,EACbC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,QAAQ,EACRC,SAAS,EACTC,MAAM,EACNC,gBAAgB,EAChBC,IAAI,QACE,oBAAoB;AAC3B,SACCC,SAAS,EACTC,WAAW,IAAIC,sBAAsB,QAC/B,yBAAyB;AAChC,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SAASC,KAAK,QAAQ,iBAAiB;;AAEvC;AACA;AACA;AACA,SAASC,kBAAkB,QAAQ,oBAAoB;AACvD,OAAOC,YAAY,MAAM,UAAU;AACnC,SAASC,sBAAsB,QAAQ,qBAAqB;AAC5D,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,MAAM;EACLC,qBAAqB;EACrBC,qBAAqB;EACrBC,iBAAiB;EACjBC,gBAAgB;EAChBC,0BAA0B;EAC1BC;AACD,CAAC,GAAGN,MAAM,CAAEN,sBAAuB,CAAC;AAEpC,SAASa,mBAAmBA,CAAA,EAAG;EAC9B,MAAMC,UAAU,GAAGtB,SAAS,CACzBuB,MAAM,IAAMA,MAAM,CAAE/B,WAAY,CAAC,CAACgC,aAAa,CAAC,CAAC,EACnD,EACD,CAAC;EACD;EACA;EACA;EACA;EACA;EACA,MAAMC,WAAW,GAAGA,CAAEC,MAAM,EAAEC,KAAK,KAAM;IACxC,MAAM;MAAEC,IAAI;MAAEC;IAAQ,CAAC,GAAGH,MAAM;I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BAAmB,EAAEH,KAAM,CAAC;EAC7C,CAAC,EAAE,CAAER,WAAW,EAAEE,cAAc,CAAG,CAAC;EAEpC,OACCR,aAAA;IACCkB,GAAG,EAAGL,iBAAmB;IACzBM,SAAS,EAAC;EAAiC,GAEzCT,kBAAkB,CAACU,GAAG,CAAI9C,KAAK,IAChC0B,aAAA,CAACJ,aAAa;IACbtB,KAAK,EAAGA,KAAO;IACf+C,GAAG,EAAG,iBAAiB,GAAG/C,KAAK,CAACI;EAAM,CACtC,CACA,CACE,CAAC;AAER;AAEA,MAAM4C,iBAAiB,GAAGtE,IAAI,CAAEqD,SAAU,CAAC;AAE3C,SAASkB,eAAeA,CAAA,EAAG;EAC1B,MAAM,CAAEjB,WAAW,EAAEkB,cAAc,CAAE,GAAG5E,QAAQ,CAAE,EAAG,CAAC;EACtD,MAAM6E,mBAAmB,GAAG1E,gBAAgB,CAAEuD,WAAY,CAAC;EAE3D,OACCN,aAAA,CAAA0B,QAAA,QACC1B,aAAA,CAACzC,YAAY;IACZwC,KAAK,EAAG3D,EAAE,CAAE,QAAS,CAAG;IACxBuF,WAAW,EAAGvF,EAAE,CACf,qEACD;EAAG,CACH,CAAC,EACF4D,aAAA,CAACxD,aAAa;IACboF,uBAAuB;IACvBT,SAAS,EAAC,8BAA8B;IACxCU,QAAQ,EAAGL,cAAgB;IAC3BM,KAAK,EAAGxB,WAAa;IACrByB,KAAK,EAAG3F,EAAE,CAAE,mBAAoB,CAAG;IACnC4F,WAAW,EAAG5F,EAAE,CAAE,QAAS;EAAG,CAC9B,CAAC,EACF4D,aAAA,CAACsB,iBAAiB;IAAChB,WAAW,EAAGmB;EAAqB,CAAE,CACvD,CAAC;AAEL;AAEA,eAAeF,eAAe"}
@@ -2,9 +2,10 @@ import { createElement, Fragment } from "react";
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
5
- import { __ } from '@wordpress/i18n';
5
+ import { __, sprintf } from '@wordpress/i18n';
6
6
  import { Button, __experimentalUseNavigator as useNavigator, __experimentalConfirmDialog as ConfirmDialog, Spinner, __experimentalSpacer as Spacer } from '@wordpress/components';
7
7
  import { useSelect, useDispatch } from '@wordpress/data';
8
+ import { store as coreStore } from '@wordpress/core-data';
8
9
  import { useContext, useState, useEffect } from '@wordpress/element';
9
10
  import { privateApis as blockEditorPrivateApis, store as blockEditorStore } from '@wordpress/block-editor';
10
11
 
@@ -32,11 +33,28 @@ function ScreenRevisions() {
32
33
  } = useContext(GlobalStylesContext);
33
34
  const {
34
35
  blocks,
35
- editorCanvasContainerView
36
+ editorCanvasContainerView,
37
+ revisionsCount
36
38
  } = useSelect(select => {
39
+ const {
40
+ getEntityRecord,
41
+ __experimentalGetCurrentGlobalStylesId,
42
+ __experimentalGetDirtyEntityRecords
43
+ } = select(coreStore);
44
+ const isDirty = __experimentalGetDirtyEntityRecords().length > 0;
45
+ const globalStylesId = __experimentalGetCurrentGlobalStylesId();
46
+ const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined;
47
+ let _revisionsCount = globalStyles?._links?.['version-history']?.[0]?.count || 0;
48
+ // one for the reset item.
49
+ _revisionsCount++;
50
+ // one for any dirty changes (unsaved).
51
+ if (isDirty) {
52
+ _revisionsCount++;
53
+ }
37
54
  return {
38
55
  editorCanvasContainerView: unlock(select(editSiteStore)).getEditorCanvasContainerView(),
39
- blocks: select(blockEditorStore).getBlocks()
56
+ blocks: select(blockEditorStore).getBlocks(),
57
+ revisionsCount: _revisionsCount
40
58
  };
41
59
  }, []);
42
60
  const {
@@ -52,8 +70,8 @@ function ScreenRevisions() {
52
70
  const selectedRevisionMatchesEditorStyles = areGlobalStyleConfigsEqual(currentlySelectedRevision, currentEditorGlobalStyles);
53
71
  const onCloseRevisions = () => {
54
72
  goTo('/'); // Return to global styles main panel.
73
+ setEditorCanvasContainerView(undefined);
55
74
  };
56
-
57
75
  const restoreRevision = revision => {
58
76
  setUserConfig(() => ({
59
77
  styles: revision?.styles,
@@ -99,8 +117,11 @@ function ScreenRevisions() {
99
117
  const isLoadButtonEnabled = !!currentlySelectedRevisionId && !selectedRevisionMatchesEditorStyles;
100
118
  const shouldShowRevisions = !isLoading && revisions.length;
101
119
  return createElement(Fragment, null, createElement(ScreenHeader, {
102
- title: __('Revisions'),
103
- description: __('Click on previously saved styles to preview them. To restore a selected version to the editor, hit "Apply." When you\'re ready, use the Save button to save your changes.')
120
+ title: revisionsCount &&
121
+ // translators: %s: number of revisions.
122
+ sprintf(__('Revisions (%s)'), revisionsCount),
123
+ description: __('Click on previously saved styles to preview them. To restore a selected version to the editor, hit "Apply." When you\'re ready, use the Save button to save your changes.'),
124
+ onBack: onCloseRevisions
104
125
  }), isLoading && createElement(Spinner, {
105
126
  className: "edit-site-global-styles-screen-revisions__loading"
106
127
  }), shouldShowRevisions ? createElement(Fragment, null, createElement(Revisions, {