@wordpress/edit-site 5.28.9 → 5.28.11

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 (39) hide show
  1. package/build/components/global-styles/font-library-modal/context.js +50 -22
  2. package/build/components/global-styles/font-library-modal/context.js.map +1 -1
  3. package/build/components/global-styles/font-library-modal/font-collection.js +1 -0
  4. package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  5. package/build/components/global-styles/font-library-modal/index.js +1 -1
  6. package/build/components/global-styles/font-library-modal/index.js.map +1 -1
  7. package/build/components/global-styles/font-library-modal/installed-fonts.js +6 -5
  8. package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  9. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +14 -5
  10. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  11. package/build/hooks/push-changes-to-global-styles/index.js +4 -40
  12. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  13. package/build/utils/set-nested-value.js +44 -0
  14. package/build/utils/set-nested-value.js.map +1 -0
  15. package/build-module/components/global-styles/font-library-modal/context.js +49 -22
  16. package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
  17. package/build-module/components/global-styles/font-library-modal/font-collection.js +1 -0
  18. package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  19. package/build-module/components/global-styles/font-library-modal/index.js +2 -2
  20. package/build-module/components/global-styles/font-library-modal/index.js.map +1 -1
  21. package/build-module/components/global-styles/font-library-modal/installed-fonts.js +6 -5
  22. package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  23. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +14 -5
  24. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  25. package/build-module/hooks/push-changes-to-global-styles/index.js +1 -38
  26. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  27. package/build-module/utils/set-nested-value.js +38 -0
  28. package/build-module/utils/set-nested-value.js.map +1 -0
  29. package/build-style/style-rtl.css +2 -0
  30. package/build-style/style.css +2 -0
  31. package/package.json +16 -16
  32. package/src/components/global-styles/font-library-modal/context.js +66 -41
  33. package/src/components/global-styles/font-library-modal/font-collection.js +1 -0
  34. package/src/components/global-styles/font-library-modal/index.js +2 -2
  35. package/src/components/global-styles/font-library-modal/installed-fonts.js +4 -2
  36. package/src/components/global-styles/font-library-modal/style.scss +6 -0
  37. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +50 -35
  38. package/src/hooks/push-changes-to-global-styles/index.js +1 -40
  39. package/src/utils/set-nested-value.js +39 -0
@@ -1,3 +1,7 @@
1
+ // Fixed height for the modal footer.
2
+ // Ensures that the footer is always visible when the modal content is scrollable.
3
+ $footer-height: 70px;
4
+
1
5
  .font-library-modal {
2
6
  // @todo: If a new prop is added to the Modal component that constrains
3
7
  // the content width, we should use that prop instead of this style.
@@ -15,6 +19,7 @@
15
19
 
16
20
  .components-modal__content {
17
21
  padding-top: 0;
22
+ margin-bottom: $footer-height;
18
23
  }
19
24
 
20
25
  .font-library-modal__subtitle {
@@ -40,6 +45,7 @@
40
45
  position: absolute;
41
46
  bottom: $grid-unit-40;
42
47
  width: 100%;
48
+ height: $footer-height;
43
49
  background-color: $white;
44
50
  }
45
51
  }
@@ -28,42 +28,48 @@ const postTypesWithoutParentTemplate = [
28
28
  ];
29
29
 
