@wordpress/edit-site 5.12.8 → 5.12.9

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 (93) hide show
  1. package/build/components/block-editor/index.js +0 -4
  2. package/build/components/block-editor/index.js.map +1 -1
  3. package/build/components/block-editor/use-site-editor-settings.js +12 -6
  4. package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
  5. package/build/components/page-patterns/grid.js +72 -12
  6. package/build/components/page-patterns/grid.js.map +1 -1
  7. package/build/components/page-patterns/patterns-list.js +2 -3
  8. package/build/components/page-patterns/patterns-list.js.map +1 -1
  9. package/build/components/page-template-parts/add-new-template-part.js +74 -0
  10. package/build/components/page-template-parts/add-new-template-part.js.map +1 -0
  11. package/build/components/page-template-parts/index.js +2 -23
  12. package/build/components/page-template-parts/index.js.map +1 -1
  13. package/build/components/resizable-frame/index.js +75 -32
  14. package/build/components/resizable-frame/index.js.map +1 -1
  15. package/build/components/sidebar-navigation-screen/index.js +13 -7
  16. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  17. package/build/components/sidebar-navigation-screen-main/template-part-hint.js +1 -1
  18. package/build/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -1
  19. package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
  20. package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
  21. package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +3 -3
  22. package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
  23. package/build/components/sidebar-navigation-screen-pages/index.js +33 -25
  24. package/build/components/sidebar-navigation-screen-pages/index.js.map +1 -1
  25. package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +3 -2
  26. package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
  27. package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +3 -2
  28. package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
  29. package/build/components/sidebar-navigation-screen-patterns/index.js +3 -4
  30. package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  31. package/build/components/site-hub/index.js +3 -1
  32. package/build/components/site-hub/index.js.map +1 -1
  33. package/build/components/sync-state-with-url/use-sync-path-with-url.js +15 -12
  34. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  35. package/build-module/components/block-editor/index.js +0 -4
  36. package/build-module/components/block-editor/index.js.map +1 -1
  37. package/build-module/components/block-editor/use-site-editor-settings.js +13 -7
  38. package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
  39. package/build-module/components/page-patterns/grid.js +75 -15
  40. package/build-module/components/page-patterns/grid.js.map +1 -1
  41. package/build-module/components/page-patterns/patterns-list.js +3 -4
  42. package/build-module/components/page-patterns/patterns-list.js.map +1 -1
  43. package/build-module/components/page-template-parts/add-new-template-part.js +58 -0
  44. package/build-module/components/page-template-parts/add-new-template-part.js.map +1 -0
  45. package/build-module/components/page-template-parts/index.js +3 -22
  46. package/build-module/components/page-template-parts/index.js.map +1 -1
  47. package/build-module/components/resizable-frame/index.js +76 -35
  48. package/build-module/components/resizable-frame/index.js.map +1 -1
  49. package/build-module/components/sidebar-navigation-screen/index.js +14 -8
  50. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  51. package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js +1 -1
  52. package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -1
  53. package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
  54. package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
  55. package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +3 -3
  56. package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
  57. package/build-module/components/sidebar-navigation-screen-pages/index.js +33 -25
  58. package/build-module/components/sidebar-navigation-screen-pages/index.js.map +1 -1
  59. package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +3 -2
  60. package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
  61. package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +3 -2
  62. package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
  63. package/build-module/components/sidebar-navigation-screen-patterns/index.js +3 -4
  64. package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  65. package/build-module/components/site-hub/index.js +3 -1
  66. package/build-module/components/site-hub/index.js.map +1 -1
  67. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +16 -12
  68. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  69. package/build-style/style-rtl.css +48 -10
  70. package/build-style/style.css +48 -10
  71. package/package.json +14 -14
  72. package/src/components/block-editor/index.js +0 -4
  73. package/src/components/block-editor/use-site-editor-settings.js +16 -11
  74. package/src/components/layout/style.scss +1 -0
  75. package/src/components/page-patterns/grid.js +101 -16
  76. package/src/components/page-patterns/patterns-list.js +3 -4
  77. package/src/components/page-patterns/style.scss +21 -1
  78. package/src/components/page-template-parts/add-new-template-part.js +57 -0
  79. package/src/components/page-template-parts/index.js +3 -22
  80. package/src/components/resizable-frame/index.js +100 -31
  81. package/src/components/resizable-frame/style.scss +26 -9
  82. package/src/components/sidebar-navigation-item/style.scss +10 -1
  83. package/src/components/sidebar-navigation-screen/index.js +13 -6
  84. package/src/components/sidebar-navigation-screen-main/template-part-hint.js +1 -3
  85. package/src/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
  86. package/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +1 -1
  87. package/src/components/sidebar-navigation-screen-pages/index.js +39 -29
  88. package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +2 -1
  89. package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +2 -1
  90. package/src/components/sidebar-navigation-screen-patterns/index.js +20 -18
  91. package/src/components/site-hub/index.js +5 -1
  92. package/src/components/site-hub/style.scss +5 -0
  93. package/src/components/sync-state-with-url/use-sync-path-with-url.js +73 -66
@@ -36,6 +36,12 @@ export function getPathFromURL( urlParams ) {
36
36
  return path;
37
37
  }
38
38
 
