@wordpress/edit-site 5.9.0 → 5.10.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 (426) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/add-new-template/add-custom-template-modal.js +21 -6
  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 -2
  5. package/build/components/add-new-template/new-template-part.js.map +1 -1
  6. package/build/components/add-new-template/new-template.js +6 -3
  7. package/build/components/add-new-template/new-template.js.map +1 -1
  8. package/build/components/app/index.js +8 -2
  9. package/build/components/app/index.js.map +1 -1
  10. package/build/components/block-editor/back-button.js +10 -3
  11. package/build/components/block-editor/back-button.js.map +1 -1
  12. package/build/components/block-editor/editor-canvas.js +39 -6
  13. package/build/components/block-editor/editor-canvas.js.map +1 -1
  14. package/build/components/editor/index.js +43 -9
  15. package/build/components/editor/index.js.map +1 -1
  16. package/build/components/editor-canvas-container/index.js +18 -4
  17. package/build/components/editor-canvas-container/index.js.map +1 -1
  18. package/build/components/global-styles/block-preview-panel.js +1 -1
  19. package/build/components/global-styles/block-preview-panel.js.map +1 -1
  20. package/build/components/global-styles/border-panel.js +3 -1
  21. package/build/components/global-styles/border-panel.js.map +1 -1
  22. package/build/components/global-styles/color-palette-panel.js +14 -3
  23. package/build/components/global-styles/color-palette-panel.js.map +1 -1
  24. package/build/components/global-styles/dimensions-panel.js +17 -18
  25. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  26. package/build/components/global-styles/gradients-palette-panel.js +14 -3
  27. package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
  28. package/build/components/global-styles/root-menu.js +61 -0
  29. package/build/components/global-styles/root-menu.js.map +1 -0
  30. package/build/components/global-styles/screen-block-list.js +3 -1
  31. package/build/components/global-styles/screen-block-list.js.map +1 -1
  32. package/build/components/global-styles/screen-block.js +158 -7
  33. package/build/components/global-styles/screen-block.js.map +1 -1
  34. package/build/components/global-styles/screen-colors.js +9 -26
  35. package/build/components/global-styles/screen-colors.js.map +1 -1
  36. package/build/components/global-styles/screen-css.js +20 -15
  37. package/build/components/global-styles/screen-css.js.map +1 -1
  38. package/build/components/global-styles/screen-layout.js +4 -17
  39. package/build/components/global-styles/screen-layout.js.map +1 -1
  40. package/build/components/global-styles/screen-revisions/index.js +148 -0
  41. package/build/components/global-styles/screen-revisions/index.js.map +1 -0
  42. package/build/components/global-styles/screen-revisions/revisions-buttons.js +132 -0
  43. package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -0
  44. package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js +130 -0
  45. package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -0
  46. package/build/components/global-styles/screen-root.js +2 -2
  47. package/build/components/global-styles/screen-root.js.map +1 -1
  48. package/build/components/global-styles/screen-typography-element.js +0 -3
  49. package/build/components/global-styles/screen-typography-element.js.map +1 -1
  50. package/build/components/global-styles/screen-typography.js +11 -39
  51. package/build/components/global-styles/screen-typography.js.map +1 -1
  52. package/build/components/global-styles/style-variations-container.js +3 -8
  53. package/build/components/global-styles/style-variations-container.js.map +1 -1
  54. package/build/components/global-styles/typography-panel.js +7 -11
  55. package/build/components/global-styles/typography-panel.js.map +1 -1
  56. package/build/components/global-styles/ui.js +61 -108
  57. package/build/components/global-styles/ui.js.map +1 -1
  58. package/build/components/global-styles/variations-panel.js +4 -28
  59. package/build/components/global-styles/variations-panel.js.map +1 -1
  60. package/build/components/header-edit-mode/index.js +1 -1
  61. package/build/components/header-edit-mode/index.js.map +1 -1
  62. package/build/components/keyboard-shortcuts/register.js +1 -1
  63. package/build/components/keyboard-shortcuts/register.js.map +1 -1
  64. package/build/components/layout/index.js +13 -7
  65. package/build/components/layout/index.js.map +1 -1
  66. package/build/components/list/index.js +9 -3
  67. package/build/components/list/index.js.map +1 -1
  68. package/build/components/list/table.js +1 -1
  69. package/build/components/list/table.js.map +1 -1
  70. package/build/components/plugin-template-setting-panel/index.js +44 -0
  71. package/build/components/plugin-template-setting-panel/index.js.map +1 -0
  72. package/build/components/revisions/index.js +95 -0
  73. package/build/components/revisions/index.js.map +1 -0
  74. package/build/components/routes/link.js +17 -2
  75. package/build/components/routes/link.js.map +1 -1
  76. package/build/components/routes/use-title.js +8 -2
  77. package/build/components/routes/use-title.js.map +1 -1
  78. package/build/components/save-button/index.js +31 -6
  79. package/build/components/save-button/index.js.map +1 -1
  80. package/build/components/save-hub/index.js +14 -31
  81. package/build/components/save-hub/index.js.map +1 -1
  82. package/build/components/save-panel/index.js +20 -7
  83. package/build/components/save-panel/index.js.map +1 -1
  84. package/build/components/secondary-sidebar/list-view-sidebar.js +2 -7
  85. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  86. package/build/components/sidebar/index.js +16 -2
  87. package/build/components/sidebar/index.js.map +1 -1
  88. package/build/components/sidebar-edit-mode/global-styles-sidebar.js +9 -3
  89. package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  90. package/build/components/sidebar-edit-mode/index.js +9 -2
  91. package/build/components/sidebar-edit-mode/index.js.map +1 -1
  92. package/build/components/sidebar-edit-mode/sidebar-fixed-bottom.js +40 -0
  93. package/build/components/sidebar-edit-mode/sidebar-fixed-bottom.js.map +1 -0
  94. package/build/components/sidebar-edit-mode/template-card/index.js +1 -8
  95. package/build/components/sidebar-edit-mode/template-card/index.js.map +1 -1
  96. package/build/components/sidebar-edit-mode/{template-card/last-revision.js → template-revisions/index.js} +1 -1
  97. package/build/components/sidebar-edit-mode/template-revisions/index.js.map +1 -0
  98. package/build/components/sidebar-navigation-item/index.js +5 -7
  99. package/build/components/sidebar-navigation-item/index.js.map +1 -1
  100. package/build/components/sidebar-navigation-screen/index.js +14 -4
  101. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  102. package/build/components/sidebar-navigation-screen-main/index.js +24 -7
  103. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  104. package/build/components/sidebar-navigation-screen-navigation-item/index.js +1 -1
  105. package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  106. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +17 -5
  107. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  108. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +3 -3
  109. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
  110. package/build/components/sidebar-navigation-screen-page/index.js +67 -0
  111. package/build/components/sidebar-navigation-screen-page/index.js.map +1 -0
  112. package/build/components/sidebar-navigation-screen-pages/index.js +74 -0
  113. package/build/components/sidebar-navigation-screen-pages/index.js.map +1 -0
  114. package/build/components/sidebar-navigation-screen-templates/index.js +5 -3
  115. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  116. package/build/components/sidebar-navigation-subtitle/index.js +18 -0
  117. package/build/components/sidebar-navigation-subtitle/index.js.map +1 -0
  118. package/build/components/site-hub/index.js +36 -6
  119. package/build/components/site-hub/index.js.map +1 -1
  120. package/build/components/start-template-options/index.js +12 -16
  121. package/build/components/start-template-options/index.js.map +1 -1
  122. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +8 -2
  123. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  124. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +9 -4
  125. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  126. package/build/components/sync-state-with-url/use-sync-path-with-url.js +17 -3
  127. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  128. package/build/components/template-details/template-areas.js +9 -3
  129. package/build/components/template-details/template-areas.js.map +1 -1
  130. package/build/hooks/template-part-edit.js +8 -2
  131. package/build/hooks/template-part-edit.js.map +1 -1
  132. package/build/index.js +8 -0
  133. package/build/index.js.map +1 -1
  134. package/build/utils/is-previewing-theme.js +27 -0
  135. package/build/utils/is-previewing-theme.js.map +1 -0
  136. package/build/utils/use-activate-theme.js +46 -0
  137. package/build/utils/use-activate-theme.js.map +1 -0
  138. package/build-module/components/add-new-template/add-custom-template-modal.js +21 -6
  139. package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
  140. package/build-module/components/add-new-template/new-template-part.js +5 -1
  141. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  142. package/build-module/components/add-new-template/new-template.js +4 -1
  143. package/build-module/components/add-new-template/new-template.js.map +1 -1
  144. package/build-module/components/app/index.js +6 -2
  145. package/build-module/components/app/index.js.map +1 -1
  146. package/build-module/components/block-editor/back-button.js +6 -1
  147. package/build-module/components/block-editor/back-button.js.map +1 -1
  148. package/build-module/components/block-editor/editor-canvas.js +37 -6
  149. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  150. package/build-module/components/editor/index.js +45 -11
  151. package/build-module/components/editor/index.js.map +1 -1
  152. package/build-module/components/editor-canvas-container/index.js +21 -6
  153. package/build-module/components/editor-canvas-container/index.js.map +1 -1
  154. package/build-module/components/global-styles/block-preview-panel.js +1 -1
  155. package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
  156. package/build-module/components/global-styles/border-panel.js +3 -1
  157. package/build-module/components/global-styles/border-panel.js.map +1 -1
  158. package/build-module/components/global-styles/color-palette-panel.js +13 -3
  159. package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
  160. package/build-module/components/global-styles/dimensions-panel.js +17 -18
  161. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  162. package/build-module/components/global-styles/gradients-palette-panel.js +13 -3
  163. package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
  164. package/build-module/components/global-styles/root-menu.js +47 -0
  165. package/build-module/components/global-styles/root-menu.js.map +1 -0
  166. package/build-module/components/global-styles/screen-block-list.js +4 -2
  167. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  168. package/build-module/components/global-styles/screen-block.js +151 -7
  169. package/build-module/components/global-styles/screen-block.js.map +1 -1
  170. package/build-module/components/global-styles/screen-colors.js +9 -25
  171. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  172. package/build-module/components/global-styles/screen-css.js +20 -15
  173. package/build-module/components/global-styles/screen-css.js.map +1 -1
  174. package/build-module/components/global-styles/screen-layout.js +4 -16
  175. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  176. package/build-module/components/global-styles/screen-revisions/index.js +128 -0
  177. package/build-module/components/global-styles/screen-revisions/index.js.map +1 -0
  178. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +121 -0
  179. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -0
  180. package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js +116 -0
  181. package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -0
  182. package/build-module/components/global-styles/screen-root.js +2 -2
  183. package/build-module/components/global-styles/screen-root.js.map +1 -1
  184. package/build-module/components/global-styles/screen-typography-element.js +0 -3
  185. package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
  186. package/build-module/components/global-styles/screen-typography.js +11 -37
  187. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  188. package/build-module/components/global-styles/style-variations-container.js +3 -7
  189. package/build-module/components/global-styles/style-variations-container.js.map +1 -1
  190. package/build-module/components/global-styles/typography-panel.js +7 -11
  191. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  192. package/build-module/components/global-styles/ui.js +61 -105
  193. package/build-module/components/global-styles/ui.js.map +1 -1
  194. package/build-module/components/global-styles/variations-panel.js +3 -22
  195. package/build-module/components/global-styles/variations-panel.js.map +1 -1
  196. package/build-module/components/header-edit-mode/index.js +2 -2
  197. package/build-module/components/header-edit-mode/index.js.map +1 -1
  198. package/build-module/components/keyboard-shortcuts/register.js +1 -1
  199. package/build-module/components/keyboard-shortcuts/register.js.map +1 -1
  200. package/build-module/components/layout/index.js +9 -3
  201. package/build-module/components/layout/index.js.map +1 -1
  202. package/build-module/components/list/index.js +5 -1
  203. package/build-module/components/list/index.js.map +1 -1
  204. package/build-module/components/list/table.js +1 -1
  205. package/build-module/components/list/table.js.map +1 -1
  206. package/build-module/components/plugin-template-setting-panel/index.js +35 -0
  207. package/build-module/components/plugin-template-setting-panel/index.js.map +1 -0
  208. package/build-module/components/revisions/index.js +77 -0
  209. package/build-module/components/revisions/index.js.map +1 -0
  210. package/build-module/components/routes/link.js +13 -1
  211. package/build-module/components/routes/link.js.map +1 -1
  212. package/build-module/components/routes/use-title.js +5 -1
  213. package/build-module/components/routes/use-title.js.map +1 -1
  214. package/build-module/components/save-button/index.js +28 -6
  215. package/build-module/components/save-button/index.js.map +1 -1
  216. package/build-module/components/save-hub/index.js +13 -32
  217. package/build-module/components/save-hub/index.js.map +1 -1
  218. package/build-module/components/save-panel/index.js +19 -7
  219. package/build-module/components/save-panel/index.js.map +1 -1
  220. package/build-module/components/secondary-sidebar/list-view-sidebar.js +3 -8
  221. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  222. package/build-module/components/sidebar/index.js +11 -1
  223. package/build-module/components/sidebar/index.js.map +1 -1
  224. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +9 -3
  225. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  226. package/build-module/components/sidebar-edit-mode/index.js +10 -5
  227. package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
  228. package/build-module/components/sidebar-edit-mode/sidebar-fixed-bottom.js +29 -0
  229. package/build-module/components/sidebar-edit-mode/sidebar-fixed-bottom.js.map +1 -0
  230. package/build-module/components/sidebar-edit-mode/template-card/index.js +2 -7
  231. package/build-module/components/sidebar-edit-mode/template-card/index.js.map +1 -1
  232. package/build-module/components/sidebar-edit-mode/{template-card/last-revision.js → template-revisions/index.js} +1 -1
  233. package/build-module/components/sidebar-edit-mode/template-revisions/index.js.map +1 -0
  234. package/build-module/components/sidebar-navigation-item/index.js +6 -8
  235. package/build-module/components/sidebar-navigation-item/index.js.map +1 -1
  236. package/build-module/components/sidebar-navigation-screen/index.js +13 -5
  237. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  238. package/build-module/components/sidebar-navigation-screen-main/index.js +25 -8
  239. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  240. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +1 -1
  241. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  242. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +13 -3
  243. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  244. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +3 -3
  245. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
  246. package/build-module/components/sidebar-navigation-screen-page/index.js +48 -0
  247. package/build-module/components/sidebar-navigation-screen-page/index.js.map +1 -0
  248. package/build-module/components/sidebar-navigation-screen-pages/index.js +57 -0
  249. package/build-module/components/sidebar-navigation-screen-pages/index.js.map +1 -0
  250. package/build-module/components/sidebar-navigation-screen-templates/index.js +5 -3
  251. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  252. package/build-module/components/sidebar-navigation-subtitle/index.js +10 -0
  253. package/build-module/components/sidebar-navigation-subtitle/index.js.map +1 -0
  254. package/build-module/components/site-hub/index.js +34 -6
  255. package/build-module/components/site-hub/index.js.map +1 -1
  256. package/build-module/components/start-template-options/index.js +13 -17
  257. package/build-module/components/start-template-options/index.js.map +1 -1
  258. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -1
  259. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  260. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +5 -1
  261. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  262. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +13 -1
  263. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  264. package/build-module/components/template-details/template-areas.js +5 -1
  265. package/build-module/components/template-details/template-areas.js.map +1 -1
  266. package/build-module/hooks/template-part-edit.js +5 -1
  267. package/build-module/hooks/template-part-edit.js.map +1 -1
  268. package/build-module/index.js +1 -0
  269. package/build-module/index.js.map +1 -1
  270. package/build-module/utils/is-previewing-theme.js +17 -0
  271. package/build-module/utils/is-previewing-theme.js.map +1 -0
  272. package/build-module/utils/use-activate-theme.js +36 -0
  273. package/build-module/utils/use-activate-theme.js.map +1 -0
  274. package/build-style/style-rtl.css +199 -78
  275. package/build-style/style.css +199 -78
  276. package/package.json +36 -34
  277. package/src/components/add-new-template/add-custom-template-modal.js +31 -8
  278. package/src/components/add-new-template/new-template-part.js +4 -1
  279. package/src/components/add-new-template/new-template.js +3 -1
  280. package/src/components/add-new-template/style.scss +52 -48
  281. package/src/components/app/index.js +6 -3
  282. package/src/components/block-editor/back-button.js +4 -1
  283. package/src/components/block-editor/editor-canvas.js +36 -8
  284. package/src/components/block-editor/style.scss +15 -8
  285. package/src/components/editor/index.js +48 -7
  286. package/src/components/editor-canvas-container/index.js +30 -17
  287. package/src/components/global-styles/block-preview-panel.js +1 -1
  288. package/src/components/global-styles/border-panel.js +3 -1
  289. package/src/components/global-styles/color-palette-panel.js +9 -0
  290. package/src/components/global-styles/dimensions-panel.js +15 -15
  291. package/src/components/global-styles/gradients-palette-panel.js +8 -0
  292. package/src/components/global-styles/root-menu.js +66 -0
  293. package/src/components/global-styles/screen-block-list.js +2 -2
  294. package/src/components/global-styles/screen-block.js +184 -7
  295. package/src/components/global-styles/screen-colors.js +9 -16
  296. package/src/components/global-styles/screen-css.js +21 -21
  297. package/src/components/global-styles/screen-layout.js +5 -9
  298. package/src/components/global-styles/screen-revisions/index.js +177 -0
  299. package/src/components/global-styles/screen-revisions/revisions-buttons.js +131 -0
  300. package/src/components/global-styles/screen-revisions/style.scss +99 -0
  301. package/src/components/global-styles/screen-revisions/test/use-global-styles-revisions.js +125 -0
  302. package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +103 -0
  303. package/src/components/global-styles/screen-root.js +2 -2
  304. package/src/components/global-styles/screen-typography-element.js +1 -3
  305. package/src/components/global-styles/screen-typography.js +44 -79
  306. package/src/components/global-styles/style-variations-container.js +4 -10
  307. package/src/components/global-styles/style.scss +1 -23
  308. package/src/components/global-styles/typography-panel.js +12 -13
  309. package/src/components/global-styles/ui.js +72 -101
  310. package/src/components/global-styles/variations-panel.js +3 -26
  311. package/src/components/header-edit-mode/index.js +5 -2
  312. package/src/components/keyboard-shortcuts/register.js +1 -1
  313. package/src/components/layout/index.js +7 -3
  314. package/src/components/layout/style.scss +2 -4
  315. package/src/components/list/index.js +4 -1
  316. package/src/components/list/style.scss +4 -0
  317. package/src/components/list/table.js +3 -1
  318. package/src/components/plugin-template-setting-panel/index.js +33 -0
  319. package/src/components/revisions/index.js +104 -0
  320. package/src/components/routes/link.js +16 -1
  321. package/src/components/routes/use-title.js +4 -1
  322. package/src/components/save-button/index.js +27 -6
  323. package/src/components/save-hub/index.js +17 -35
  324. package/src/components/save-panel/index.js +15 -3
  325. package/src/components/secondary-sidebar/list-view-sidebar.js +2 -6
  326. package/src/components/sidebar/index.js +12 -1
  327. package/src/components/sidebar-edit-mode/global-styles-sidebar.js +9 -7
  328. package/src/components/sidebar-edit-mode/index.js +17 -6
  329. package/src/components/sidebar-edit-mode/sidebar-fixed-bottom.js +26 -0
  330. package/src/components/sidebar-edit-mode/style.scss +10 -0
  331. package/src/components/sidebar-edit-mode/template-card/index.js +1 -9
  332. package/src/components/sidebar-navigation-item/index.js +13 -14
  333. package/src/components/sidebar-navigation-item/style.scss +8 -1
  334. package/src/components/sidebar-navigation-screen/index.js +26 -5
  335. package/src/components/sidebar-navigation-screen-main/index.js +43 -22
  336. package/src/components/sidebar-navigation-screen-navigation-item/index.js +3 -9
  337. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +13 -1
  338. package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +3 -3
  339. package/src/components/sidebar-navigation-screen-page/index.js +59 -0
  340. package/src/components/sidebar-navigation-screen-pages/index.js +82 -0
  341. package/src/components/sidebar-navigation-screen-pages/style.scss +4 -0
  342. package/src/components/sidebar-navigation-screen-templates/index.js +5 -1
  343. package/src/components/sidebar-navigation-subtitle/index.js +5 -0
  344. package/src/components/sidebar-navigation-subtitle/style.scss +7 -0
  345. package/src/components/site-hub/index.js +89 -58
  346. package/src/components/site-hub/style.scss +8 -0
  347. package/src/components/start-template-options/index.js +19 -27
  348. package/src/components/start-template-options/style.scss +29 -21
  349. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +4 -1
  350. package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +3 -1
  351. package/src/components/sync-state-with-url/use-sync-path-with-url.js +14 -1
  352. package/src/components/template-details/template-areas.js +4 -1
  353. package/src/hooks/template-part-edit.js +4 -1
  354. package/src/index.js +1 -0
  355. package/src/store/test/actions.js +6 -14
  356. package/src/style.scss +4 -1
  357. package/src/utils/is-previewing-theme.js +18 -0
  358. package/src/utils/use-activate-theme.js +38 -0
  359. package/build/components/global-styles/context-menu.js +0 -126
  360. package/build/components/global-styles/context-menu.js.map +0 -1
  361. package/build/components/global-styles/custom-css.js +0 -113
  362. package/build/components/global-styles/custom-css.js.map +0 -1
  363. package/build/components/global-styles/effects-panel.js +0 -53
  364. package/build/components/global-styles/effects-panel.js.map +0 -1
  365. package/build/components/global-styles/filters-panel.js +0 -50
  366. package/build/components/global-styles/filters-panel.js.map +0 -1
  367. package/build/components/global-styles/screen-border.js +0 -61
  368. package/build/components/global-styles/screen-border.js.map +0 -1
  369. package/build/components/global-styles/screen-effects.js +0 -61
  370. package/build/components/global-styles/screen-effects.js.map +0 -1
  371. package/build/components/global-styles/screen-filters.js +0 -46
  372. package/build/components/global-styles/screen-filters.js.map +0 -1
  373. package/build/components/global-styles/screen-variations.js +0 -71
  374. package/build/components/global-styles/screen-variations.js.map +0 -1
  375. package/build/components/routes/index.js +0 -60
  376. package/build/components/routes/index.js.map +0 -1
  377. package/build/components/sidebar-edit-mode/template-card/last-revision.js.map +0 -1
  378. package/build/hooks/commands/index.js +0 -19
  379. package/build/hooks/commands/index.js.map +0 -1
  380. package/build/hooks/commands/use-navigation-commands.js +0 -126
  381. package/build/hooks/commands/use-navigation-commands.js.map +0 -1
  382. package/build/hooks/commands/use-wp-admin-commands.js +0 -97
  383. package/build/hooks/commands/use-wp-admin-commands.js.map +0 -1
  384. package/build/utils/history.js +0 -41
  385. package/build/utils/history.js.map +0 -1
  386. package/build-module/components/global-styles/context-menu.js +0 -107
  387. package/build-module/components/global-styles/context-menu.js.map +0 -1
  388. package/build-module/components/global-styles/custom-css.js +0 -98
  389. package/build-module/components/global-styles/custom-css.js.map +0 -1
  390. package/build-module/components/global-styles/effects-panel.js +0 -43
  391. package/build-module/components/global-styles/effects-panel.js.map +0 -1
  392. package/build-module/components/global-styles/filters-panel.js +0 -40
  393. package/build-module/components/global-styles/filters-panel.js.map +0 -1
  394. package/build-module/components/global-styles/screen-border.js +0 -44
  395. package/build-module/components/global-styles/screen-border.js.map +0 -1
  396. package/build-module/components/global-styles/screen-effects.js +0 -44
  397. package/build-module/components/global-styles/screen-effects.js.map +0 -1
  398. package/build-module/components/global-styles/screen-filters.js +0 -33
  399. package/build-module/components/global-styles/screen-filters.js.map +0 -1
  400. package/build-module/components/global-styles/screen-variations.js +0 -54
  401. package/build-module/components/global-styles/screen-variations.js.map +0 -1
  402. package/build-module/components/routes/index.js +0 -47
  403. package/build-module/components/routes/index.js.map +0 -1
  404. package/build-module/components/sidebar-edit-mode/template-card/last-revision.js.map +0 -1
  405. package/build-module/hooks/commands/index.js +0 -10
  406. package/build-module/hooks/commands/index.js.map +0 -1
  407. package/build-module/hooks/commands/use-navigation-commands.js +0 -109
  408. package/build-module/hooks/commands/use-navigation-commands.js.map +0 -1
  409. package/build-module/hooks/commands/use-wp-admin-commands.js +0 -81
  410. package/build-module/hooks/commands/use-wp-admin-commands.js.map +0 -1
  411. package/build-module/utils/history.js +0 -31
  412. package/build-module/utils/history.js.map +0 -1
  413. package/src/components/global-styles/context-menu.js +0 -175
  414. package/src/components/global-styles/custom-css.js +0 -131
  415. package/src/components/global-styles/effects-panel.js +0 -40
  416. package/src/components/global-styles/filters-panel.js +0 -39
  417. package/src/components/global-styles/screen-border.js +0 -35
  418. package/src/components/global-styles/screen-effects.js +0 -35
  419. package/src/components/global-styles/screen-filters.js +0 -27
  420. package/src/components/global-styles/screen-variations.js +0 -46
  421. package/src/components/routes/index.js +0 -53
  422. package/src/hooks/commands/index.js +0 -10
  423. package/src/hooks/commands/use-navigation-commands.js +0 -112
  424. package/src/hooks/commands/use-wp-admin-commands.js +0 -79
  425. package/src/utils/history.js +0 -39
  426. /package/src/components/sidebar-edit-mode/{template-card/last-revision.js → template-revisions/index.js} +0 -0
