@wordpress/edit-site 5.31.0 → 5.32.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 (280) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-editor/editor-canvas.js +8 -1
  3. package/build/components/block-editor/editor-canvas.js.map +1 -1
  4. package/build/components/block-editor/site-editor-canvas.js +15 -4
  5. package/build/components/block-editor/site-editor-canvas.js.map +1 -1
  6. package/build/components/editor/index.js +12 -3
  7. package/build/components/editor/index.js.map +1 -1
  8. package/build/components/editor-canvas-container/index.js +1 -2
  9. package/build/components/editor-canvas-container/index.js.map +1 -1
  10. package/build/components/global-styles/background-panel.js +38 -0
  11. package/build/components/global-styles/background-panel.js.map +1 -0
  12. package/build/components/global-styles/font-families.js +1 -1
  13. package/build/components/global-styles/font-families.js.map +1 -1
  14. package/build/components/global-styles/font-library-modal/context.js +38 -9
  15. package/build/components/global-styles/font-library-modal/context.js.map +1 -1
  16. package/build/components/global-styles/font-library-modal/utils/index.js +20 -2
  17. package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  18. package/build/components/global-styles/palette.js +3 -1
  19. package/build/components/global-styles/palette.js.map +1 -1
  20. package/build/components/global-styles/preview-colors.js +2 -2
  21. package/build/components/global-styles/preview-colors.js.map +1 -1
  22. package/build/components/global-styles/root-menu.js +8 -2
  23. package/build/components/global-styles/root-menu.js.map +1 -1
  24. package/build/components/global-styles/screen-background.js +34 -0
  25. package/build/components/global-styles/screen-background.js.map +1 -0
  26. package/build/components/global-styles/screen-color-palette.js +2 -2
  27. package/build/components/global-styles/screen-color-palette.js.map +1 -1
  28. package/build/components/global-styles/screen-colors.js +6 -4
  29. package/build/components/global-styles/screen-colors.js.map +1 -1
  30. package/build/components/global-styles/screen-style-variations.js +3 -37
  31. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  32. package/build/components/global-styles/screen-typography.js +6 -6
  33. package/build/components/global-styles/screen-typography.js.map +1 -1
  34. package/build/components/global-styles/style-variations-container.js +5 -2
  35. package/build/components/global-styles/style-variations-container.js.map +1 -1
  36. package/build/components/global-styles/ui.js +4 -1
  37. package/build/components/global-styles/ui.js.map +1 -1
  38. package/build/components/global-styles/variations/variations-color.js +10 -3
  39. package/build/components/global-styles/variations/variations-color.js.map +1 -1
  40. package/build/components/global-styles/variations/variations-typography.js +9 -2
  41. package/build/components/global-styles/variations/variations-typography.js.map +1 -1
  42. package/build/components/keyboard-shortcut-help-modal/index.js +3 -0
  43. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  44. package/build/components/layout/animation.js +129 -0
  45. package/build/components/layout/animation.js.map +1 -0
  46. package/build/components/layout/index.js +9 -17
  47. package/build/components/layout/index.js.map +1 -1
  48. package/build/components/layout/router.js +21 -18
  49. package/build/components/layout/router.js.map +1 -1
  50. package/build/components/page-pages/index.js +19 -17
  51. package/build/components/page-pages/index.js.map +1 -1
  52. package/build/components/page-patterns/index.js +18 -28
  53. package/build/components/page-patterns/index.js.map +1 -1
  54. package/build/components/page-patterns/search-items.js +16 -58
  55. package/build/components/page-patterns/search-items.js.map +1 -1
  56. package/build/components/page-templates-template-parts/actions.js +54 -41
  57. package/build/components/page-templates-template-parts/actions.js.map +1 -1
  58. package/build/components/page-templates-template-parts/index.js +26 -59
  59. package/build/components/page-templates-template-parts/index.js.map +1 -1
  60. package/build/components/plugin-template-setting-panel/index.js +12 -1
  61. package/build/components/plugin-template-setting-panel/index.js.map +1 -1
  62. package/build/components/save-button/index.js +45 -16
  63. package/build/components/save-button/index.js.map +1 -1
  64. package/build/components/save-hub/index.js +8 -112
  65. package/build/components/save-hub/index.js.map +1 -1
  66. package/build/components/sidebar/index.js +1 -5
  67. package/build/components/sidebar/index.js.map +1 -1
  68. package/build/components/sidebar-dataviews/default-views.js +1 -1
  69. package/build/components/sidebar-dataviews/default-views.js.map +1 -1
  70. package/build/components/sidebar-dataviews/index.js +1 -1
  71. package/build/components/sidebar-dataviews/index.js.map +1 -1
  72. package/build/components/sidebar-edit-mode/index.js +1 -2
  73. package/build/components/sidebar-edit-mode/index.js.map +1 -1
  74. package/build/components/sidebar-edit-mode/page-panels/index.js +5 -15
  75. package/build/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
  76. package/build/components/sidebar-edit-mode/page-panels/page-content.js +7 -5
  77. package/build/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
  78. package/build/components/sidebar-edit-mode/template-panel/index.js +10 -16
  79. package/build/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
  80. package/build/components/sidebar-navigation-screen-details-footer/index.js +5 -1
  81. package/build/components/sidebar-navigation-screen-details-footer/index.js.map +1 -1
  82. package/build/components/sidebar-navigation-screen-global-styles/index.js +10 -5
  83. package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  84. package/build/components/sidebar-navigation-screen-patterns/index.js +1 -5
  85. package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  86. package/build/components/style-book/index.js +1 -1
  87. package/build/components/style-book/index.js.map +1 -1
  88. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +2 -2
  89. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  90. package/build/components/sync-state-with-url/use-sync-path-with-url.js +1 -1
  91. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  92. package/build/hooks/index.js +0 -1
  93. package/build/hooks/index.js.map +1 -1
  94. package/build/store/selectors.js +1 -9
  95. package/build/store/selectors.js.map +1 -1
  96. package/build-module/components/block-editor/editor-canvas.js +8 -1
  97. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  98. package/build-module/components/block-editor/site-editor-canvas.js +15 -4
  99. package/build-module/components/block-editor/site-editor-canvas.js.map +1 -1
  100. package/build-module/components/editor/index.js +13 -4
  101. package/build-module/components/editor/index.js.map +1 -1
  102. package/build-module/components/editor-canvas-container/index.js +1 -2
  103. package/build-module/components/editor-canvas-container/index.js.map +1 -1
  104. package/build-module/components/global-styles/background-panel.js +31 -0
  105. package/build-module/components/global-styles/background-panel.js.map +1 -0
  106. package/build-module/components/global-styles/font-families.js +1 -1
  107. package/build-module/components/global-styles/font-families.js.map +1 -1
  108. package/build-module/components/global-styles/font-library-modal/context.js +38 -9
  109. package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
  110. package/build-module/components/global-styles/font-library-modal/utils/index.js +20 -2
  111. package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  112. package/build-module/components/global-styles/palette.js +3 -1
  113. package/build-module/components/global-styles/palette.js.map +1 -1
  114. package/build-module/components/global-styles/preview-colors.js +2 -2
  115. package/build-module/components/global-styles/preview-colors.js.map +1 -1
  116. package/build-module/components/global-styles/root-menu.js +9 -3
  117. package/build-module/components/global-styles/root-menu.js.map +1 -1
  118. package/build-module/components/global-styles/screen-background.js +26 -0
  119. package/build-module/components/global-styles/screen-background.js.map +1 -0
  120. package/build-module/components/global-styles/screen-color-palette.js +2 -2
  121. package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
  122. package/build-module/components/global-styles/screen-colors.js +6 -4
  123. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  124. package/build-module/components/global-styles/screen-style-variations.js +4 -38
  125. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  126. package/build-module/components/global-styles/screen-typography.js +6 -6
  127. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  128. package/build-module/components/global-styles/style-variations-container.js +5 -2
  129. package/build-module/components/global-styles/style-variations-container.js.map +1 -1
  130. package/build-module/components/global-styles/ui.js +4 -1
  131. package/build-module/components/global-styles/ui.js.map +1 -1
  132. package/build-module/components/global-styles/variations/variations-color.js +10 -3
  133. package/build-module/components/global-styles/variations/variations-color.js.map +1 -1
  134. package/build-module/components/global-styles/variations/variations-typography.js +9 -2
  135. package/build-module/components/global-styles/variations/variations-typography.js.map +1 -1
  136. package/build-module/components/keyboard-shortcut-help-modal/index.js +3 -0
  137. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  138. package/build-module/components/layout/animation.js +122 -0
  139. package/build-module/components/layout/animation.js.map +1 -0
  140. package/build-module/components/layout/index.js +9 -17
  141. package/build-module/components/layout/index.js.map +1 -1
  142. package/build-module/components/layout/router.js +21 -18
  143. package/build-module/components/layout/router.js.map +1 -1
  144. package/build-module/components/page-pages/index.js +19 -17
  145. package/build-module/components/page-pages/index.js.map +1 -1
  146. package/build-module/components/page-patterns/index.js +20 -30
  147. package/build-module/components/page-patterns/index.js.map +1 -1
  148. package/build-module/components/page-patterns/search-items.js +14 -55
  149. package/build-module/components/page-patterns/search-items.js.map +1 -1
  150. package/build-module/components/page-templates-template-parts/actions.js +54 -40
  151. package/build-module/components/page-templates-template-parts/actions.js.map +1 -1
  152. package/build-module/components/page-templates-template-parts/index.js +29 -62
  153. package/build-module/components/page-templates-template-parts/index.js.map +1 -1
  154. package/build-module/components/plugin-template-setting-panel/index.js +12 -1
  155. package/build-module/components/plugin-template-setting-panel/index.js.map +1 -1
  156. package/build-module/components/save-button/index.js +46 -17
  157. package/build-module/components/save-button/index.js.map +1 -1
  158. package/build-module/components/save-hub/index.js +10 -114
  159. package/build-module/components/save-hub/index.js.map +1 -1
  160. package/build-module/components/sidebar/index.js +1 -5
  161. package/build-module/components/sidebar/index.js.map +1 -1
  162. package/build-module/components/sidebar-dataviews/default-views.js +1 -1
  163. package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
  164. package/build-module/components/sidebar-dataviews/index.js +1 -1
  165. package/build-module/components/sidebar-dataviews/index.js.map +1 -1
  166. package/build-module/components/sidebar-edit-mode/index.js +1 -2
  167. package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
  168. package/build-module/components/sidebar-edit-mode/page-panels/index.js +8 -18
  169. package/build-module/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
  170. package/build-module/components/sidebar-edit-mode/page-panels/page-content.js +7 -5
  171. package/build-module/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
  172. package/build-module/components/sidebar-edit-mode/template-panel/index.js +11 -17
  173. package/build-module/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
  174. package/build-module/components/sidebar-navigation-screen-details-footer/index.js +5 -1
  175. package/build-module/components/sidebar-navigation-screen-details-footer/index.js.map +1 -1
  176. package/build-module/components/sidebar-navigation-screen-global-styles/index.js +10 -5
  177. package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  178. package/build-module/components/sidebar-navigation-screen-patterns/index.js +1 -5
  179. package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  180. package/build-module/components/style-book/index.js +1 -1
  181. package/build-module/components/style-book/index.js.map +1 -1
  182. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +2 -2
  183. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  184. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +1 -1
  185. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  186. package/build-module/hooks/index.js +0 -1
  187. package/build-module/hooks/index.js.map +1 -1
  188. package/build-module/store/selectors.js +1 -9
  189. package/build-module/store/selectors.js.map +1 -1
  190. package/build-style/style-rtl.css +116 -104
  191. package/build-style/style.css +116 -104
  192. package/package.json +44 -44
  193. package/src/components/block-editor/editor-canvas.js +14 -2
  194. package/src/components/block-editor/site-editor-canvas.js +10 -7
  195. package/src/components/editor/index.js +11 -4
  196. package/src/components/editor-canvas-container/index.js +0 -1
  197. package/src/components/global-styles/background-panel.js +34 -0
  198. package/src/components/global-styles/font-families.js +1 -1
  199. package/src/components/global-styles/font-library-modal/context.js +43 -14
  200. package/src/components/global-styles/font-library-modal/style.scss +1 -1
  201. package/src/components/global-styles/font-library-modal/utils/index.js +17 -4
  202. package/src/components/global-styles/palette.js +3 -1
  203. package/src/components/global-styles/preview-colors.js +2 -2
  204. package/src/components/global-styles/root-menu.js +12 -1
  205. package/src/components/global-styles/screen-background.js +29 -0
  206. package/src/components/global-styles/screen-color-palette.js +2 -2
  207. package/src/components/global-styles/screen-colors.js +4 -4
  208. package/src/components/global-styles/screen-style-variations.js +4 -36
  209. package/src/components/global-styles/screen-typography.js +6 -9
  210. package/src/components/global-styles/style-variations-container.js +2 -1
  211. package/src/components/global-styles/style.scss +14 -12
  212. package/src/components/global-styles/ui.js +5 -0
  213. package/src/components/global-styles/variations/style.scss +32 -17
  214. package/src/components/global-styles/variations/variations-color.js +4 -2
  215. package/src/components/global-styles/variations/variations-typography.js +4 -1
  216. package/src/components/header-edit-mode/style.scss +28 -17
  217. package/src/components/keyboard-shortcut-help-modal/index.js +4 -0
  218. package/src/components/layout/animation.js +122 -0
  219. package/src/components/layout/index.js +12 -27
  220. package/src/components/layout/router.js +25 -19
  221. package/src/components/layout/style.scss +2 -0
  222. package/src/components/page-pages/index.js +27 -43
  223. package/src/components/page-patterns/index.js +20 -28
  224. package/src/components/page-patterns/search-items.js +13 -58
  225. package/src/components/page-templates-template-parts/actions.js +106 -91
  226. package/src/components/page-templates-template-parts/index.js +34 -78
  227. package/src/components/page-templates-template-parts/style.scss +5 -0
  228. package/src/components/plugin-template-setting-panel/index.js +14 -1
  229. package/src/components/save-button/index.js +55 -26
  230. package/src/components/save-hub/index.js +20 -164
  231. package/src/components/sidebar/index.js +0 -5
  232. package/src/components/sidebar-dataviews/default-views.js +1 -1
  233. package/src/components/sidebar-dataviews/index.js +1 -1
  234. package/src/components/sidebar-edit-mode/index.js +0 -2
  235. package/src/components/sidebar-edit-mode/page-panels/index.js +29 -60
  236. package/src/components/sidebar-edit-mode/page-panels/page-content.js +10 -10
  237. package/src/components/sidebar-edit-mode/template-panel/index.js +23 -33
  238. package/src/components/sidebar-edit-mode/template-panel/style.scss +1 -29
  239. package/src/components/sidebar-navigation-screen/style.scss +12 -9
  240. package/src/components/sidebar-navigation-screen-details-footer/index.js +6 -2
  241. package/src/components/sidebar-navigation-screen-global-styles/index.js +7 -13
  242. package/src/components/sidebar-navigation-screen-patterns/index.js +0 -7
  243. package/src/components/style-book/index.js +1 -3
  244. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +2 -2
  245. package/src/components/sync-state-with-url/use-sync-path-with-url.js +1 -1
  246. package/src/hooks/index.js +0 -1
  247. package/src/store/selectors.js +3 -15
  248. package/src/style.scss +0 -1
  249. package/build/components/actions/index.js +0 -319
  250. package/build/components/actions/index.js.map +0 -1
  251. package/build/components/sidebar-edit-mode/sidebar-card/index.js +0 -48
  252. package/build/components/sidebar-edit-mode/sidebar-card/index.js.map +0 -1
  253. package/build/components/sidebar-edit-mode/template-panel/template-areas.js +0 -70
  254. package/build/components/sidebar-edit-mode/template-panel/template-areas.js.map +0 -1
  255. package/build/components/sidebar-navigation-screen-pages/index.js +0 -175
  256. package/build/components/sidebar-navigation-screen-pages/index.js.map +0 -1
  257. package/build/hooks/template-part-edit.js +0 -82
  258. package/build/hooks/template-part-edit.js.map +0 -1
  259. package/build/store/utils.js +0 -71
  260. package/build/store/utils.js.map +0 -1
  261. package/build-module/components/actions/index.js +0 -308
  262. package/build-module/components/actions/index.js.map +0 -1
  263. package/build-module/components/sidebar-edit-mode/sidebar-card/index.js +0 -40
  264. package/build-module/components/sidebar-edit-mode/sidebar-card/index.js.map +0 -1
  265. package/build-module/components/sidebar-edit-mode/template-panel/template-areas.js +0 -63
  266. package/build-module/components/sidebar-edit-mode/template-panel/template-areas.js.map +0 -1
  267. package/build-module/components/sidebar-navigation-screen-pages/index.js +0 -167
  268. package/build-module/components/sidebar-navigation-screen-pages/index.js.map +0 -1
  269. package/build-module/hooks/template-part-edit.js +0 -75
  270. package/build-module/hooks/template-part-edit.js.map +0 -1
  271. package/build-module/store/utils.js +0 -64
  272. package/build-module/store/utils.js.map +0 -1
  273. package/src/components/actions/index.js +0 -409
  274. package/src/components/sidebar-edit-mode/sidebar-card/index.js +0 -53
  275. package/src/components/sidebar-edit-mode/sidebar-card/style.scss +0 -36
  276. package/src/components/sidebar-edit-mode/template-panel/template-areas.js +0 -86
  277. package/src/components/sidebar-navigation-screen-pages/index.js +0 -238
  278. package/src/hooks/template-part-edit.js +0 -89
  279. package/src/store/test/utils.js +0 -191
  280. package/src/store/utils.js +0 -69
