@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.
- package/build/components/block-editor/index.js +0 -4
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/block-editor/use-site-editor-settings.js +12 -6
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/page-patterns/grid.js +72 -12
- package/build/components/page-patterns/grid.js.map +1 -1
- package/build/components/page-patterns/patterns-list.js +2 -3
- package/build/components/page-patterns/patterns-list.js.map +1 -1
- package/build/components/page-template-parts/add-new-template-part.js +74 -0
- package/build/components/page-template-parts/add-new-template-part.js.map +1 -0
- package/build/components/page-template-parts/index.js +2 -23
- package/build/components/page-template-parts/index.js.map +1 -1
- package/build/components/resizable-frame/index.js +75 -32
- package/build/components/resizable-frame/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +13 -7
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/template-part-hint.js +1 -1
- package/build/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +3 -3
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pages/index.js +33 -25
- package/build/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +3 -2
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +3 -2
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js +3 -4
- package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build/components/site-hub/index.js +3 -1
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-path-with-url.js +15 -12
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-module/components/block-editor/index.js +0 -4
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +13 -7
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/page-patterns/grid.js +75 -15
- package/build-module/components/page-patterns/grid.js.map +1 -1
- package/build-module/components/page-patterns/patterns-list.js +3 -4
- package/build-module/components/page-patterns/patterns-list.js.map +1 -1
- package/build-module/components/page-template-parts/add-new-template-part.js +58 -0
- package/build-module/components/page-template-parts/add-new-template-part.js.map +1 -0
- package/build-module/components/page-template-parts/index.js +3 -22
- package/build-module/components/page-template-parts/index.js.map +1 -1
- package/build-module/components/resizable-frame/index.js +76 -35
- package/build-module/components/resizable-frame/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +14 -8
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js +1 -1
- package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +3 -3
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pages/index.js +33 -25
- package/build-module/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +3 -2
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +3 -2
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.js +3 -4
- package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +3 -1
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +16 -12
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-style/style-rtl.css +48 -10
- package/build-style/style.css +48 -10
- package/package.json +14 -14
- package/src/components/block-editor/index.js +0 -4
- package/src/components/block-editor/use-site-editor-settings.js +16 -11
- package/src/components/layout/style.scss +1 -0
- package/src/components/page-patterns/grid.js +101 -16
- package/src/components/page-patterns/patterns-list.js +3 -4
- package/src/components/page-patterns/style.scss +21 -1
- package/src/components/page-template-parts/add-new-template-part.js +57 -0
- package/src/components/page-template-parts/index.js +3 -22
- package/src/components/resizable-frame/index.js +100 -31
- package/src/components/resizable-frame/style.scss +26 -9
- package/src/components/sidebar-navigation-item/style.scss +10 -1
- package/src/components/sidebar-navigation-screen/index.js +13 -6
- package/src/components/sidebar-navigation-screen-main/template-part-hint.js +1 -3
- package/src/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
- package/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +1 -1
- package/src/components/sidebar-navigation-screen-pages/index.js +39 -29
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +2 -1
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +2 -1
- package/src/components/sidebar-navigation-screen-patterns/index.js +20 -18
- package/src/components/site-hub/index.js +5 -1
- package/src/components/site-hub/style.scss +5 -0
- 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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
isMounting.current
|
|
56
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
}
|