@@ -0,0 +1,66 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __experimentalItemGroup as ItemGroup } from '@wordpress/components';
5
+ import { typography, color, layout } from '@wordpress/icons';
6
+ import { __ } from '@wordpress/i18n';
7
+ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ import { NavigationButtonAsItem } from './navigation-button';
13
+ import { unlock } from '../../private-apis';
14
+
15
+ const {
16
+ useHasDimensionsPanel,
17
+ useHasTypographyPanel,
18
+ useHasColorPanel,
19
+ useGlobalSetting,
20
+ useSettingsForBlockElement,
21
+ } = unlock( blockEditorPrivateApis );
22
+
23
+ function RootMenu() {
24
+ const [ rawSettings ] = useGlobalSetting( '' );
25
+ const settings = useSettingsForBlockElement( rawSettings );
26
+ const hasTypographyPanel = useHasTypographyPanel( settings );
27
+ const hasColorPanel = useHasColorPanel( settings );
28
+ const hasDimensionsPanel = useHasDimensionsPanel( settings );
29
+ const hasLayoutPanel = hasDimensionsPanel;
30
+
31
+ return (
32
+ <>
33
+ <ItemGroup>
34
+ { hasTypographyPanel && (
35
+ <NavigationButtonAsItem
36
+ icon={ typography }
37
+ path="/typography"
38
+ aria-label={ __( 'Typography styles' ) }
39
+ >
40
+ { __( 'Typography' ) }
41
+ </NavigationButtonAsItem>
42
+ ) }
43
+ { hasColorPanel && (
44
+ <NavigationButtonAsItem
45
+ icon={ color }
46
+ path="/colors"
47
+ aria-label={ __( 'Colors styles' ) }
48
+ >
49
+ { __( 'Colors' ) }
50
+ </NavigationButtonAsItem>
51
+ ) }
52
+ { hasLayoutPanel && (
53
+ <NavigationButtonAsItem
54
+ icon={ layout }
55
+ path="/layout"
56
+ aria-label={ __( 'Layout styles' ) }
57
+ >
58
+ { __( 'Layout' ) }
59
+ </NavigationButtonAsItem>
60
+ ) }
61
+ </ItemGroup>
62
+ </>
63
+ );
64
+ }
65
+
66
+ export default RootMenu;
@@ -20,7 +20,7 @@ import { speak } from '@wordpress/a11y';
20
20
  /**
21
21
  * Internal dependencies
22
22
  */