39
+ function isSubset( subset, superset ) {
40
+ return Object.entries( subset ).every( ( [ key, value ] ) => {
41
+ return superset[ key ] === value;
42
+ } );
43
+ }
44
+
39
45
  export default function useSyncPathWithURL() {
40
46
  const history = useHistory();
41
47
  const { params: urlParams } = useLocation();
@@ -44,76 +50,77 @@ export default function useSyncPathWithURL() {
44
50
  params: navigatorParams,
45
51
  goTo,
46
52
  } = useNavigator();
47
- const currentUrlParams = useRef( urlParams );
48
- const currentPath = useRef( navigatorLocation.path );
49
53
  const isMounting = useRef( true );
50
54
 
51
- useEffect( () => {
52
- // The navigatorParams are only initially filled properly when the
53
- // navigator screens mount. so we ignore the first synchronisation.
54
- if ( isMounting.current ) {
55
- isMounting.current = false;
56
- return;
57
- }
58
-
59
- function updateUrlParams( newUrlParams ) {
60
- if (
61
- Object.entries( newUrlParams ).every( ( [ key, value ] ) => {
62
- return currentUrlParams.current[ key ] === value;
63
- } )
64
- ) {
55
+ useEffect(
56
+ () => {
57
+ // The navigatorParams are only initially filled properly when the
58
+ // navigator screens mount. so we ignore the first synchronisation.
59
+ if ( isMounting.current ) {
60
+ isMounting.current = false;
65
61
  return;
66
62
  }
67
- const updatedParams = {
68
- ...currentUrlParams.current,
69
- ...newUrlParams,
70
- };
71
- currentUrlParams.current = updatedParams;
72
- history.push( updatedParams );
73
- }
74
63
 
75
- if ( navigatorParams?.postType && navigatorParams?.postId ) {
76
- updateUrlParams( {
77
- postType: navigatorParams?.postType,
78
- postId: navigatorParams?.postId,
79
- path: undefined,
80
- } );
81
- } else if (
82
- navigatorLocation.path.startsWith( '/page/' ) &&
83
- navigatorParams?.postId
84
- ) {
85
- updateUrlParams( {
86
- postType: 'page',
87
- postId: navigatorParams?.postId,
88
- path: undefined,
89
- } );
90
- } else if ( navigatorLocation.path === '/patterns' ) {
91
- updateUrlParams( {
92
- postType: undefined,
93
- postId: undefined,
94
- canvas: undefined,
95
- path: navigatorLocation.path,
96
- } );
97
- } else {
98
- updateUrlParams( {
99
- postType: undefined,
100
- postId: undefined,
101
- categoryType: undefined,
102
- categoryId: undefined,
103
- path:
104
- navigatorLocation.path === '/'
105
- ? undefined
106
- : navigatorLocation.path,
107
- } );
108
- }
109
- }, [ navigatorLocation?.path, navigatorParams, history ] );
64
+ function updateUrlParams( newUrlParams ) {
65
+ if ( isSubset( newUrlParams, urlParams ) ) {
66
+ return;
67
+ }
68
+ const updatedParams = {
69
+ ...urlParams,
70
+ ...newUrlParams,
71
+ };
72
+ history.push( updatedParams );
73
+ }
110
74
 
111
- useEffect( () => {
112
- currentUrlParams.current = urlParams;
113
- const path = getPathFromURL( urlParams );
114
- if ( currentPath.current !== path ) {
115
- currentPath.current = path;
116
- goTo( path );
117
- }
118
- }, [ urlParams, goTo ] );
75
+ if ( navigatorParams?.postType && navigatorParams?.postId ) {
76
+ updateUrlParams( {
77
+ postType: navigatorParams?.postType,
78
+ postId: navigatorParams?.postId,
79
+ path: undefined,
80
+ } );
81
+ } else if (
82
+ navigatorLocation.path.startsWith( '/page/' ) &&
83
+ navigatorParams?.postId
84
+ ) {
85
+ updateUrlParams( {
86
+ postType: 'page',
87
+ postId: navigatorParams?.postId,
88
+ path: undefined,
89
+ } );
90
+ } else if ( navigatorLocation.path === '/patterns' ) {
91
+ updateUrlParams( {
92
+ postType: undefined,
93
+ postId: undefined,
94
+ canvas: undefined,
95
+ path: navigatorLocation.path,
96
+ } );
97
+ } else {
98
+ updateUrlParams( {
99
+ postType: undefined,
100
+ postId: undefined,
101
+ categoryType: undefined,
102
+ categoryId: undefined,
103
+ path:
104
+ navigatorLocation.path === '/'
105
+ ? undefined
106
+ : navigatorLocation.path,
107
+ } );
108
+ }
109
+ },
110
+ // Trigger only when navigator changes to prevent infinite loops.
111
+ // eslint-disable-next-line react-hooks/exhaustive-deps
112
+ [ navigatorLocation?.path, navigatorParams ]
113
+ );
114
+
115
+ useEffect(
116
+ () => {
117
+ const path = getPathFromURL( urlParams );
118
+ if ( navigatorLocation.path !== path ) {
119
+ goTo( path );
120
+ }
121
+ },
122
+ // Trigger only when URL changes to prevent infinite loops.
123
+ // eslint-disable-next-line react-hooks/exhaustive-deps
124
+ [ urlParams ]
125
+ );
119
126
  }