@@ -1,5 +1,3 @@
1
- $header-toolbar-min-width: 335px;
2
-
3
1
  .edit-site-header-edit-mode {
4
2
  height: $header-height;
5
3
  align-items: center;
@@ -16,46 +14,62 @@ $header-toolbar-min-width: 335px;
16
14
  display: flex;
17
15
  border: none;
18
16
  align-items: center;
17
+ flex-grow: 1;
19
18
  flex-shrink: 2;
20
- // We need this to be overflow hidden so the block toolbar can
21
- // overflow scroll. If the overflow is visible, flexbox allows
22
- // the toolbar to grow outside of the allowed container space.
23
- overflow: hidden;
24
19
  // Take up the full height of the header so the border focus
25
20
  // is visible on toolbar buttons.
26
21
  height: 100%;
27
22
  // Allow focus ring to be fully visible on furthest right button.
28
23
  @include break-medium() {
24
+ // Account for the site hub, which is 60x60px.
25
+ flex-basis: calc(37.5% - 60px);
29
26
  padding-right: 2px;
27
+ // We need this to be overflow hidden so the block toolbar can
28
+ // overflow scroll. If the overflow is visible, flexbox allows
29
+ // the toolbar to grow outside of the allowed container space.
30
+ overflow: hidden;
30
31
  }
31
32
  }
