@wordpress/edit-site 5.4.0 → 5.6.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 (339) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/add-new-template/add-custom-template-modal.js +12 -3
  3. package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
  4. package/build/components/add-new-template/new-template-part.js +8 -7
  5. package/build/components/add-new-template/new-template-part.js.map +1 -1
  6. package/build/components/add-new-template/new-template.js +19 -16
  7. package/build/components/add-new-template/new-template.js.map +1 -1
  8. package/build/components/app/index.js +4 -2
  9. package/build/components/app/index.js.map +1 -1
  10. package/build/components/block-editor/editor-canvas.js +2 -1
  11. package/build/components/block-editor/editor-canvas.js.map +1 -1
  12. package/build/components/editor/index.js +5 -7
  13. package/build/components/editor/index.js.map +1 -1
  14. package/build/components/global-styles/border-panel.js +20 -159
  15. package/build/components/global-styles/border-panel.js.map +1 -1
  16. package/build/components/global-styles/context-menu.js +13 -11
  17. package/build/components/global-styles/context-menu.js.map +1 -1
  18. package/build/components/global-styles/dimensions-panel.js +41 -487
  19. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  20. package/build/components/global-styles/duotone-panel.js +78 -0
  21. package/build/components/global-styles/duotone-panel.js.map +1 -0
  22. package/build/components/global-styles/filter-utils.js +17 -0
  23. package/build/components/global-styles/filter-utils.js.map +1 -0
  24. package/build/components/global-styles/hooks.js +11 -26
  25. package/build/components/global-styles/hooks.js.map +1 -1
  26. package/build/components/global-styles/preview.js +9 -5
  27. package/build/components/global-styles/preview.js.map +1 -1
  28. package/build/components/global-styles/screen-block-list.js +6 -11
  29. package/build/components/global-styles/screen-block-list.js.map +1 -1
  30. package/build/components/global-styles/screen-border.js +14 -6
  31. package/build/components/global-styles/screen-border.js.map +1 -1
  32. package/build/components/global-styles/screen-filters.js +46 -0
  33. package/build/components/global-styles/screen-filters.js.map +1 -0
  34. package/build/components/global-styles/screen-layout.js +13 -5
  35. package/build/components/global-styles/screen-layout.js.map +1 -1
  36. package/build/components/global-styles/screen-root.js +2 -1
  37. package/build/components/global-styles/screen-root.js.map +1 -1
  38. package/build/components/global-styles/screen-style-variations.js +2 -1
  39. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  40. package/build/components/global-styles/screen-variations.js +1 -1
  41. package/build/components/global-styles/screen-variations.js.map +1 -1
  42. package/build/components/global-styles/shadow-panel.js +6 -4
  43. package/build/components/global-styles/shadow-panel.js.map +1 -1
  44. package/build/components/global-styles/typography-panel.js +2 -5
  45. package/build/components/global-styles/typography-panel.js.map +1 -1
  46. package/build/components/global-styles/ui.js +7 -1
  47. package/build/components/global-styles/ui.js.map +1 -1
  48. package/build/components/keyboard-shortcut-help-modal/config.js +12 -0
  49. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  50. package/build/components/keyboard-shortcuts/edit-mode.js +124 -0
  51. package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -0
  52. package/build/components/keyboard-shortcuts/global.js +48 -0
  53. package/build/components/keyboard-shortcuts/global.js.map +1 -0
  54. package/build/components/keyboard-shortcuts/index.js +67 -0
  55. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  56. package/build/components/keyboard-shortcuts/register.js +153 -0
  57. package/build/components/keyboard-shortcuts/register.js.map +1 -0
  58. package/build/components/layout/index.js +12 -1
  59. package/build/components/layout/index.js.map +1 -1
  60. package/build/components/list/added-by.js +127 -136
  61. package/build/components/list/added-by.js.map +1 -1
  62. package/build/components/list/index.js +2 -1
  63. package/build/components/list/index.js.map +1 -1
  64. package/build/components/list/table.js +9 -7
  65. package/build/components/list/table.js.map +1 -1
  66. package/build/components/routes/link.js +4 -1
  67. package/build/components/routes/link.js.map +1 -1
  68. package/build/components/save-hub/index.js +82 -0
  69. package/build/components/save-hub/index.js.map +1 -0
  70. package/build/components/save-panel/index.js +11 -1
  71. package/build/components/save-panel/index.js.map +1 -1
  72. package/build/components/sidebar/index.js +27 -17
  73. package/build/components/sidebar/index.js.map +1 -1
  74. package/build/components/sidebar-button/index.js +30 -0
  75. package/build/components/sidebar-button/index.js.map +1 -0
  76. package/build/components/sidebar-edit-mode/global-styles-sidebar.js +8 -2
  77. package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  78. package/build/components/sidebar-navigation-screen/index.js +14 -11
  79. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  80. package/build/components/sidebar-navigation-screen-main/index.js +16 -16
  81. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  82. package/build/components/sidebar-navigation-screen-navigation-item/index.js +22 -26
  83. package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  84. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +97 -14
  85. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  86. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js +19 -0
  87. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
  88. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +77 -0
  89. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
  90. package/build/components/sidebar-navigation-screen-template/index.js +66 -27
  91. package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
  92. package/build/components/sidebar-navigation-screen-templates/index.js +30 -17
  93. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  94. package/build/components/sidebar-navigation-screen-templates-browse/index.js +14 -10
  95. package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  96. package/build/components/site-hub/index.js +3 -1
  97. package/build/components/site-hub/index.js.map +1 -1
  98. package/build/components/style-book/index.js +151 -21
  99. package/build/components/style-book/index.js.map +1 -1
  100. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +36 -34
  101. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  102. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
  103. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  104. package/build/components/sync-state-with-url/use-sync-path-with-url.js +67 -18
  105. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  106. package/build/components/template-details/index.js +5 -10
  107. package/build/components/template-details/index.js.map +1 -1
  108. package/build/components/template-part-converter/convert-to-regular.js +8 -12
  109. package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
  110. package/build/components/template-part-converter/convert-to-template-part.js +2 -2
  111. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  112. package/build/components/template-part-converter/index.js +19 -14
  113. package/build/components/template-part-converter/index.js.map +1 -1
  114. package/build/components/use-edited-entity-record/index.js +6 -6
  115. package/build/components/use-edited-entity-record/index.js.map +1 -1
  116. package/build/index.js +13 -22
  117. package/build/index.js.map +1 -1
  118. package/build/store/actions.js +2 -2
  119. package/build/store/actions.js.map +1 -1
  120. package/build/utils/get-is-list-page.js +1 -1
  121. package/build/utils/get-is-list-page.js.map +1 -1
  122. package/build/utils/history.js +8 -2
  123. package/build/utils/history.js.map +1 -1
  124. package/build-module/components/add-new-template/add-custom-template-modal.js +13 -4
  125. package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
  126. package/build-module/components/add-new-template/new-template-part.js +8 -7
  127. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  128. package/build-module/components/add-new-template/new-template.js +21 -17
  129. package/build-module/components/add-new-template/new-template.js.map +1 -1
  130. package/build-module/components/app/index.js +3 -2
  131. package/build-module/components/app/index.js.map +1 -1
  132. package/build-module/components/block-editor/editor-canvas.js +2 -1
  133. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  134. package/build-module/components/editor/index.js +5 -6
  135. package/build-module/components/editor/index.js.map +1 -1
  136. package/build-module/components/global-styles/border-panel.js +21 -157
  137. package/build-module/components/global-styles/border-panel.js.map +1 -1
  138. package/build-module/components/global-styles/context-menu.js +14 -11
  139. package/build-module/components/global-styles/context-menu.js.map +1 -1
  140. package/build-module/components/global-styles/dimensions-panel.js +43 -480
  141. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  142. package/build-module/components/global-styles/duotone-panel.js +67 -0
  143. package/build-module/components/global-styles/duotone-panel.js.map +1 -0
  144. package/build-module/components/global-styles/filter-utils.js +9 -0
  145. package/build-module/components/global-styles/filter-utils.js.map +1 -0
  146. package/build-module/components/global-styles/hooks.js +11 -26
  147. package/build-module/components/global-styles/hooks.js.map +1 -1
  148. package/build-module/components/global-styles/preview.js +10 -6
  149. package/build-module/components/global-styles/preview.js.map +1 -1
  150. package/build-module/components/global-styles/screen-block-list.js +6 -8
  151. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  152. package/build-module/components/global-styles/screen-border.js +12 -3
  153. package/build-module/components/global-styles/screen-border.js.map +1 -1
  154. package/build-module/components/global-styles/screen-filters.js +33 -0
  155. package/build-module/components/global-styles/screen-filters.js.map +1 -0
  156. package/build-module/components/global-styles/screen-layout.js +11 -2
  157. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  158. package/build-module/components/global-styles/screen-root.js +2 -1
  159. package/build-module/components/global-styles/screen-root.js.map +1 -1
  160. package/build-module/components/global-styles/screen-style-variations.js +2 -1
  161. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  162. package/build-module/components/global-styles/screen-variations.js +1 -1
  163. package/build-module/components/global-styles/screen-variations.js.map +1 -1
  164. package/build-module/components/global-styles/shadow-panel.js +6 -4
  165. package/build-module/components/global-styles/shadow-panel.js.map +1 -1
  166. package/build-module/components/global-styles/typography-panel.js +2 -5
  167. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  168. package/build-module/components/global-styles/ui.js +6 -1
  169. package/build-module/components/global-styles/ui.js.map +1 -1
  170. package/build-module/components/keyboard-shortcut-help-modal/config.js +12 -0
  171. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  172. package/build-module/components/keyboard-shortcuts/edit-mode.js +108 -0
  173. package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -0
  174. package/build-module/components/keyboard-shortcuts/global.js +37 -0
  175. package/build-module/components/keyboard-shortcuts/global.js.map +1 -0
  176. package/build-module/components/keyboard-shortcuts/index.js +65 -0
  177. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  178. package/build-module/components/keyboard-shortcuts/register.js +141 -0
  179. package/build-module/components/keyboard-shortcuts/register.js.map +1 -0
  180. package/build-module/components/layout/index.js +10 -1
  181. package/build-module/components/layout/index.js.map +1 -1
  182. package/build-module/components/list/added-by.js +126 -138
  183. package/build-module/components/list/added-by.js.map +1 -1
  184. package/build-module/components/list/index.js +2 -1
  185. package/build-module/components/list/index.js.map +1 -1
  186. package/build-module/components/list/table.js +9 -7
  187. package/build-module/components/list/table.js.map +1 -1
  188. package/build-module/components/routes/link.js +5 -2
  189. package/build-module/components/routes/link.js.map +1 -1
  190. package/build-module/components/save-hub/index.js +68 -0
  191. package/build-module/components/save-hub/index.js.map +1 -0
  192. package/build-module/components/save-panel/index.js +8 -1
  193. package/build-module/components/save-panel/index.js.map +1 -1
  194. package/build-module/components/sidebar/index.js +24 -19
  195. package/build-module/components/sidebar/index.js.map +1 -1
  196. package/build-module/components/sidebar-button/index.js +18 -0
  197. package/build-module/components/sidebar-button/index.js.map +1 -0
  198. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +8 -2
  199. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  200. package/build-module/components/sidebar-navigation-screen/index.js +12 -12
  201. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  202. package/build-module/components/sidebar-navigation-screen-main/index.js +16 -16
  203. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  204. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +24 -30
  205. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  206. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +91 -14
  207. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  208. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js +11 -0
  209. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
  210. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +66 -0
  211. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
  212. package/build-module/components/sidebar-navigation-screen-template/index.js +67 -30
  213. package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
  214. package/build-module/components/sidebar-navigation-screen-templates/index.js +28 -18
  215. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  216. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +13 -10
  217. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  218. package/build-module/components/site-hub/index.js +3 -1
  219. package/build-module/components/site-hub/index.js.map +1 -1
  220. package/build-module/components/style-book/index.js +152 -25
  221. package/build-module/components/style-book/index.js.map +1 -1
  222. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +36 -34
  223. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  224. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
  225. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  226. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +65 -18
  227. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  228. package/build-module/components/template-details/index.js +5 -9
  229. package/build-module/components/template-details/index.js.map +1 -1
  230. package/build-module/components/template-part-converter/convert-to-regular.js +9 -13
  231. package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
  232. package/build-module/components/template-part-converter/convert-to-template-part.js +3 -3
  233. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  234. package/build-module/components/template-part-converter/index.js +20 -15
  235. package/build-module/components/template-part-converter/index.js.map +1 -1
  236. package/build-module/components/use-edited-entity-record/index.js +6 -6
  237. package/build-module/components/use-edited-entity-record/index.js.map +1 -1
  238. package/build-module/index.js +16 -23
  239. package/build-module/index.js.map +1 -1
  240. package/build-module/store/actions.js +2 -2
  241. package/build-module/store/actions.js.map +1 -1
  242. package/build-module/utils/get-is-list-page.js +1 -1
  243. package/build-module/utils/get-is-list-page.js.map +1 -1
  244. package/build-module/utils/history.js +9 -3
  245. package/build-module/utils/history.js.map +1 -1
  246. package/build-style/style-rtl.css +203 -143
  247. package/build-style/style.css +203 -143
  248. package/package.json +31 -31
  249. package/src/components/add-new-template/add-custom-template-modal.js +14 -10
  250. package/src/components/add-new-template/new-template-part.js +7 -9
  251. package/src/components/add-new-template/new-template.js +60 -38
  252. package/src/components/add-new-template/style.scss +12 -6
  253. package/src/components/app/index.js +9 -6
  254. package/src/components/block-editor/editor-canvas.js +2 -1
  255. package/src/components/block-editor/style.scss +1 -1
  256. package/src/components/editor/index.js +62 -65
  257. package/src/components/editor/style.scss +0 -6
  258. package/src/components/global-styles/border-panel.js +24 -199
  259. package/src/components/global-styles/context-menu.js +18 -12
  260. package/src/components/global-styles/dimensions-panel.js +43 -577
  261. package/src/components/global-styles/duotone-panel.js +82 -0
  262. package/src/components/global-styles/filter-utils.js +9 -0
  263. package/src/components/global-styles/hooks.js +12 -36
  264. package/src/components/global-styles/preview.js +155 -140
  265. package/src/components/global-styles/screen-block-list.js +6 -11
  266. package/src/components/global-styles/screen-border.js +10 -3
  267. package/src/components/global-styles/screen-filters.js +27 -0
  268. package/src/components/global-styles/screen-layout.js +9 -2
  269. package/src/components/global-styles/screen-root.js +1 -1
  270. package/src/components/global-styles/screen-style-variations.js +5 -1
  271. package/src/components/global-styles/screen-variations.js +0 -1
  272. package/src/components/global-styles/shadow-panel.js +4 -3
  273. package/src/components/global-styles/style.scss +10 -0
  274. package/src/components/global-styles/typography-panel.js +5 -7
  275. package/src/components/global-styles/ui.js +6 -1
  276. package/src/components/keyboard-shortcut-help-modal/config.js +10 -0
  277. package/src/components/keyboard-shortcuts/edit-mode.js +116 -0
  278. package/src/components/keyboard-shortcuts/global.js +35 -0
  279. package/src/components/keyboard-shortcuts/index.js +70 -0
  280. package/src/components/keyboard-shortcuts/register.js +157 -0
  281. package/src/components/layout/index.js +19 -0
  282. package/src/components/layout/style.scss +9 -4
  283. package/src/components/list/added-by.js +152 -155
  284. package/src/components/list/index.js +3 -1
  285. package/src/components/list/style.scss +5 -13
  286. package/src/components/list/table.js +11 -9
  287. package/src/components/routes/link.js +9 -2
  288. package/src/components/save-hub/index.js +78 -0
  289. package/src/components/save-hub/style.scss +15 -0
  290. package/src/components/save-panel/index.js +8 -1
  291. package/src/components/sidebar/index.js +33 -16
  292. package/src/components/sidebar/style.scss +4 -3
  293. package/src/components/sidebar-button/index.js +21 -0
  294. package/src/components/sidebar-button/style.scss +24 -0
  295. package/src/components/sidebar-edit-mode/global-styles-sidebar.js +3 -7
  296. package/src/components/sidebar-edit-mode/style.scss +16 -0
  297. package/src/components/sidebar-navigation-item/style.scss +1 -23
  298. package/src/components/sidebar-navigation-screen/index.js +37 -38
  299. package/src/components/sidebar-navigation-screen/style.scss +16 -9
  300. package/src/components/sidebar-navigation-screen-main/index.js +24 -11
  301. package/src/components/sidebar-navigation-screen-navigation-item/index.js +39 -26
  302. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +99 -12
  303. package/src/components/sidebar-navigation-screen-navigation-menus/loader.js +9 -0
  304. package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +78 -0
  305. package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +108 -1
  306. package/src/components/sidebar-navigation-screen-template/index.js +89 -30
  307. package/src/components/sidebar-navigation-screen-template/style.scss +25 -0
  308. package/src/components/sidebar-navigation-screen-templates/index.js +29 -14
  309. package/src/components/sidebar-navigation-screen-templates/style.scss +0 -5
  310. package/src/components/sidebar-navigation-screen-templates-browse/index.js +12 -6
  311. package/src/components/site-hub/index.js +5 -1
  312. package/src/components/site-hub/style.scss +5 -1
  313. package/src/components/style-book/index.js +234 -55
  314. package/src/components/style-book/style.scss +1 -45
  315. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +28 -23
  316. package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +38 -8
  317. package/src/components/sync-state-with-url/use-sync-path-with-url.js +77 -17
  318. package/src/components/template-details/index.js +4 -8
  319. package/src/components/template-part-converter/convert-to-regular.js +10 -17
  320. package/src/components/template-part-converter/convert-to-template-part.js +9 -16
  321. package/src/components/template-part-converter/index.js +28 -12
  322. package/src/components/use-edited-entity-record/index.js +26 -18
  323. package/src/index.js +11 -22
  324. package/src/store/actions.js +2 -2
  325. package/src/store/test/actions.js +0 -2
  326. package/src/style.scss +3 -1
  327. package/src/utils/get-is-list-page.js +1 -1
  328. package/src/utils/history.js +13 -9
  329. package/build/components/navigation-inspector/index.js +0 -161
  330. package/build/components/navigation-inspector/index.js.map +0 -1
  331. package/build/components/navigation-inspector/navigation-menu.js +0 -62
  332. package/build/components/navigation-inspector/navigation-menu.js.map +0 -1
  333. package/build-module/components/navigation-inspector/index.js +0 -146
  334. package/build-module/components/navigation-inspector/index.js.map +0 -1
  335. package/build-module/components/navigation-inspector/navigation-menu.js +0 -52
  336. package/build-module/components/navigation-inspector/navigation-menu.js.map +0 -1
  337. package/src/components/navigation-inspector/index.js +0 -191
  338. package/src/components/navigation-inspector/navigation-menu.js +0 -66
  339. package/src/components/navigation-inspector/style.scss +0 -46