23
- import { useHasVariationsPanel } from './variations-panel';
23
+ import { useBlockVariations } from './variations-panel';
24
24
  import ScreenHeader from './header';
25
25
  import { NavigationButtonAsItem } from './navigation-button';
26
26
  import { unlock } from '../../private-apis';
@@ -65,7 +65,7 @@ export function useBlockHasGlobalStyles( blockName ) {
65
65
  const hasBorderPanel = useHasBorderPanel( settings );
66
66
  const hasDimensionsPanel = useHasDimensionsPanel( settings );
67
67
  const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
68
- const hasVariationsPanel = useHasVariationsPanel( blockName );
68
+ const hasVariationsPanel = !! useBlockVariations( blockName )?.length;
69
69
  const hasGlobalStyles =
70
70
  hasTypographyPanel ||
71
71
  hasColorPanel ||
@@ -2,25 +2,202 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { getBlockType } from '@wordpress/blocks';
5
+ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
6
+ import { useMemo } from '@wordpress/element';
7
+ import { useSelect } from '@wordpress/data';
8
+ import { store as coreStore } from '@wordpress/core-data';
9
+ import {
10
+ PanelBody,
11
+ __experimentalVStack as VStack,
12
+ } from '@wordpress/components';
13
+ import { __, sprintf } from '@wordpress/i18n';
5
14
 
6
15
  /**
7
16
  * Internal dependencies
8
17
  */
9
- import ContextMenu from './context-menu';
10
18
  import ScreenHeader from './header';
11
19
  import BlockPreviewPanel from './block-preview-panel';
20
+ import { unlock } from '../../private-apis';
21
+ import Subtitle from './subtitle';
22
+ import { useBlockVariations, VariationsPanel } from './variations-panel';
12
23
 
13
- function ScreenBlock( { name } ) {
24
+ const {
25
+ useHasDimensionsPanel,
26
+ useHasTypographyPanel,
27
+ useHasBorderPanel,
28
+ useGlobalSetting,
29
+ useSettingsForBlockElement,
30
+ useHasColorPanel,
31
+ useHasEffectsPanel,
32
+ useHasFiltersPanel,
33
+ useGlobalStyle,
34
+ BorderPanel: StylesBorderPanel,
35
+ ColorPanel: StylesColorPanel,
36
+ TypographyPanel: StylesTypographyPanel,
37
+ DimensionsPanel: StylesDimensionsPanel,
38
+ EffectsPanel: StylesEffectsPanel,
39
+ FiltersPanel: StylesFiltersPanel,
40
+ AdvancedPanel: StylesAdvancedPanel,
41
+ } = unlock( blockEditorPrivateApis );
42
+
43
+ function ScreenBlock( { name, variation } ) {
44
+ let prefixParts = [];
45
+ if ( variation ) {
46
+ prefixParts = [ 'variations', variation ].concat( prefixParts );
47
+ }
48
+ const prefix = prefixParts.join( '.' );
49
+
50
+ const [ style ] = useGlobalStyle( prefix, name, 'user', {
51
+ shouldDecodeEncode: false,
52
+ } );
53
+ const [ inheritedStyle, setStyle ] = useGlobalStyle( prefix, name, 'all', {
54
+ shouldDecodeEncode: false,
55
+ } );
56
+ const [ rawSettings, setSettings ] = useGlobalSetting( '', name );
57
+ const settings = useSettingsForBlockElement( rawSettings, name );
14
58
  const blockType = getBlockType( name );
59
+ const blockVariations = useBlockVariations( name );
60
+ const hasTypographyPanel = useHasTypographyPanel( settings );
61
+ const hasColorPanel = useHasColorPanel( settings );
62
+ const hasBorderPanel = useHasBorderPanel( settings );
63
+ const hasDimensionsPanel = useHasDimensionsPanel( settings );
64
+ const hasEffectsPanel = useHasEffectsPanel( settings );
65
+ const hasFiltersPanel = useHasFiltersPanel( settings );
66
+ const hasVariationsPanel = !! blockVariations?.length && ! variation;
67
+ const { canEditCSS } = useSelect( ( select ) => {
68
+ const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =
69
+ select( coreStore );
70
+
71
+ const globalStylesId = __experimentalGetCurrentGlobalStylesId();
72
+ const globalStyles = globalStylesId
73
+ ? getEntityRecord( 'root', 'globalStyles', globalStylesId )
74
+ : undefined;
75
+
76
+ return {
77
+ canEditCSS:
78
+ !! globalStyles?._links?.[ 'wp:action-edit-css' ] ?? false,
79
+ };
80
+ }, [] );
81
+ const currentBlockStyle = variation
82
+ ? blockVariations.find( ( s ) => s.name === variation )
83
+ : null;
84
+
85
+ // These intermediary objects are needed because the "layout" property is stored
86
+ // in settings rather than styles.
87
+ const inheritedStyleWithLayout = useMemo( () => {
88
+ return {
89
+ ...inheritedStyle,
90
+ layout: settings.layout,
91
+ };
92
+ }, [ inheritedStyle, settings.layout ] );
93
+ const styleWithLayout = useMemo( () => {
94
+ return {
95
+ ...style,
96
+ layout: settings.layout,
97
+ };
98
+ }, [ style, settings.layout ] );
99
+ const onChangeDimensions = ( newStyle ) => {
100
+ const updatedStyle = { ...newStyle };
101
+ delete updatedStyle.layout;
102
+ setStyle( updatedStyle );
103
+
104
+ if ( newStyle.layout !== settings.layout ) {
105
+ setSettings( {
106
+ ...rawSettings,
107
+ layout: newStyle.layout,
108
+ } );
109
+ }
110
+ };
15
111
 
16
112
  return (
17
113
  <>
18
- <ScreenHeader title={ blockType.title } />
19
- <BlockPreviewPanel name={ name } />
20
- <ContextMenu
21
- parentMenu={ '/blocks/' + encodeURIComponent( name ) }
22
- name={ name }
114
+ <ScreenHeader
115
+ title={ variation ? currentBlockStyle.label : blockType.title }
23
116
  />
117
+ <BlockPreviewPanel name={ name } variation={ variation } />
118
+ { hasVariationsPanel && (
119
+ <div className="edit-site-global-styles-screen-variations">
120
+ <VStack spacing={ 3 }>
121
+ <Subtitle>{ __( 'Style Variations' ) }</Subtitle>
122
+ <VariationsPanel name={ name } />
123
+ </VStack>
124
+ </div>
125
+ ) }
126
+ { hasColorPanel && (
127
+ <StylesColorPanel
128
+ inheritedValue={ inheritedStyle }
129
+ value={ style }
130
+ onChange={ setStyle }
131
+ settings={ settings }
132
+ />
133
+ ) }
134
+ { hasTypographyPanel && (
135
+ <StylesTypographyPanel
136
+ inheritedValue={ inheritedStyle }
137
+ value={ style }
138
+ onChange={ setStyle }
139
+ settings={ settings }
140
+ />
141
+ ) }
142
+ { hasDimensionsPanel && (
143
+ <StylesDimensionsPanel
144
+ inheritedValue={ inheritedStyleWithLayout }
145
+ value={ styleWithLayout }
146
+ onChange={ onChangeDimensions }
147
+ settings={ settings }
148
+ includeLayoutControls
149
+ />
150
+ ) }
151
+ { hasBorderPanel && (
152
+ <StylesBorderPanel
153
+ inheritedValue={ inheritedStyle }
154
+ value={ style }
155
+ onChange={ setStyle }
156
+ settings={ settings }
157
+ />
158
+ ) }
159
+ { hasEffectsPanel && (
160
+ <StylesEffectsPanel
161
+ inheritedValue={ inheritedStyleWithLayout }
162
+ value={ styleWithLayout }
163
+ onChange={ onChangeDimensions }
164
+ settings={ settings }
165
+ includeLayoutControls
166
+ />
167
+ ) }
168
+ { hasFiltersPanel && (
169
+ <StylesFiltersPanel
170
+ inheritedValue={ inheritedStyleWithLayout }
171
+ value={ styleWithLayout }
172
+ onChange={ onChangeDimensions }
173
+ settings={ {
174
+ ...settings,
175
+ color: {
176
+ ...settings.color,
177
+ customDuotone: false, //TO FIX: Custom duotone only works on the block level right now
178
+ },
179
+ } }
180
+ includeLayoutControls
181
+ />
182
+ ) }
183
+ { canEditCSS && (
184
+ <PanelBody title={ __( 'Advanced' ) } initialOpen={ false }>
185
+ <p>
186
+ { sprintf(
187
+ // translators: %s: is the name of a block e.g., 'Image' or 'Table'.
188
+ __(
189
+ 'Add your own CSS to customize the appearance of the %s block.'
190
+ ),
191
+ blockType?.title
192
+ ) }
193
+ </p>
194
+ <StylesAdvancedPanel
195
+ value={ style }
196
+ onChange={ setStyle }
197
+ inheritedValue={ inheritedStyle }
198
+ />
199
+ </PanelBody>
200
+ ) }
24
201
  </>
25
202
  );
26
203
  }
@@ -11,7 +11,6 @@ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
11
11
  import ScreenHeader from './header';
12
12
  import Palette from './palette';
13
13
  import BlockPreviewPanel from './block-preview-panel';
14
- import { getVariationClassName } from './utils';
15
14
  import { unlock } from '../../private-apis';
16
15
 
17
16
  const {
@@ -21,21 +20,15 @@ const {
21
20
  ColorPanel: StylesColorPanel,
22
21
  } = unlock( blockEditorPrivateApis );
23
22
 
24
- function ScreenColors( { name, variation = '' } ) {
25
- const variationClassName = getVariationClassName( variation );
26
-
27
- let prefixParts = [];
28
- if ( variation ) {
29
- prefixParts = [ 'variations', variation ].concat( prefixParts );
30
- }
31
- const prefix = prefixParts.join( '.' );
32
-
33
- const [ style ] = useGlobalStyle( prefix, name, 'user', false );
34
- const [ inheritedStyle, setStyle ] = useGlobalStyle( prefix, name, 'all', {
23
+ function ScreenColors() {
24
+ const [ style ] = useGlobalStyle( '', undefined, 'user', {
25
+ shouldDecodeEncode: false,
26
+ } );
27
+ const [ inheritedStyle, setStyle ] = useGlobalStyle( '', undefined, 'all', {
35
28
  shouldDecodeEncode: false,
36
29
  } );
37
- const [ rawSettings ] = useGlobalSetting( '', name );
38
- const settings = useSettingsForBlockElement( rawSettings, name );
30
+ const [ rawSettings ] = useGlobalSetting( '' );
31
+ const settings = useSettingsForBlockElement( rawSettings );
39
32
 
40
33
  return (
41
34
  <>
@@ -46,11 +39,11 @@ function ScreenColors( { name, variation = '' } ) {
46
39
  ) }
47
40
  />
48
41
 
49
- <BlockPreviewPanel name={ name } variation={ variationClassName } />
42
+ <BlockPreviewPanel />
50
43
 
51
44
  <div className="edit-site-global-styles-screen-colors">
52
45
  <VStack spacing={ 10 }>
53
- <Palette name={ name } />
46
+ <Palette />
54
47
 
55
48
  <StylesColorPanel
56
49
  inheritedValue={ inheritedStyle }
@@ -1,34 +1,30 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { sprintf, __ } from '@wordpress/i18n';
4
+ import { __ } from '@wordpress/i18n';
5
5
  import { ExternalLink } from '@wordpress/components';
6
- import { getBlockType } from '@wordpress/blocks';
6
+ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
7
7
 
8
8
  /**
9
9
  * Internal dependencies
10
10
  */
11
+ import { unlock } from '../../private-apis';
11
12
  import ScreenHeader from './header';
12
- import CustomCSSControl from './custom-css';
13
13
 
14
- function ScreenCSS( { name } ) {
15
- // If name is defined, we are customizing CSS at the block level.
16
- // Display the block title in the description.
17
- const blockType = getBlockType( name );
18
- const title = blockType?.title;
14
+ const { useGlobalStyle, AdvancedPanel: StylesAdvancedPanel } = unlock(
15
+ blockEditorPrivateApis
16
+ );
19
17
 
20
- const description =
21
- title !== undefined
22
- ? sprintf(
23
- // translators: %s: is the name of a block e.g., 'Image' or 'Table'.
24
- __(
25
- 'Add your own CSS to customize the appearance of the %s block.'
26
- ),
27
- title
28
- )
29
- : __(
30
- 'Add your own CSS to customize the appearance and layout of your site.'
31
- );
18
+ function ScreenCSS() {
19
+ const description = __(
20
+ 'Add your own CSS to customize the appearance and layout of your site.'
21
+ );
22
+ const [ style ] = useGlobalStyle( '', undefined, 'user', {
23
+ shouldDecodeEncode: false,
24
+ } );
25
+ const [ inheritedStyle, setStyle ] = useGlobalStyle( '', undefined, 'all', {
26
+ shouldDecodeEncode: false,
27
+ } );
32
28
 
33
29
  return (
34
30
  <>
@@ -47,7 +43,11 @@ function ScreenCSS( { name } ) {
47
43
  }
48
44
  />
49
45
  <div className="edit-site-global-styles-screen-css">
50
- <CustomCSSControl blockName={ name } />
46
+ <StylesAdvancedPanel
47
+ value={ style }
48
+ onChange={ setStyle }
49
+ inheritedValue={ inheritedStyle }
50
+ />
51
51
  </div>
52
52
  </>
53
53
  );
@@ -10,24 +10,20 @@ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
10
10
  import DimensionsPanel from './dimensions-panel';
11
11
  import ScreenHeader from './header';
12
12
  import BlockPreviewPanel from './block-preview-panel';
13
- import { getVariationClassName } from './utils';
14
13
  import { unlock } from '../../private-apis';
15
14
 
16
15
  const { useHasDimensionsPanel, useGlobalSetting, useSettingsForBlockElement } =
17
16
  unlock( blockEditorPrivateApis );
18
17
 
19
- function ScreenLayout( { name, variation = '' } ) {
20
- const [ rawSettings ] = useGlobalSetting( '', name );
21
- const settings = useSettingsForBlockElement( rawSettings, name );
18
+ function ScreenLayout() {
19
+ const [ rawSettings ] = useGlobalSetting( '' );
20
+ const settings = useSettingsForBlockElement( rawSettings );
22
21
  const hasDimensionsPanel = useHasDimensionsPanel( settings );
23
- const variationClassName = getVariationClassName( variation );
24
22
  return (
25
23
  <>
26
24
  <ScreenHeader title={ __( 'Layout' ) } />
27
- <BlockPreviewPanel name={ name } variation={ variationClassName } />
28
- { hasDimensionsPanel && (
29
- <DimensionsPanel name={ name } variation={ variation } />
30
- ) }
25
+ <BlockPreviewPanel />
26
+ { hasDimensionsPanel && <DimensionsPanel /> }
31
27
  </>
32
28
  );
33
29
  }
@@ -0,0 +1,177 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import {
6
+ Button,
7
+ __experimentalUseNavigator as useNavigator,
8
+ __experimentalConfirmDialog as ConfirmDialog,
9
+ Spinner,
10
+ } from '@wordpress/components';
11
+ import { useSelect, useDispatch } from '@wordpress/data';
12
+ import { useContext, useState, useEffect } from '@wordpress/element';
13
+ import {
14
+ privateApis as blockEditorPrivateApis,
15
+ store as blockEditorStore,
16
+ } from '@wordpress/block-editor';
17
+
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+ import ScreenHeader from '../header';
22
+ import { unlock } from '../../../private-apis';
23
+ import Revisions from '../../revisions';
24
+ import SidebarFixedBottom from '../../sidebar-edit-mode/sidebar-fixed-bottom';
25
+ import { store as editSiteStore } from '../../../store';
26
+ import useGlobalStylesRevisions from './use-global-styles-revisions';
27
+ import RevisionsButtons from './revisions-buttons';
28
+
29
+ const { GlobalStylesContext, areGlobalStyleConfigsEqual } = unlock(
30
+ blockEditorPrivateApis
31
+ );
32
+
33
+ function ScreenRevisions() {
34
+ const { goBack } = useNavigator();
35
+ const { user: userConfig, setUserConfig } =
36
+ useContext( GlobalStylesContext );
37
+ const { blocks, editorCanvasContainerView } = useSelect( ( select ) => {
38
+ return {
39
+ editorCanvasContainerView: unlock(
40
+ select( editSiteStore )
41
+ ).getEditorCanvasContainerView(),
42
+ blocks: select( blockEditorStore ).getBlocks(),
43
+ };
44
+ }, [] );
45
+
46
+ const { revisions, isLoading, hasUnsavedChanges } =
47
+ useGlobalStylesRevisions();
48
+ const [ globalStylesRevision, setGlobalStylesRevision ] =
49
+ useState( userConfig );
50
+
51
+ const [ currentRevisionId, setCurrentRevisionId ] = useState(
52
+ /*
53
+ * We need this for the first render,
54
+ * otherwise the unsaved changes haven't been merged into the revisions array yet.
55
+ */
56
+ hasUnsavedChanges ? 'unsaved' : revisions?.[ 0 ]?.id
57
+ );
58
+ const [
59
+ isLoadingRevisionWithUnsavedChanges,
60
+ setIsLoadingRevisionWithUnsavedChanges,
61
+ ] = useState( false );
62
+ const { setEditorCanvasContainerView } = unlock(
63
+ useDispatch( editSiteStore )
64
+ );
65
+
66
+ useEffect( () => {
67
+ if ( editorCanvasContainerView !== 'global-styles-revisions' ) {
68
+ goBack();
69
+ setEditorCanvasContainerView( editorCanvasContainerView );
70
+ }
71
+ }, [ editorCanvasContainerView ] );
72
+
73
+ const onCloseRevisions = () => {
74
+ goBack();
75
+ };
76
+
77
+ const restoreRevision = ( revision ) => {
78
+ setUserConfig( () => ( {
79
+ styles: revision?.styles,
80
+ settings: revision?.settings,
81
+ } ) );
82
+ setIsLoadingRevisionWithUnsavedChanges( false );
83
+ onCloseRevisions();
84
+ };
85
+
86
+ const selectRevision = ( revision ) => {
87
+ setGlobalStylesRevision( {
88
+ styles: revision?.styles,
89
+ settings: revision?.settings,
90
+ id: revision?.id,
91
+ } );
92
+ setCurrentRevisionId( revision?.id );
93
+ };
94
+
95
+ const isLoadButtonEnabled =
96
+ !! globalStylesRevision?.id &&
97
+ ! areGlobalStyleConfigsEqual( globalStylesRevision, userConfig );
98
+
99
+ return (
100
+ <>
101
+ <ScreenHeader
102
+ title={ __( 'Revisions' ) }
103
+ description={ __(
104
+ 'Revisions are added to the timeline when style changes are saved.'
105
+ ) }
106
+ />
107
+ { isLoading && (
108
+ <Spinner className="edit-site-global-styles-screen-revisions__loading" />
109
+ ) }
110
+ { ! isLoading && (
111
+ <Revisions
112
+ blocks={ blocks }
113
+ userConfig={ globalStylesRevision }
114
+ onClose={ onCloseRevisions }
115
+ />
116
+ ) }
117
+ <div className="edit-site-global-styles-screen-revisions">
118
+ <RevisionsButtons
119
+ onChange={ selectRevision }
120
+ currentRevisionId={ currentRevisionId }
121
+ userRevisions={ revisions }
122
+ />
123
+ { isLoadButtonEnabled && (
124
+ <SidebarFixedBottom>
125
+ <Button
126
+ variant="primary"
127
+ className="edit-site-global-styles-screen-revisions__button"
128
+ disabled={
129
+ ! globalStylesRevision?.id ||
130
+ globalStylesRevision?.id === 'unsaved'
131
+ }
132
+ onClick={ () => {
133
+ if ( hasUnsavedChanges ) {
134
+ setIsLoadingRevisionWithUnsavedChanges(
135
+ true
136
+ );
137
+ } else {
138
+ restoreRevision( globalStylesRevision );
139
+ }
140
+ } }
141
+ >
142
+ { __( 'Apply' ) }
143
+ </Button>
144
+ </SidebarFixedBottom>
145
+ ) }
146
+ </div>
147
+ { isLoadingRevisionWithUnsavedChanges && (
148
+ <ConfirmDialog
149
+ title={ __(
150
+ 'Loading this revision will discard all unsaved changes.'
151
+ ) }
152
+ isOpen={ isLoadingRevisionWithUnsavedChanges }
153
+ confirmButtonText={ __( ' Discard unsaved changes' ) }
154
+ onConfirm={ () => restoreRevision( globalStylesRevision ) }
155
+ onCancel={ () =>
156
+ setIsLoadingRevisionWithUnsavedChanges( false )
157
+ }
158
+ >
159
+ <>
160
+ <h2>
161
+ { __(
162
+ 'Loading this revision will discard all unsaved changes.'
163
+ ) }
164
+ </h2>
165
+ <p>
166
+ { __(
167
+ 'Do you want to replace your unsaved changes in the editor?'
168
+ ) }
169
+ </p>
170
+ </>
171
+ </ConfirmDialog>
172
+ ) }
173
+ </>
174
+ );
175
+ }
176
+
177
+ export default ScreenRevisions;