32
33
 
33
34
  .edit-site-header-edit-mode__end {
34
35
  display: flex;
35
36
  justify-content: flex-end;
37
+ height: 100%;
38
+ flex-grow: 1;
39
+ flex-shrink: 1;
40
+
41
+ @include break-medium() {
42
+ flex-basis: 37.5%;
43
+ }
36
44
  }
37
45
 
38
46
  .edit-site-header-edit-mode__center {
39
- display: flex;
40
47
  align-items: center;
41
- height: 100%;
48
+ display: flex;
49
+ flex-basis: 100%;
42
50
  flex-grow: 1;
43
- margin: 0 $grid-unit-20;
51
+ flex-shrink: 2;
52
+ height: 100%;
44
53
  justify-content: center;
54
+
45
55
  // Flex items will, by default, refuse to shrink below a minimum
46
56
  // intrinsic width. In order to shrink this flexbox item, and
47
57
  // subsequently truncate child text, we set an explicit min-width.
48
58
  // See https://dev.w3.org/csswg/css-flexbox/#min-size-auto
49
59
  min-width: 0;
60
+
61
+ @include break-medium() {
62
+ flex-basis: 25%;
63
+ }
50
64
  }
51
65
 
52
66
  }
53
67
 
54
68
  .edit-site-header-edit-mode__toolbar {
55
- display: flex;
56
69
  align-items: center;
57
- padding-left: $grid-unit-20;
70
+ display: flex;
58
71
  gap: $grid-unit-10;
72
+ padding-left: $grid-unit-20;
59
73
 
60
74
  @include break-medium() {
61
75
  padding-left: $grid-unit-50 * 0.5;
@@ -87,12 +101,9 @@ $header-toolbar-min-width: 335px;
87
101
  display: inline-flex;
88
102
  align-items: center;
89
103
  flex-wrap: nowrap;
90
- padding-right: $grid-unit-05;
91
-
92
- @include break-small () {
93
- padding-right: $grid-unit-10;
94
- }
95
-
104
+ // Ensure actions do not press against .edit-site-header-edit-mode__center.
105
+ padding-left: $grid-unit-10;
106
+ padding-right: $grid-unit-10;
96
107
  gap: $grid-unit-10;
97
108
  }
98
109
 
@@ -142,6 +142,10 @@ export default function KeyboardShortcutHelpModal() {
142
142
  title={ __( 'Text formatting' ) }
143
143
  shortcuts={ textFormattingShortcuts }
144
144
  />
145
+ <ShortcutCategorySection
146
+ title={ __( 'List View shortcuts' ) }
147
+ categoryName="list-view"
148
+ />
145
149
  </Modal>
146
150
  );
147
151
  }