30
30
  function useResolveEditedEntityAndContext( { path, postId, postType } ) {
31
- const { hasLoadedAllDependencies, homepageId, url, frontPageTemplateId } =
32
- useSelect( ( select ) => {
33
- const { getSite, getUnstableBase, getEntityRecords } =
34
- select( coreDataStore );
35
- const siteData = getSite();
36
- const base = getUnstableBase();
37
- const templates = getEntityRecords(
38
- 'postType',
39
- TEMPLATE_POST_TYPE,
40
- {
41
- per_page: -1,
42
- }
31
+ const {
32
+ hasLoadedAllDependencies,
33
+ homepageId,
34
+ postsPageId,
35
+ url,
36
+ frontPageTemplateId,
37
+ } = useSelect( ( select ) => {
38
+ const { getSite, getUnstableBase, getEntityRecords } =
39
+ select( coreDataStore );
40
+ const siteData = getSite();
41
+ const base = getUnstableBase();
42
+ const templates = getEntityRecords( 'postType', TEMPLATE_POST_TYPE, {
43
+ per_page: -1,
44
+ } );
45
+ const _homepageId =
46
+ siteData?.show_on_front === 'page' &&
47
+ [ 'number', 'string' ].includes( typeof siteData.page_on_front ) &&
48
+ !! +siteData.page_on_front // We also need to check if it's not zero(`0`).
49
+ ? siteData.page_on_front.toString()
50
+ : null;
51
+ const _postsPageId =
52
+ siteData?.show_on_front === 'page' &&
53
+ [ 'number', 'string' ].includes( typeof siteData.page_for_posts )
54
+ ? siteData.page_for_posts.toString()
55
+ : null;
56
+ let _frontPageTemplateId;
57
+ if ( templates ) {
58
+ const frontPageTemplate = templates.find(
59
+ ( t ) => t.slug === 'front-page'
43
60
  );
44
- let _frontPateTemplateId;
45
- if ( templates ) {
46
- const frontPageTemplate = templates.find(
47
- ( t ) => t.slug === 'front-page'
48
- );
49
- _frontPateTemplateId = frontPageTemplate
50
- ? frontPageTemplate.id
51
- : false;
52
- }
53
-
54
- return {
55
- hasLoadedAllDependencies: !! base && !! siteData,
56
- homepageId:
57
- siteData?.show_on_front === 'page' &&
58
- [ 'number', 'string' ].includes(
59
- typeof siteData.page_on_front
60
- )
61
- ? siteData.page_on_front.toString()
62
- : null,
63
- url: base?.home,
64
- frontPageTemplateId: _frontPateTemplateId,
65
- };
66
- }, [] );
61
+ _frontPageTemplateId = frontPageTemplate
62
+ ? frontPageTemplate.id
63
+ : false;
64
+ }
65
+ return {
66
+ hasLoadedAllDependencies: !! base && !! siteData,
67
+ homepageId: _homepageId,
68
+ postsPageId: _postsPageId,
69
+ url: base?.home,
70
+ frontPageTemplateId: _frontPageTemplateId,
71
+ };
72
+ }, [] );
67
73
 
68
74
  /**
69
75
  * This is a hook that recreates the logic to resolve a template for a given WordPress postID postTypeId
@@ -114,6 +120,14 @@ function useResolveEditedEntityAndContext( { path, postId, postType } ) {
114
120
  if ( ! editedEntity ) {
115
121
  return undefined;
116
122
  }
123
+ // Check if the current page is the posts page.
124
+ if (
125
+ postTypeToResolve === 'page' &&
126
+ postsPageId === postIdToResolve
127
+ ) {
128
+ return __experimentalGetTemplateForLink( editedEntity.link )
129
+ ?.id;
130
+ }
117
131
  // First see if the post/page has an assigned template and fetch it.
118
132
  const currentTemplateSlug = editedEntity.template;
119
133
  if ( currentTemplateSlug ) {
@@ -177,6 +191,7 @@ function useResolveEditedEntityAndContext( { path, postId, postType } ) {
177
191
  },
178
192
  [
179
193
  homepageId,
194
+ postsPageId,
180
195
  hasLoadedAllDependencies,
181
196
  url,
182
197
  postId,
@@ -26,6 +26,7 @@ import { store as coreStore } from '@wordpress/core-data';
26
26
  */
27
27
  import { useSupportedStyles } from '../../components/global-styles/hooks';
28
28
  import { unlock } from '../../lock-unlock';
29
+ import setNestedValue from '../../utils/set-nested-value';
29
30
 
30
31
  const { cleanEmptyObject, GlobalStylesContext } = unlock(
31
32
  blockEditorPrivateApis
@@ -235,46 +236,6 @@ function useChangesToPush( name, attributes, userConfig ) {
235
236
  }, [ supports, attributes, blockUserConfig ] );
236
237
  }
237
238
 
238
- /**
239
- * Sets the value at path of object.
240
- * If a portion of path doesn’t exist, it’s created.
241
- * Arrays are created for missing index properties while objects are created
242
- * for all other missing properties.
243
- *
244
- * This function intentionally mutates the input object.
245
- *
246
- * Inspired by _.set().
247
- *
248
- * @see https://lodash.com/docs/4.17.15#set
249
- *
250
- * @todo Needs to be deduplicated with its copy in `@wordpress/core-data`.
251
- *
252
- * @param {Object} object Object to modify
253
- * @param {Array} path Path of the property to set.
254
- * @param {*} value Value to set.
255
- */
256
- function setNestedValue( object, path, value ) {
257
- if ( ! object || typeof object !== 'object' ) {
258
- return object;
259
- }
260
-
261
- path.reduce( ( acc, key, idx ) => {
262
- if ( acc[ key ] === undefined ) {
263
- if ( Number.isInteger( path[ idx + 1 ] ) ) {
264
- acc[ key ] = [];
265
- } else {
266
- acc[ key ] = {};
267
- }
268
- }
269
- if ( idx === path.length - 1 ) {
270
- acc[ key ] = value;
271
- }
272
- return acc[ key ];
273
- }, object );
274
-
275
- return object;
276
- }
277
-
278
239
  function cloneDeep( object ) {
279
240
  return ! object ? {} : JSON.parse( JSON.stringify( object ) );
280
241
  }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Sets the value at path of object.
3
+ * If a portion of path doesn’t exist, it’s created.
4
+ * Arrays are created for missing index properties while objects are created
5
+ * for all other missing properties.
6
+ *
7
+ * This function intentionally mutates the input object.
8
+ *
9
+ * Inspired by _.set().
10
+ *
11
+ * @see https://lodash.com/docs/4.17.15#set
12
+ *
13
+ * @todo Needs to be deduplicated with its copy in `@wordpress/core-data`.
14
+ *
15
+ * @param {Object} object Object to modify
16
+ * @param {Array} path Path of the property to set.
17
+ * @param {*} value Value to set.
18
+ */
19
+ export default function setNestedValue( object, path, value ) {
20
+ if ( ! object || typeof object !== 'object' ) {
21
+ return object;
22
+ }
23
+
24
+ path.reduce( ( acc, key, idx ) => {
25
+ if ( acc[ key ] === undefined ) {
26
+ if ( Number.isInteger( path[ idx + 1 ] ) ) {
27
+ acc[ key ] = [];
28
+ } else {
29
+ acc[ key ] = {};
30
+ }
31
+ }
32
+ if ( idx === path.length - 1 ) {
33
+ acc[ key ] = value;
34
+ }
35
+ return acc[ key ];
36
+ }, object );
37
+
38
+ return object;
39
+ }