@@ -1,146 +0,0 @@
1
- import { createElement, Fragment } from "@wordpress/element";
2
-
3
- /**
4
- * WordPress dependencies
5
- */
6
- import { useSelect } from '@wordpress/data';
7
- import { useState, useEffect } from '@wordpress/element';
8
- import { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';
9
- import { store as blockEditorStore, BlockEditorProvider } from '@wordpress/block-editor';
10
- import { speak } from '@wordpress/a11y';
11
- import { __ } from '@wordpress/i18n';
12
- /**
13
- * Internal dependencies
14
- */
15
-
16
- import NavigationMenu from './navigation-menu';
17
- const NAVIGATION_MENUS_QUERY = [{
18
- per_page: -1,
19
- status: 'publish'
20
- }];
21
- export default function NavigationInspector(_ref) {
22
- var _navigationMenus$;
23
-
24
- let {
25
- onSelect
26
- } = _ref;
27
- const {
28
- selectedNavigationBlockId,
29
- clientIdToRef,
30
- navigationMenus,
31
- isResolvingNavigationMenus,
32
- hasResolvedNavigationMenus,
33
- firstNavigationBlockId
34
- } = useSelect(select => {
35
- const {
36
- __experimentalGetActiveBlockIdByBlockNames,
37
- __experimentalGetGlobalBlocksByName,
38
- getBlock
39
- } = select(blockEditorStore);
40
- const {
41
- getEntityRecords,
42
- hasFinishedResolution,
43
- isResolving
44
- } = select(coreStore);
45
- const navigationMenusQuery = ['postType', 'wp_navigation', NAVIGATION_MENUS_QUERY[0]]; // Get the active Navigation block (if present).
46
-
47
- const selectedNavId = __experimentalGetActiveBlockIdByBlockNames('core/navigation'); // Get all Navigation blocks currently within the editor canvas.
48
-
49
-
50
- const navBlockIds = __experimentalGetGlobalBlocksByName('core/navigation');
51
-
52
- const idToRef = {};
53
- navBlockIds.forEach(id => {
54
- var _getBlock, _getBlock$attributes;
55
-
56
- idToRef[id] = (_getBlock = getBlock(id)) === null || _getBlock === void 0 ? void 0 : (_getBlock$attributes = _getBlock.attributes) === null || _getBlock$attributes === void 0 ? void 0 : _getBlock$attributes.ref;
57
- });
58
- return {
59
- selectedNavigationBlockId: selectedNavId,
60
- firstNavigationBlockId: navBlockIds === null || navBlockIds === void 0 ? void 0 : navBlockIds[0],
61
- clientIdToRef: idToRef,
62
- navigationMenus: getEntityRecords(...navigationMenusQuery),
63
- isResolvingNavigationMenus: isResolving('getEntityRecords', navigationMenusQuery),
64
- hasResolvedNavigationMenus: hasFinishedResolution('getEntityRecords', navigationMenusQuery)
65
- };
66
- }, []);
67
- const firstNavRefInTemplate = clientIdToRef[firstNavigationBlockId];
68
- const firstNavigationMenuRef = navigationMenus === null || navigationMenus === void 0 ? void 0 : (_navigationMenus$ = navigationMenus[0]) === null || _navigationMenus$ === void 0 ? void 0 : _navigationMenus$.id; // Default Navigation Menu is either:
69
- // - the Navigation Menu referenced by the first Nav block within the template.
70
- // - the first of the available Navigation Menus (`wp_navigation`) posts.
71
-
72
- const defaultNavigationMenuId = firstNavRefInTemplate || firstNavigationMenuRef; // The Navigation Menu manually selected by the user within the Nav inspector.
73
-
74
- const [currentMenuId, setCurrentMenuId] = useState(firstNavRefInTemplate); // If a Nav block is selected within the canvas then set the
75
- // Navigation Menu referenced by it's `ref` attribute to be
76
- // active within the Navigation sidebar.
77
-
78
- useEffect(() => {
79
- if (selectedNavigationBlockId) {
80
- setCurrentMenuId(clientIdToRef[selectedNavigationBlockId]);
81
- }
82
- }, [selectedNavigationBlockId]);
83
- const [innerBlocks, onInput, onChange] = useEntityBlockEditor('postType', 'wp_navigation', {
84
- id: currentMenuId || defaultNavigationMenuId
85
- });
86
- const {
87
- isLoadingInnerBlocks,
88
- hasLoadedInnerBlocks
89
- } = useSelect(select => {
90
- const {
91
- isResolving,
92
- hasFinishedResolution
93
- } = select(coreStore);
94
- return {
95
- isLoadingInnerBlocks: isResolving('getEntityRecord', ['postType', 'wp_navigation', currentMenuId || defaultNavigationMenuId]),
96
- hasLoadedInnerBlocks: hasFinishedResolution('getEntityRecord', ['postType', 'wp_navigation', currentMenuId || defaultNavigationMenuId])
97
- };
98
- }, [currentMenuId, defaultNavigationMenuId]);
99
- const isLoading = !(hasResolvedNavigationMenus && hasLoadedInnerBlocks);
100
- const hasNavigationMenus = !!(navigationMenus !== null && navigationMenus !== void 0 && navigationMenus.length); // Entity block editor will return entities that are not currently published.
101
- // Guard by only allowing their usage if there are published Nav Menus.
102
-
103
- const publishedInnerBlocks = hasNavigationMenus ? innerBlocks : [];
104
- const hasInnerBlocks = !!(publishedInnerBlocks !== null && publishedInnerBlocks !== void 0 && publishedInnerBlocks.length);
105
- useEffect(() => {
106
- if (isResolvingNavigationMenus) {
107
- speak('Loading Navigation sidebar menus.');
108
- }
109
-
110
- if (hasResolvedNavigationMenus) {
111
- speak('Navigation sidebar menus have loaded.');
112
- }
113
- }, [isResolvingNavigationMenus, hasResolvedNavigationMenus]);
114
- useEffect(() => {
115
- if (isLoadingInnerBlocks) {
116
- speak('Loading Navigation sidebar selected menu items.');
117
- }
118
-
119
- if (hasLoadedInnerBlocks) {
120
- speak('Navigation sidebar selected menu items have loaded.');
121
- }
122
- }, [isLoadingInnerBlocks, hasLoadedInnerBlocks]);
123
- return createElement("div", {
124
- className: "edit-site-navigation-inspector"
125
- }, hasResolvedNavigationMenus && !hasNavigationMenus && createElement("p", {
126
- className: "edit-site-navigation-inspector__empty-msg"
127
- }, __('There are no Navigation Menus.')), !hasResolvedNavigationMenus && createElement("div", {
128
- className: "edit-site-navigation-inspector__placeholder"
129
- }), isLoading && createElement(Fragment, null, createElement("div", {
130
- className: "edit-site-navigation-inspector__placeholder is-child"
131
- }), createElement("div", {
132
- className: "edit-site-navigation-inspector__placeholder is-child"
133
- }), createElement("div", {
134
- className: "edit-site-navigation-inspector__placeholder is-child"
135
- })), hasInnerBlocks && !isLoading && createElement(BlockEditorProvider, {
136
- value: publishedInnerBlocks,
137
- onChange: onChange,
138
- onInput: onInput
139
- }, createElement(NavigationMenu, {
140
- innerBlocks: publishedInnerBlocks,
141
- onSelect: onSelect
142
- })), !hasInnerBlocks && !isLoading && createElement("p", {
143
- className: "edit-site-navigation-inspector__empty-msg"
144
- }, __('Navigation Menu is empty.')));
145
- }
146
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/navigation-inspector/index.js"],"names":["useSelect","useState","useEffect","store","coreStore","useEntityBlockEditor","blockEditorStore","BlockEditorProvider","speak","__","NavigationMenu","NAVIGATION_MENUS_QUERY","per_page","status","NavigationInspector","onSelect","selectedNavigationBlockId","clientIdToRef","navigationMenus","isResolvingNavigationMenus","hasResolvedNavigationMenus","firstNavigationBlockId","select","__experimentalGetActiveBlockIdByBlockNames","__experimentalGetGlobalBlocksByName","getBlock","getEntityRecords","hasFinishedResolution","isResolving","navigationMenusQuery","selectedNavId","navBlockIds","idToRef","forEach","id","attributes","ref","firstNavRefInTemplate","firstNavigationMenuRef","defaultNavigationMenuId","currentMenuId","setCurrentMenuId","innerBlocks","onInput","onChange","isLoadingInnerBlocks","hasLoadedInnerBlocks","isLoading","hasNavigationMenus","length","publishedInnerBlocks","hasInnerBlocks"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SAASC,KAAK,IAAIC,SAAlB,EAA6BC,oBAA7B,QAAyD,sBAAzD;AACA,SACCF,KAAK,IAAIG,gBADV,EAECC,mBAFD,QAGO,yBAHP;AAIA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,mBAA3B;AAEA,MAAMC,sBAAsB,GAAG,CAAE;AAAEC,EAAAA,QAAQ,EAAE,CAAC,CAAb;AAAgBC,EAAAA,MAAM,EAAE;AAAxB,CAAF,CAA/B;AAEA,eAAe,SAASC,mBAAT,OAA6C;AAAA;;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AAC3D,QAAM;AACLC,IAAAA,yBADK;AAELC,IAAAA,aAFK;AAGLC,IAAAA,eAHK;AAILC,IAAAA,0BAJK;AAKLC,IAAAA,0BALK;AAMLC,IAAAA;AANK,MAOFrB,SAAS,CAAIsB,MAAF,IAAc;AAC5B,UAAM;AACLC,MAAAA,0CADK;AAELC,MAAAA,mCAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAEhB,gBAAF,CAJV;AAMA,UAAM;AAAEoB,MAAAA,gBAAF;AAAoBC,MAAAA,qBAApB;AAA2CC,MAAAA;AAA3C,QACLN,MAAM,CAAElB,SAAF,CADP;AAGA,UAAMyB,oBAAoB,GAAG,CAC5B,UAD4B,EAE5B,eAF4B,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useState, useEffect } from '@wordpress/element';\nimport { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tstore as blockEditorStore,\n\tBlockEditorProvider,\n} from '@wordpress/block-editor';\nimport { speak } from '@wordpress/a11y';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport NavigationMenu from './navigation-menu';\n\nconst NAVIGATION_MENUS_QUERY = [ { per_page: -1, status: 'publish' } ];\n\nexport default function NavigationInspector( { onSelect } ) {\n\tconst {\n\t\tselectedNavigationBlockId,\n\t\tclientIdToRef,\n\t\tnavigationMenus,\n\t\tisResolvingNavigationMenus,\n\t\thasResolvedNavigationMenus,\n\t\tfirstNavigationBlockId,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\t__experimentalGetActiveBlockIdByBlockNames,\n\t\t\t__experimentalGetGlobalBlocksByName,\n\t\t\tgetBlock,\n\t\t} = select( blockEditorStore );\n\n\t\tconst { getEntityRecords, hasFinishedResolution, isResolving } =\n\t\t\tselect( coreStore );\n\n\t\tconst navigationMenusQuery = [\n\t\t\t'postType',\n\t\t\t'wp_navigation',\n\t\t\tNAVIGATION_MENUS_QUERY[ 0 ],\n\t\t];\n\n\t\t// Get the active Navigation block (if present).\n\t\tconst selectedNavId =\n\t\t\t__experimentalGetActiveBlockIdByBlockNames( 'core/navigation' );\n\n\t\t// Get all Navigation blocks currently within the editor canvas.\n\t\tconst navBlockIds =\n\t\t\t__experimentalGetGlobalBlocksByName( 'core/navigation' );\n\t\tconst idToRef = {};\n\t\tnavBlockIds.forEach( ( id ) => {\n\t\t\tidToRef[ id ] = getBlock( id )?.attributes?.ref;\n\t\t} );\n\t\treturn {\n\t\t\tselectedNavigationBlockId: selectedNavId,\n\t\t\tfirstNavigationBlockId: navBlockIds?.[ 0 ],\n\t\t\tclientIdToRef: idToRef,\n\t\t\tnavigationMenus: getEntityRecords( ...navigationMenusQuery ),\n\t\t\tisResolvingNavigationMenus: isResolving(\n\t\t\t\t'getEntityRecords',\n\t\t\t\tnavigationMenusQuery\n\t\t\t),\n\t\t\thasResolvedNavigationMenus: hasFinishedResolution(\n\t\t\t\t'getEntityRecords',\n\t\t\t\tnavigationMenusQuery\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst firstNavRefInTemplate = clientIdToRef[ firstNavigationBlockId ];\n\tconst firstNavigationMenuRef = navigationMenus?.[ 0 ]?.id;\n\n\t// Default Navigation Menu is either:\n\t// - the Navigation Menu referenced by the first Nav block within the template.\n\t// - the first of the available Navigation Menus (`wp_navigation`) posts.\n\tconst defaultNavigationMenuId =\n\t\tfirstNavRefInTemplate || firstNavigationMenuRef;\n\n\t// The Navigation Menu manually selected by the user within the Nav inspector.\n\tconst [ currentMenuId, setCurrentMenuId ] = useState(\n\t\tfirstNavRefInTemplate\n\t);\n\n\t// If a Nav block is selected within the canvas then set the\n\t// Navigation Menu referenced by it's `ref` attribute to be\n\t// active within the Navigation sidebar.\n\tuseEffect( () => {\n\t\tif ( selectedNavigationBlockId ) {\n\t\t\tsetCurrentMenuId( clientIdToRef[ selectedNavigationBlockId ] );\n\t\t}\n\t}, [ selectedNavigationBlockId ] );\n\n\tconst [ innerBlocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\t'wp_navigation',\n\t\t{ id: currentMenuId || defaultNavigationMenuId }\n\t);\n\n\tconst { isLoadingInnerBlocks, hasLoadedInnerBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isResolving, hasFinishedResolution } = select( coreStore );\n\t\t\treturn {\n\t\t\t\tisLoadingInnerBlocks: isResolving( 'getEntityRecord', [\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_navigation',\n\t\t\t\t\tcurrentMenuId || defaultNavigationMenuId,\n\t\t\t\t] ),\n\t\t\t\thasLoadedInnerBlocks: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecord',\n\t\t\t\t\t[\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'wp_navigation',\n\t\t\t\t\t\tcurrentMenuId || defaultNavigationMenuId,\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ currentMenuId, defaultNavigationMenuId ]\n\t);\n\n\tconst isLoading = ! ( hasResolvedNavigationMenus && hasLoadedInnerBlocks );\n\n\tconst hasNavigationMenus = !! navigationMenus?.length;\n\n\t// Entity block editor will return entities that are not currently published.\n\t// Guard by only allowing their usage if there are published Nav Menus.\n\tconst publishedInnerBlocks = hasNavigationMenus ? innerBlocks : [];\n\n\tconst hasInnerBlocks = !! publishedInnerBlocks?.length;\n\n\tuseEffect( () => {\n\t\tif ( isResolvingNavigationMenus ) {\n\t\t\tspeak( 'Loading Navigation sidebar menus.' );\n\t\t}\n\n\t\tif ( hasResolvedNavigationMenus ) {\n\t\t\tspeak( 'Navigation sidebar menus have loaded.' );\n\t\t}\n\t}, [ isResolvingNavigationMenus, hasResolvedNavigationMenus ] );\n\n\tuseEffect( () => {\n\t\tif ( isLoadingInnerBlocks ) {\n\t\t\tspeak( 'Loading Navigation sidebar selected menu items.' );\n\t\t}\n\n\t\tif ( hasLoadedInnerBlocks ) {\n\t\t\tspeak( 'Navigation sidebar selected menu items have loaded.' );\n\t\t}\n\t}, [ isLoadingInnerBlocks, hasLoadedInnerBlocks ] );\n\n\treturn (\n\t\t<div className=\"edit-site-navigation-inspector\">\n\t\t\t{ hasResolvedNavigationMenus && ! hasNavigationMenus && (\n\t\t\t\t<p className=\"edit-site-navigation-inspector__empty-msg\">\n\t\t\t\t\t{ __( 'There are no Navigation Menus.' ) }\n\t\t\t\t</p>\n\t\t\t) }\n\n\t\t\t{ ! hasResolvedNavigationMenus && (\n\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder\" />\n\t\t\t) }\n\t\t\t{ isLoading && (\n\t\t\t\t<>\n\t\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder is-child\" />\n\t\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder is-child\" />\n\t\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder is-child\" />\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ hasInnerBlocks && ! isLoading && (\n\t\t\t\t<BlockEditorProvider\n\t\t\t\t\tvalue={ publishedInnerBlocks }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tonInput={ onInput }\n\t\t\t\t>\n\t\t\t\t\t<NavigationMenu\n\t\t\t\t\t\tinnerBlocks={ publishedInnerBlocks }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t/>\n\t\t\t\t</BlockEditorProvider>\n\t\t\t) }\n\n\t\t\t{ ! hasInnerBlocks && ! isLoading && (\n\t\t\t\t<p className=\"edit-site-navigation-inspector__empty-msg\">\n\t\t\t\t\t{ __( 'Navigation Menu is empty.' ) }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"]}
@@ -1,52 +0,0 @@
1
- import { createElement } from "@wordpress/element";
2
-
3
- /**
4
- * WordPress dependencies
5
- */
6
- import { privateApis as blockEditorPrivateApis, store as blockEditorStore } from '@wordpress/block-editor';
7
- import { useEffect } from '@wordpress/element';
8
- import { useDispatch } from '@wordpress/data';
9
- /**
10
- * Internal dependencies
11
- */
12
-
13
- import { unlock } from '../../private-apis';
14
- const ALLOWED_BLOCKS = {
15
- 'core/navigation': ['core/navigation-link', 'core/search', 'core/social-links', 'core/page-list', 'core/spacer', 'core/home-link', 'core/site-title', 'core/site-logo', 'core/navigation-submenu'],
16
- 'core/social-links': ['core/social-link'],
17
- 'core/navigation-submenu': ['core/navigation-link', 'core/navigation-submenu'],
18
- 'core/navigation-link': ['core/navigation-link', 'core/navigation-submenu']
19
- };
20
- export default function NavigationMenu(_ref) {
21
- let {
22
- innerBlocks,
23
- onSelect
24
- } = _ref;
25
- const {
26
- updateBlockListSettings
27
- } = useDispatch(blockEditorStore);
28
- const {
29
- OffCanvasEditor,
30
- LeafMoreMenu
31
- } = unlock(blockEditorPrivateApis); //TODO: Block settings are normally updated as a side effect of rendering InnerBlocks in BlockList
32
- //Think through a better way of doing this, possible with adding allowed blocks to block library metadata
33
-
34
- useEffect(() => {
35
- updateBlockListSettings('', {
36
- allowedBlocks: ALLOWED_BLOCKS['core/navigation']
37
- });
38
- innerBlocks.forEach(block => {
39
- if (ALLOWED_BLOCKS[block.name]) {
40
- updateBlockListSettings(block.clientId, {
41
- allowedBlocks: ALLOWED_BLOCKS[block.name]
42
- });
43
- }
44
- });
45
- }, [updateBlockListSettings, innerBlocks]);
46
- return createElement(OffCanvasEditor, {
47
- blocks: innerBlocks,
48
- onSelect: onSelect,
49
- LeafMoreMenu: LeafMoreMenu
50
- });
51
- }
52
- //# sourceMappingURL=navigation-menu.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/navigation-inspector/navigation-menu.js"],"names":["privateApis","blockEditorPrivateApis","store","blockEditorStore","useEffect","useDispatch","unlock","ALLOWED_BLOCKS","NavigationMenu","innerBlocks","onSelect","updateBlockListSettings","OffCanvasEditor","LeafMoreMenu","allowedBlocks","forEach","block","name","clientId"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,WAAW,IAAIC,sBADhB,EAECC,KAAK,IAAIC,gBAFV,QAGO,yBAHP;AAIA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,oBAAvB;AAEA,MAAMC,cAAc,GAAG;AACtB,qBAAmB,CAClB,sBADkB,EAElB,aAFkB,EAGlB,mBAHkB,EAIlB,gBAJkB,EAKlB,aALkB,EAMlB,gBANkB,EAOlB,iBAPkB,EAQlB,gBARkB,EASlB,yBATkB,CADG;AAYtB,uBAAqB,CAAE,kBAAF,CAZC;AAatB,6BAA2B,CAC1B,sBAD0B,EAE1B,yBAF0B,CAbL;AAiBtB,0BAAwB,CACvB,sBADuB,EAEvB,yBAFuB;AAjBF,CAAvB;AAuBA,eAAe,SAASC,cAAT,OAAqD;AAAA,MAA5B;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,GAA4B;AACnE,QAAM;AAAEC,IAAAA;AAAF,MAA8BN,WAAW,CAAEF,gBAAF,CAA/C;AAEA,QAAM;AAAES,IAAAA,eAAF;AAAmBC,IAAAA;AAAnB,MAAoCP,MAAM,CAAEL,sBAAF,CAAhD,CAHmE,CAKnE;AACA;;AACAG,EAAAA,SAAS,CAAE,MAAM;AAChBO,IAAAA,uBAAuB,CAAE,EAAF,EAAM;AAC5BG,MAAAA,aAAa,EAAEP,cAAc,CAAE,iBAAF;AADD,KAAN,CAAvB;AAGAE,IAAAA,WAAW,CAACM,OAAZ,CAAuBC,KAAF,IAAa;AACjC,UAAKT,cAAc,CAAES,KAAK,CAACC,IAAR,CAAnB,EAAoC;AACnCN,QAAAA,uBAAuB,CAAEK,KAAK,CAACE,QAAR,EAAkB;AACxCJ,UAAAA,aAAa,EAAEP,cAAc,CAAES,KAAK,CAACC,IAAR;AADW,SAAlB,CAAvB;AAGA;AACD,KAND;AAOA,GAXQ,EAWN,CAAEN,uBAAF,EAA2BF,WAA3B,CAXM,CAAT;AAaA,SACC,cAAC,eAAD;AACC,IAAA,MAAM,EAAGA,WADV;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,YAAY,EAAGG;AAHhB,IADD;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\n\nconst ALLOWED_BLOCKS = {\n\t'core/navigation': [\n\t\t'core/navigation-link',\n\t\t'core/search',\n\t\t'core/social-links',\n\t\t'core/page-list',\n\t\t'core/spacer',\n\t\t'core/home-link',\n\t\t'core/site-title',\n\t\t'core/site-logo',\n\t\t'core/navigation-submenu',\n\t],\n\t'core/social-links': [ 'core/social-link' ],\n\t'core/navigation-submenu': [\n\t\t'core/navigation-link',\n\t\t'core/navigation-submenu',\n\t],\n\t'core/navigation-link': [\n\t\t'core/navigation-link',\n\t\t'core/navigation-submenu',\n\t],\n};\n\nexport default function NavigationMenu( { innerBlocks, onSelect } ) {\n\tconst { updateBlockListSettings } = useDispatch( blockEditorStore );\n\n\tconst { OffCanvasEditor, LeafMoreMenu } = unlock( blockEditorPrivateApis );\n\n\t//TODO: Block settings are normally updated as a side effect of rendering InnerBlocks in BlockList\n\t//Think through a better way of doing this, possible with adding allowed blocks to block library metadata\n\tuseEffect( () => {\n\t\tupdateBlockListSettings( '', {\n\t\t\tallowedBlocks: ALLOWED_BLOCKS[ 'core/navigation' ],\n\t\t} );\n\t\tinnerBlocks.forEach( ( block ) => {\n\t\t\tif ( ALLOWED_BLOCKS[ block.name ] ) {\n\t\t\t\tupdateBlockListSettings( block.clientId, {\n\t\t\t\t\tallowedBlocks: ALLOWED_BLOCKS[ block.name ],\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t}, [ updateBlockListSettings, innerBlocks ] );\n\n\treturn (\n\t\t<OffCanvasEditor\n\t\t\tblocks={ innerBlocks }\n\t\t\tonSelect={ onSelect }\n\t\t\tLeafMoreMenu={ LeafMoreMenu }\n\t\t/>\n\t);\n}\n"]}
@@ -1,191 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useSelect } from '@wordpress/data';
5
- import { useState, useEffect } from '@wordpress/element';
6
- import { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';
7
- import {
8
- store as blockEditorStore,
9
- BlockEditorProvider,
10
- } from '@wordpress/block-editor';
11
- import { speak } from '@wordpress/a11y';
12
- import { __ } from '@wordpress/i18n';
13
-
14
- /**
15
- * Internal dependencies
16
- */
17
- import NavigationMenu from './navigation-menu';
18
-
19
- const NAVIGATION_MENUS_QUERY = [ { per_page: -1, status: 'publish' } ];
20
-
21
- export default function NavigationInspector( { onSelect } ) {
22
- const {
23
- selectedNavigationBlockId,
24
- clientIdToRef,
25
- navigationMenus,
26
- isResolvingNavigationMenus,
27
- hasResolvedNavigationMenus,
28
- firstNavigationBlockId,
29
- } = useSelect( ( select ) => {
30
- const {
31
- __experimentalGetActiveBlockIdByBlockNames,
32
- __experimentalGetGlobalBlocksByName,
33
- getBlock,
34
- } = select( blockEditorStore );
35
-
36
- const { getEntityRecords, hasFinishedResolution, isResolving } =
37
- select( coreStore );
38
-
39
- const navigationMenusQuery = [
40
- 'postType',
41
- 'wp_navigation',
42
- NAVIGATION_MENUS_QUERY[ 0 ],
43
- ];
44
-
45
- // Get the active Navigation block (if present).
46
- const selectedNavId =
47
- __experimentalGetActiveBlockIdByBlockNames( 'core/navigation' );
48
-
49
- // Get all Navigation blocks currently within the editor canvas.
50
- const navBlockIds =
51
- __experimentalGetGlobalBlocksByName( 'core/navigation' );
52
- const idToRef = {};
53
- navBlockIds.forEach( ( id ) => {
54
- idToRef[ id ] = getBlock( id )?.attributes?.ref;
55
- } );
56
- return {
57
- selectedNavigationBlockId: selectedNavId,
58
- firstNavigationBlockId: navBlockIds?.[ 0 ],
59
- clientIdToRef: idToRef,
60
- navigationMenus: getEntityRecords( ...navigationMenusQuery ),
61
- isResolvingNavigationMenus: isResolving(
62
- 'getEntityRecords',
63
- navigationMenusQuery
64
- ),
65
- hasResolvedNavigationMenus: hasFinishedResolution(
66
- 'getEntityRecords',
67
- navigationMenusQuery
68
- ),
69
- };
70
- }, [] );
71
-
72
- const firstNavRefInTemplate = clientIdToRef[ firstNavigationBlockId ];
73
- const firstNavigationMenuRef = navigationMenus?.[ 0 ]?.id;
74
-
75
- // Default Navigation Menu is either:
76
- // - the Navigation Menu referenced by the first Nav block within the template.
77
- // - the first of the available Navigation Menus (`wp_navigation`) posts.
78
- const defaultNavigationMenuId =
79
- firstNavRefInTemplate || firstNavigationMenuRef;
80
-
81
- // The Navigation Menu manually selected by the user within the Nav inspector.
82
- const [ currentMenuId, setCurrentMenuId ] = useState(
83
- firstNavRefInTemplate
84
- );
85
-
86
- // If a Nav block is selected within the canvas then set the
87
- // Navigation Menu referenced by it's `ref` attribute to be
88
- // active within the Navigation sidebar.
89
- useEffect( () => {
90
- if ( selectedNavigationBlockId ) {
91
- setCurrentMenuId( clientIdToRef[ selectedNavigationBlockId ] );
92
- }
93
- }, [ selectedNavigationBlockId ] );
94
-
95
- const [ innerBlocks, onInput, onChange ] = useEntityBlockEditor(
96
- 'postType',
97
- 'wp_navigation',
98
- { id: currentMenuId || defaultNavigationMenuId }
99
- );
100
-
101
- const { isLoadingInnerBlocks, hasLoadedInnerBlocks } = useSelect(
102
- ( select ) => {
103
- const { isResolving, hasFinishedResolution } = select( coreStore );
104
- return {
105
- isLoadingInnerBlocks: isResolving( 'getEntityRecord', [
106
- 'postType',
107
- 'wp_navigation',
108
- currentMenuId || defaultNavigationMenuId,
109
- ] ),
110
- hasLoadedInnerBlocks: hasFinishedResolution(
111
- 'getEntityRecord',
112
- [
113
- 'postType',
114
- 'wp_navigation',
115
- currentMenuId || defaultNavigationMenuId,
116
- ]
117
- ),
118
- };
119
- },
120
- [ currentMenuId, defaultNavigationMenuId ]
121
- );
122
-
123
- const isLoading = ! ( hasResolvedNavigationMenus && hasLoadedInnerBlocks );
124
-
125
- const hasNavigationMenus = !! navigationMenus?.length;
126
-
127
- // Entity block editor will return entities that are not currently published.
128
- // Guard by only allowing their usage if there are published Nav Menus.
129
- const publishedInnerBlocks = hasNavigationMenus ? innerBlocks : [];
130
-
131
- const hasInnerBlocks = !! publishedInnerBlocks?.length;
132
-
133
- useEffect( () => {
134
- if ( isResolvingNavigationMenus ) {
135
- speak( 'Loading Navigation sidebar menus.' );
136
- }
137
-
138
- if ( hasResolvedNavigationMenus ) {
139
- speak( 'Navigation sidebar menus have loaded.' );
140
- }
141
- }, [ isResolvingNavigationMenus, hasResolvedNavigationMenus ] );
142
-
143
- useEffect( () => {
144
- if ( isLoadingInnerBlocks ) {
145
- speak( 'Loading Navigation sidebar selected menu items.' );
146
- }
147
-
148
- if ( hasLoadedInnerBlocks ) {
149
- speak( 'Navigation sidebar selected menu items have loaded.' );
150
- }
151
- }, [ isLoadingInnerBlocks, hasLoadedInnerBlocks ] );
152
-
153
- return (
154
- <div className="edit-site-navigation-inspector">
155
- { hasResolvedNavigationMenus && ! hasNavigationMenus && (
156
- <p className="edit-site-navigation-inspector__empty-msg">
157
- { __( 'There are no Navigation Menus.' ) }
158
- </p>
159
- ) }
160
-
161
- { ! hasResolvedNavigationMenus && (
162
- <div className="edit-site-navigation-inspector__placeholder" />
163
- ) }
164
- { isLoading && (
165
- <>
166
- <div className="edit-site-navigation-inspector__placeholder is-child" />
167
- <div className="edit-site-navigation-inspector__placeholder is-child" />
168
- <div className="edit-site-navigation-inspector__placeholder is-child" />
169
- </>
170
- ) }
171
- { hasInnerBlocks && ! isLoading && (
172
- <BlockEditorProvider
173
- value={ publishedInnerBlocks }
174
- onChange={ onChange }
175
- onInput={ onInput }
176
- >
177
- <NavigationMenu
178
- innerBlocks={ publishedInnerBlocks }
179
- onSelect={ onSelect }
180
- />
181
- </BlockEditorProvider>
182
- ) }
183
-
184
- { ! hasInnerBlocks && ! isLoading && (
185
- <p className="edit-site-navigation-inspector__empty-msg">
186
- { __( 'Navigation Menu is empty.' ) }
187
- </p>
188
- ) }
189
- </div>
190
- );
191
- }
@@ -1,66 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import {
5
- privateApis as blockEditorPrivateApis,
6
- store as blockEditorStore,
7
- } from '@wordpress/block-editor';
8
- import { useEffect } from '@wordpress/element';
9
- import { useDispatch } from '@wordpress/data';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
- import { unlock } from '../../private-apis';
15
-
16
- const ALLOWED_BLOCKS = {
17
- 'core/navigation': [
18
- 'core/navigation-link',
19
- 'core/search',
20
- 'core/social-links',
21
- 'core/page-list',
22
- 'core/spacer',
23
- 'core/home-link',
24
- 'core/site-title',
25
- 'core/site-logo',
26
- 'core/navigation-submenu',
27
- ],
28
- 'core/social-links': [ 'core/social-link' ],
29
- 'core/navigation-submenu': [
30
- 'core/navigation-link',
31
- 'core/navigation-submenu',
32
- ],
33
- 'core/navigation-link': [
34
- 'core/navigation-link',
35
- 'core/navigation-submenu',
36
- ],
37
- };
38
-
39
- export default function NavigationMenu( { innerBlocks, onSelect } ) {
40
- const { updateBlockListSettings } = useDispatch( blockEditorStore );
41
-
42
- const { OffCanvasEditor, LeafMoreMenu } = unlock( blockEditorPrivateApis );
43
-
44
- //TODO: Block settings are normally updated as a side effect of rendering InnerBlocks in BlockList
45
- //Think through a better way of doing this, possible with adding allowed blocks to block library metadata
46
- useEffect( () => {
47
- updateBlockListSettings( '', {
48
- allowedBlocks: ALLOWED_BLOCKS[ 'core/navigation' ],
49
- } );
50
- innerBlocks.forEach( ( block ) => {
51
- if ( ALLOWED_BLOCKS[ block.name ] ) {
52
- updateBlockListSettings( block.clientId, {
53
- allowedBlocks: ALLOWED_BLOCKS[ block.name ],
54
- } );
55
- }
56
- } );
57
- }, [ updateBlockListSettings, innerBlocks ] );
58
-
59
- return (
60
- <OffCanvasEditor
61
- blocks={ innerBlocks }
62
- onSelect={ onSelect }
63
- LeafMoreMenu={ LeafMoreMenu }
64
- />
65
- );
66
- }
@@ -1,46 +0,0 @@
1
- @keyframes loadingpulse {
2
- 0% {
3
- opacity: 1;
4
- }
5
- 50% {
6
- opacity: 0.5;
7
- }
8
- 100% {
9
- opacity: 1;
10
- }
11
- }
12
-
13
- .edit-site-navigation-inspector {
14
- .block-editor-list-view-leaf .block-editor-list-view-block-contents {
15
- white-space: normal;
16
- }
17
-
18
- .block-editor-list-view-block__title {
19
- margin-top: 3px;
20
- }
21
-
22
- .block-editor-list-view-block__menu-cell {
23
- padding-right: 0;
24
- }
25
-
26
- .edit-site-navigation-inspector__select-menu {
27
- margin-bottom: $grid-unit-10;
28
- }
29
- }
30
-
31
- .edit-site-navigation-inspector__placeholder {
32
- padding: $grid-unit-10;
33
- margin: $grid-unit-10;
34
- background-color: $gray-100;
35
- animation: loadingpulse 1s linear infinite;
36
- animation-delay: 0.5s; // avoid animating for fast network responses
37
-
38
- &.is-child {
39
- margin-left: $grid-unit-30;
40
- width: 50%;
41
- }
42
- }
43
-
44
- .edit-site-navigation-inspector__empty-msg {
45
- padding: 0 $grid-unit-10;
46
- }