@@ -0,0 +1,122 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { Controller } from '@react-spring/web';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { useLayoutEffect, useMemo, useRef } from '@wordpress/element';
10
+
11
+ function getAbsolutePosition( element ) {
12
+ return {
13
+ top: element.offsetTop,
14
+ left: element.offsetLeft,
15
+ };
16
+ }
17
+
18
+ const ANIMATION_DURATION = 300;
19
+
20
+ /**
21
+ * Hook used to compute the styles required to move a div into a new position.
22
+ *
23
+ * The way this animation works is the following:
24
+ * - It first renders the element as if there was no animation.
25
+ * - It takes a snapshot of the position of the block to use it
26
+ * as a destination point for the animation.
27
+ * - It restores the element to the previous position using a CSS transform
28
+ * - It uses the "resetAnimation" flag to reset the animation
29
+ * from the beginning in order to animate to the new destination point.
30
+ *
31
+ * @param {Object} $1 Options
32
+ * @param {*} $1.triggerAnimationOnChange Variable used to trigger the animation if it changes.
33
+ */
34
+ function useMovingAnimation( { triggerAnimationOnChange } ) {
35
+ const ref = useRef();
36
+
37
+ // Whenever the trigger changes, we need to take a snapshot of the current
38
+ // position of the block to use it as a destination point for the animation.
39
+ const { previous, prevRect } = useMemo(
40
+ () => ( {
41
+ previous: ref.current && getAbsolutePosition( ref.current ),
42
+ prevRect: ref.current && ref.current.getBoundingClientRect(),
43
+ } ),
44
+ // eslint-disable-next-line react-hooks/exhaustive-deps
45
+ [ triggerAnimationOnChange ]
46
+ );
47
+
48
+ useLayoutEffect( () => {
49
+ if ( ! previous || ! ref.current ) {
50
+ return;
51
+ }
52
+
53
+ // We disable the animation if the user has a preference for reduced
54
+ // motion.
55
+ const disableAnimation = window.matchMedia(
56
+ '(prefers-reduced-motion: reduce)'
57
+ ).matches;
58
+
59
+ if ( disableAnimation ) {
60
+ return;
61
+ }
62
+
63
+ const controller = new Controller( {
64
+ x: 0,
65
+ y: 0,
66
+ width: prevRect.width,
67
+ height: prevRect.height,
68
+ config: { duration: ANIMATION_DURATION },
69
+ onChange( { value } ) {
70
+ if ( ! ref.current ) {
71
+ return;
72
+ }
73
+ let { x, y, width, height } = value;
74
+ x = Math.round( x );
75
+ y = Math.round( y );
76
+ width = Math.round( width );
77
+ height = Math.round( height );
78
+ const finishedMoving = x === 0 && y === 0;
79
+ ref.current.style.transformOrigin = 'center center';
80
+ ref.current.style.transform = finishedMoving
81
+ ? null // Set to `null` to explicitly remove the transform.
82
+ : `translate3d(${ x }px,${ y }px,0)`;
83
+ ref.current.style.width = finishedMoving
84
+ ? null
85
+ : `${ width }px`;
86
+ ref.current.style.height = finishedMoving
87
+ ? null
88
+ : `${ height }px`;
89
+ },
90
+ } );
91
+
92
+ ref.current.style.transform = undefined;
93
+ const destination = ref.current.getBoundingClientRect();
94
+
95
+ const x = Math.round( prevRect.left - destination.left );
96
+ const y = Math.round( prevRect.top - destination.top );
97
+ const width = destination.width;
98
+ const height = destination.height;
99
+
100
+ controller.start( {
101
+ x: 0,
102
+ y: 0,
103
+ width,
104
+ height,
105
+ from: { x, y, width: prevRect.width, height: prevRect.height },
106
+ } );
107
+
108
+ return () => {
109
+ controller.stop();
110
+ controller.set( {
111
+ x: 0,
112
+ y: 0,
113
+ width: prevRect.width,
114
+ height: prevRect.height,
115
+ } );
116
+ };
117
+ }, [ previous, prevRect ] );
118
+
119
+ return ref;
120
+ }
121
+
122
+ export default useMovingAnimation;
@@ -51,12 +51,13 @@ import { useCommonCommands } from '../../hooks/commands/use-common-commands';
51
51
  import { useEditModeCommands } from '../../hooks/commands/use-edit-mode-commands';
52
52
  import { useIsSiteEditorLoading } from './hooks';
53
53
  import useLayoutAreas from './router';
54
+ import useMovingAnimation from './animation';
54
55
 
55
56
  const { useCommands } = unlock( coreCommandsPrivateApis );
56
57
  const { useCommandContext } = unlock( commandsPrivateApis );
57
58
  const { useGlobalStyle } = unlock( blockEditorPrivateApis );
58
59
 
59
- const ANIMATION_DURATION = 0.5;
60
+ const ANIMATION_DURATION = 0.3;
60
61
 
61
62
  export default function Layout() {
62
63
  // This ensures the edited entity id and type are initialized properly.
@@ -114,7 +115,10 @@ export default function Layout() {
114
115
  const isEditorLoading = useIsSiteEditorLoading();
115
116
  const [ isResizableFrameOversized, setIsResizableFrameOversized ] =
116
117
  useState( false );
117
- const { areas, widths } = useLayoutAreas();
118
+ const { key: routeKey, areas, widths } = useLayoutAreas();
119
+ const animationRef = useMovingAnimation( {
120
+ triggerAnimationOnChange: canvasMode + '__' + routeKey,
121
+ } );
118
122
 
119
123
  // This determines which animation variant should apply to the header.
120
124
  // There is also a `isDistractionFreeHovering` state that gets priority
@@ -239,7 +243,9 @@ export default function Layout() {
239
243
  } }
240
244
  transition={ {
241
245
  type: 'tween',
242
- duration: disableMotion ? 0 : 0.2,
246
+ duration: disableMotion
247
+ ? 0
248
+ : ANIMATION_DURATION,
243
249
  ease: 'easeOut',
244
250
  } }
245
251
  >
@@ -315,22 +321,7 @@ export default function Layout() {
315
321
  <div className="edit-site-layout__canvas-container">
316
322
  { canvasResizer }
317
323
  { !! canvasSize.width && (
318
- <motion.div
319
- whileHover={
320
- canvasMode === 'view'
321
- ? {
322
- scale: 1.005,
323
- transition: {
324
- duration: disableMotion
325
- ? 0
326
- : 0.5,
327
- ease: 'easeOut',
328
- },
329
- }
330
- : {}
331
- }
332
- initial={ false }
333
- layout="position"
324
+ <div
334
325
  className={ classnames(
335
326
  'edit-site-layout__canvas',
336
327
  {
@@ -338,13 +329,7 @@ export default function Layout() {
338
329
  isResizableFrameOversized,
339
330
  }
340
331
  ) }
341
- transition={ {
342
- type: 'tween',
343
- duration: disableMotion
344
- ? 0
345
- : ANIMATION_DURATION,
346
- ease: 'easeOut',
347
- } }
332
+ ref={ animationRef }
348
333
  >
349
334
  <ErrorBoundary>
350
335
  <ResizableFrame
@@ -373,7 +358,7 @@ export default function Layout() {
373
358
  { areas.preview }
374
359
  </ResizableFrame>
375
360
  </ErrorBoundary>
376
- </motion.div>
361
+ </div>
377
362
  ) }
378
363
  </div>
379
364
  ) }
@@ -18,10 +18,11 @@ import {
18
18
  TEMPLATE_PART_POST_TYPE,
19
19
  } from '../../utils/constants';
20
20
 
21
- const { useLocation } = unlock( routerPrivateApis );
21
+ const { useLocation, useHistory } = unlock( routerPrivateApis );
22
22
 
23
23
  export default function useLayoutAreas() {
24
24
  const isSiteEditorLoading = useIsSiteEditorLoading();
25
+ const history = useHistory();
25
26
  const { params } = useLocation();
26
27
  const { postType, postId, path, layout, isCustom, canvas } = params ?? {};
27
28
 
@@ -30,31 +31,29 @@ export default function useLayoutAreas() {
30
31
 
31
32
  // Regular page
32
33
  if ( path === '/page' ) {
34
+ const isListLayout = layout === 'list' || ! layout;
33
35
  return {
36
+ key: 'pages-list',
34
37
  areas: {
35
- content: undefined,
36
- preview: <Editor isLoading={ isSiteEditorLoading } />,
38
+ content: <PagePages />,
39
+ preview: isListLayout && (
40
+ <Editor
41
+ isLoading={ isSiteEditorLoading }
42
+ onClick={ () =>
43
+ history.push( {
44
+ path,
45
+ postType: 'page',
46
+ postId,
47
+ canvas: 'edit',
48
+ } )
49
+ }
50
+ />
51
+ ),
37
52
  mobile:
38
53
  canvas === 'edit' ? (
39
54
  <Editor isLoading={ isSiteEditorLoading } />
40
55
  ) : undefined,
41
56
  },
42
- widths: {
43
- content: undefined,
44
- },
45
- };
46
- }
47
-
48
- const isListLayout = isCustom !== 'true' && layout === 'list';
49
-
50
- if ( path === '/pages' ) {
51
- return {
52
- areas: {
53
- content: <PagePages />,
54
- preview: isListLayout && (
55
- <Editor isLoading={ isSiteEditorLoading } />
56
- ),
57
- },
58
57
  widths: {
59
58
  content: isListLayout ? 380 : undefined,
60
59
  },
@@ -64,6 +63,7 @@ export default function useLayoutAreas() {
64
63
  // Regular other post types
65
64
  if ( postType && postId ) {
66
65
  return {
66
+ key: 'page',
67
67
  areas: {
68
68
  preview: <Editor isLoading={ isSiteEditorLoading } />,
69
69
  mobile:
@@ -76,7 +76,9 @@ export default function useLayoutAreas() {
76
76
 
77
77
  // Templates
78
78
  if ( path === '/wp_template' ) {
79
+ const isListLayout = isCustom !== 'true' && layout === 'list';
79
80
  return {
81
+ key: 'templates-list',
80
82
  areas: {
81
83
  content: (
82
84
  <PageTemplatesTemplateParts
@@ -100,7 +102,9 @@ export default function useLayoutAreas() {
100
102
 
101
103
  // Template parts
102
104
  if ( path === '/wp_template_part/all' ) {
105
+ const isListLayout = isCustom !== 'true' && layout === 'list';
103
106
  return {
107
+ key: 'template-parts',
104
108
  areas: {
105
109
  content: (
106
110
  <PageTemplatesTemplateParts
@@ -125,6 +129,7 @@ export default function useLayoutAreas() {
125
129
  // Patterns
126
130
  if ( path === '/patterns' ) {
127
131
  return {
132
+ key: 'patterns',
128
133
  areas: {
129
134
  content: <PagePatterns />,
130
135
  mobile: <PagePatterns />,
@@ -134,6 +139,7 @@ export default function useLayoutAreas() {
134
139
 
135
140
  // Fallback shows the home page preview
136
141
  return {
142
+ key: 'default',
137
143
  areas: {
138
144
  preview: <Editor isLoading={ isSiteEditorLoading } />,
139
145
  mobile:
@@ -93,6 +93,8 @@
93
93
  position: relative;
94
94
  flex-grow: 1;
95
95
  z-index: z-index(".edit-site-layout__canvas-container");
96
+ // When animating the frame size can exceed its container size.
97
+ overflow: visible;
96
98
 
97
99
  &.is-resizing::after {
98
100
  // This covers the whole content which ensures mouse up triggers
@@ -15,6 +15,7 @@ import { dateI18n, getDate, getSettings } from '@wordpress/date';
15
15
  import { privateApis as routerPrivateApis } from '@wordpress/router';
16
16
  import { useSelect, useDispatch } from '@wordpress/data';
17
17
  import { DataViews } from '@wordpress/dataviews';
18
+ import { privateApis as editorPrivateApis } from '@wordpress/editor';
18
19
 
19
20
  /**
20
21
  * Internal dependencies
@@ -34,18 +35,12 @@ import {
34
35
  OPERATOR_IS_NONE,
35
36
  } from '../../utils/constants';
36
37
 
37
- import {
38
- trashPostAction,
39
- usePermanentlyDeletePostAction,
40
- useRestorePostAction,
41
- postRevisionsAction,
42
- viewPostAction,
43
- useEditPostAction,
44
- } from '../actions';
45
38
  import AddNewPageModal from '../add-new-page';
46
39
  import Media from '../media';
47
40
  import { unlock } from '../../lock-unlock';
48
41
 
42
+ const { usePostActions } = unlock( editorPrivateApis );
43
+
49
44
  const { useLocation, useHistory } = unlock( routerPrivateApis );
50
45
 
51
46
  const EMPTY_ARRAY = [];
@@ -345,21 +340,20 @@ export default function PagePages() {
345
340
  ],
346
341
  [ authors, view.type ]
347
342
  );
348
-
349
- const permanentlyDeletePostAction = usePermanentlyDeletePostAction();
350
- const restorePostAction = useRestorePostAction();
351
- const editPostAction = useEditPostAction();
352
- const actions = useMemo(
353
- () => [
354
- editPostAction,
355
- viewPostAction,
356
- restorePostAction,
357
- permanentlyDeletePostAction,
358
- postRevisionsAction,
359
- trashPostAction,
360
- ],
361
- [ permanentlyDeletePostAction, restorePostAction, editPostAction ]
343
+ const onActionPerformed = useCallback(
344
+ ( actionId, items ) => {
345
+ if ( actionId === 'edit-post' ) {
346
+ const post = items[ 0 ];
347
+ history.push( {
348
+ postId: post.id,
349
+ postType: post.type,
350
+ canvas: 'edit',
351
+ } );
352
+ }
353
+ },
354
+ [ history ]
362
355
  );
356
+ const actions = usePostActions( onActionPerformed );
363
357
  const onChangeView = useCallback(
364
358
  ( newView ) => {
365
359
  if ( newView.type !== view.type ) {
@@ -377,27 +371,17 @@ export default function PagePages() {
377
371
  );
378
372
 
379
373
  const [ showAddPageModal, setShowAddPageModal ] = useState( false );
380
- const openModal = useCallback( () => {
381
- if ( ! showAddPageModal ) {
382
- setShowAddPageModal( true );
383
- }
384
- }, [ showAddPageModal ] );
385
- const closeModal = useCallback( () => {
386
- if ( showAddPageModal ) {
387
- setShowAddPageModal( false );
388
- }
389
- }, [ showAddPageModal ] );
390
- const handleNewPage = useCallback(
391
- ( { type, id } ) => {
392
- history.push( {
393
- postId: id,
394
- postType: type,
395
- canvas: 'edit',
396
- } );
397
- closeModal();
398
- },
399
- [ history ]
400
- );
374
+
375
+ const openModal = () => setShowAddPageModal( true );
376
+ const closeModal = () => setShowAddPageModal( false );
377
+ const handleNewPage = ( { type, id } ) => {
378
+ history.push( {
379
+ postId: id,
380
+ postType: type,
381
+ canvas: 'edit',
382
+ } );
383
+ closeModal();
384
+ };
401
385
 
402
386
  // TODO: we need to handle properly `data={ data || EMPTY_ARRAY }` for when `isLoading`.
403
387
  return (
@@ -20,11 +20,7 @@ import {
20
20
  BlockPreview,
21
21
  privateApis as blockEditorPrivateApis,
22
22
  } from '@wordpress/block-editor';
23
- import {
24
- DataViews,
25
- sortByTextFields,
26
- getPaginationResults,
27
- } from '@wordpress/dataviews';
23
+ import { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';
28
24
  import {
29
25
  Icon,
30
26
  header,
@@ -41,6 +37,7 @@ import { usePrevious } from '@wordpress/compose';
41
37
  import Page from '../page';
42
38
  import {
43
39
  LAYOUT_GRID,
40
+ LAYOUT_TABLE,
44
41
  PATTERN_TYPES,
45
42
  TEMPLATE_PART_POST_TYPE,
46
43
  PATTERN_SYNC_TYPES,
@@ -69,6 +66,9 @@ const { ExperimentalBlockEditorProvider, useGlobalStyle } = unlock(
69
66
  const templatePartIcons = { header, footer, uncategorized };
70
67
  const EMPTY_ARRAY = [];
71
68
  const defaultConfigPerViewType = {
69
+ [ LAYOUT_TABLE ]: {
70
+ primaryField: 'title',
71
+ },
72
72
  [ LAYOUT_GRID ]: {
73
73
  mediaField: 'preview',
74
74
  primaryField: 'title',
@@ -151,6 +151,7 @@ function Preview( { item, categoryId, viewType } ) {
151
151
  postId: isUserPattern ? item.id : item.name,
152
152
  categoryId,
153
153
  categoryType: isTemplatePart ? item.type : PATTERN_TYPES.theme,
154
+ canvas: 'edit',
154
155
  } );
155
156
 
156
157
  return (
@@ -175,7 +176,12 @@ function Preview( { item, categoryId, viewType } ) {
175
176
  >
176
177
  { isEmpty && isTemplatePart && __( 'Empty template part' ) }
177
178
  { isEmpty && ! isTemplatePart && __( 'Empty pattern' ) }
178
- { ! isEmpty && <BlockPreview blocks={ item.blocks } /> }
179
+ { ! isEmpty && (
180
+ <BlockPreview
181
+ blocks={ item.blocks }
182
+ viewportWidth={ item.viewportWidth }
183
+ />
184
+ ) }
179
185
  </PreviewWrapper>
180
186
  </div>
181
187
  { ariaDescriptions.map( ( ariaDescription, index ) => (
@@ -201,6 +207,7 @@ function Title( { item, categoryId } ) {
201
207
  postId: isUserPattern ? item.id : item.name,
202
208
  categoryId,
203
209
  categoryType: isTemplatePart ? item.type : PATTERN_TYPES.theme,
210
+ canvas: 'edit',
204
211
  } );
205
212
  if ( ! isUserPattern && templatePartIcons[ categoryId ] ) {
206
213
  itemIcon = templatePartIcons[ categoryId ];
@@ -337,27 +344,12 @@ export default function DataviewsPatterns() {
337
344
  }
338
345
  }, [ categoryId, previousCategoryId ] );
339
346
  const { data, paginationInfo } = useMemo( () => {
340
- if ( ! patterns ) {
341
- return {
342
- data: EMPTY_ARRAY,
343
- paginationInfo: { totalItems: 0, totalPages: 0 },
344
- };
345
- }
346
- let filteredData = [ ...patterns ];
347
- // Handle sorting.
348
- if ( view.sort ) {
349
- filteredData = sortByTextFields( {
350
- data: filteredData,
351
- view,
352
- fields,
353
- textFields: [ 'title', 'author' ],
354
- } );
355
- }
356
- // Handle pagination.
357
- return getPaginationResults( {
358
- data: filteredData,
359
- view,
360
- } );
347
+ // Since filters are applied server-side,
348
+ // we need to remove them from the view
349
+ const viewWithoutFilters = { ...view };
350
+ delete viewWithoutFilters.search;
351
+ viewWithoutFilters.filters = [];
352
+ return filterSortAndPaginate( patterns, viewWithoutFilters, fields );
361
353
  }, [ patterns, view, fields ] );
362
354
 
363
355
  const actions = useMemo(
@@ -413,7 +405,7 @@ export default function DataviewsPatterns() {
413
405
  view={ view }
414
406
  onChangeView={ onChangeView }
415
407
  deferredRendering
416
- supportedLayouts={ [ LAYOUT_GRID ] }
408
+ supportedLayouts={ [ LAYOUT_GRID, LAYOUT_TABLE ] }
417
409
  />
418
410
  </Page>
419
411
  </ExperimentalBlockEditorProvider>