@wordpress/editor 14.8.3 → 14.8.5

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 (65) hide show
  1. package/build/bindings/post-meta.js +64 -42
  2. package/build/bindings/post-meta.js.map +1 -1
  3. package/build/components/editor-interface/index.js +7 -3
  4. package/build/components/editor-interface/index.js.map +1 -1
  5. package/build/components/entities-saved-states/index.js +8 -6
  6. package/build/components/entities-saved-states/index.js.map +1 -1
  7. package/build/components/plugin-sidebar/index.js +2 -6
  8. package/build/components/plugin-sidebar/index.js.map +1 -1
  9. package/build/components/post-publish-panel/maybe-upload-media.js +3 -3
  10. package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  11. package/build/components/preview-dropdown/index.js +14 -1
  12. package/build/components/preview-dropdown/index.js.map +1 -1
  13. package/build/components/provider/index.js +10 -14
  14. package/build/components/provider/index.js.map +1 -1
  15. package/build/components/visual-editor/index.js +6 -6
  16. package/build/components/visual-editor/index.js.map +1 -1
  17. package/build/components/zoom-out-toggle/index.js +22 -6
  18. package/build/components/zoom-out-toggle/index.js.map +1 -1
  19. package/build/store/actions.js +15 -4
  20. package/build/store/actions.js.map +1 -1
  21. package/build-module/bindings/post-meta.js +65 -42
  22. package/build-module/bindings/post-meta.js.map +1 -1
  23. package/build-module/components/editor-interface/index.js +7 -3
  24. package/build-module/components/editor-interface/index.js.map +1 -1
  25. package/build-module/components/entities-saved-states/index.js +8 -6
  26. package/build-module/components/entities-saved-states/index.js.map +1 -1
  27. package/build-module/components/plugin-sidebar/index.js +2 -6
  28. package/build-module/components/plugin-sidebar/index.js.map +1 -1
  29. package/build-module/components/post-publish-panel/maybe-upload-media.js +3 -3
  30. package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  31. package/build-module/components/preview-dropdown/index.js +14 -1
  32. package/build-module/components/preview-dropdown/index.js.map +1 -1
  33. package/build-module/components/provider/index.js +10 -14
  34. package/build-module/components/provider/index.js.map +1 -1
  35. package/build-module/components/visual-editor/index.js +6 -6
  36. package/build-module/components/visual-editor/index.js.map +1 -1
  37. package/build-module/components/zoom-out-toggle/index.js +22 -6
  38. package/build-module/components/zoom-out-toggle/index.js.map +1 -1
  39. package/build-module/store/actions.js +16 -5
  40. package/build-module/store/actions.js.map +1 -1
  41. package/build-style/style-rtl.css +2 -2
  42. package/build-style/style.css +2 -2
  43. package/build-types/bindings/post-meta.d.ts +3 -8
  44. package/build-types/bindings/post-meta.d.ts.map +1 -1
  45. package/build-types/components/editor-interface/index.d.ts.map +1 -1
  46. package/build-types/components/entities-saved-states/index.d.ts.map +1 -1
  47. package/build-types/components/plugin-sidebar/index.d.ts.map +1 -1
  48. package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
  49. package/build-types/components/provider/index.d.ts.map +1 -1
  50. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  51. package/build-types/components/zoom-out-toggle/index.d.ts.map +1 -1
  52. package/build-types/store/actions.d.ts.map +1 -1
  53. package/package.json +30 -30
  54. package/src/bindings/post-meta.js +73 -65
  55. package/src/components/editor-interface/index.js +6 -4
  56. package/src/components/entities-saved-states/index.js +10 -8
  57. package/src/components/entities-saved-states/style.scss +2 -2
  58. package/src/components/plugin-sidebar/index.js +1 -6
  59. package/src/components/post-publish-panel/maybe-upload-media.js +3 -3
  60. package/src/components/preview-dropdown/index.js +11 -1
  61. package/src/components/provider/index.js +13 -20
  62. package/src/components/visual-editor/index.js +8 -6
  63. package/src/components/zoom-out-toggle/index.js +23 -6
  64. package/src/store/actions.js +26 -11
  65. package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/provider/index.js"],"names":[],"mappings":"AAuWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,sCArBG;IAAwB,IAAI;IACJ,kBAAkB;IAElB,QAAQ;IAER,QAAQ;CAGhC,GAWS,GAAG,CAAC,OAAO,CAWtB;AA5QD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,4GAyME"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/provider/index.js"],"names":[],"mappings":"AAgWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,sCArBG;IAAwB,IAAI;IACJ,kBAAkB;IAElB,QAAQ;IAER,QAAQ;CAGhC,GAWS,GAAG,CAAC,OAAO,CAWtB;AArQD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,4GAkME"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/visual-editor/index.js"],"names":[],"mappings":";AAkGA;;;;;;;gCA8YC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/visual-editor/index.js"],"names":[],"mappings":";AAkGA;;;;;;;gCAgZC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/zoom-out-toggle/index.js"],"names":[],"mappings":";AAUA,8DAqBC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/zoom-out-toggle/index.js"],"names":[],"mappings":";AAgBA,8DAgCC"}
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/store/actions.js"],"names":[],"mappings":"AAsEA;;;;;;;GAOG;AACH,gDAFY,MAAM,CAUjB;AAED;;;;;GAKG;AACH;;EAOC;AAED;;;;;;GAMG;AACH,8BAHY,MAAM,CAWjB;AAED;;;;;;GAMG;AACH,uCAFW,MAAM,UAQhB;AAED;;;;;;;GAOG;AACH,wCALW,MAAM,UACN,MAAM,GAEL,MAAM,CAQjB;AAsID;;;;GAIG;AACH;;EAOC;AAqGD;;;;GAIG;AACH;;EAOC;AAED;;;;;GAKG;AACH,qCAHW,MAAM,GACL,MAAM,CAOjB;AAwBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,yCAxCW,MAAM,GAsCL,MAAM,CAOjB;AAED;;;;;;;;;;;;GAYG;AACH,2CAVW,MAAM,GAQL,MAAM,CAOjB;AAED;;;;;;;;;;;;GAYG;AACH,6CAVW,MAAM,GAQL,MAAM,CAOjB;AAED;;;;;;;;;;;;GAYG;AACH,+CAVW,MAAM,GAQL,MAAM,CAOjB;AA6CD;;;EAKC;AAyBD;;;;;;GAMG;AACH,0CAJW,MAAM,GAEL,MAAM,CAOjB;AAiED;;;;;;GAMG;AACH,6CAJW,MAAM,GAEL,MAAM,CAOjB;AAED;;;;;;;;;;;GAWG;AACH,2CATW,OAAO,GAAC,MAAM,GAOb,MAAM,CAOjB;AAED;;;;;GAKG;AACH,4CAHW,OAAO,GACN,MAAM,CAOjB;AA+FD;;;;;GAKG;AACH,sCAFY,MAAM,CAMjB;AAED;;;;;GAKG;AACH,uCAFY,MAAM,CAMjB;AAED;;;;GAIG;AACH,wCAFY,MAAM,CAMjB;AAx0BM,kCAJI,MAAM,SACN,MAAM,YACN,YAAM;;WAiCf;AA0FK,gCAHI,MAAM,WACN,MAAM;;;WASf;AAOK,mCAFI,MAAM;;;;oBA+Gf;AAmBK;;;;oBA2BL;AAUK,iDAFI,MAAM,OAAC;;;oBAqBhB;AAEK;;;;;mBAkBL;AAKK;;WAIL;AAKK;;WAIL;AAgCK;;WAML;AAKK;;WAML;AAsHK,2DAFK,MAAM,OAAA;;;;WA8BhB;AAwBK,uCAFI,MAAM;;;;WAef;AAuBK,oDAJI,MAAM,GAEL,MAAM,CA0BhB;AAOK,mDAFI,MAAM;;WAyBf;AAqDK;;;WA0DL;AAOK,uCAFI,MAAM;;;WAuBf;AA2CD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC"}
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/store/actions.js"],"names":[],"mappings":"AA0EA;;;;;;;GAOG;AACH,gDAFY,MAAM,CAUjB;AAED;;;;;GAKG;AACH;;EAOC;AAED;;;;;;GAMG;AACH,8BAHY,MAAM,CAWjB;AAED;;;;;;GAMG;AACH,uCAFW,MAAM,UAQhB;AAED;;;;;;;GAOG;AACH,wCALW,MAAM,UACN,MAAM,GAEL,MAAM,CAQjB;AAiJD;;;;GAIG;AACH;;EAOC;AAqGD;;;;GAIG;AACH;;EAOC;AAED;;;;;GAKG;AACH,qCAHW,MAAM,GACL,MAAM,CAOjB;AAwBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,yCAxCW,MAAM,GAsCL,MAAM,CAOjB;AAED;;;;;;;;;;;;GAYG;AACH,2CAVW,MAAM,GAQL,MAAM,CAOjB;AAED;;;;;;;;;;;;GAYG;AACH,6CAVW,MAAM,GAQL,MAAM,CAOjB;AAED;;;;;;;;;;;;GAYG;AACH,+CAVW,MAAM,GAQL,MAAM,CAOjB;AA6CD;;;EAKC;AAyBD;;;;;;GAMG;AACH,0CAJW,MAAM,GAEL,MAAM,CAOjB;AAiED;;;;;;GAMG;AACH,6CAJW,MAAM,GAEL,MAAM,CAOjB;AAED;;;;;;;;;;;GAWG;AACH,2CATW,OAAO,GAAC,MAAM,GAOb,MAAM,CAOjB;AAED;;;;;GAKG;AACH,4CAHW,OAAO,GACN,MAAM,CAOjB;AA+FD;;;;;GAKG;AACH,sCAFY,MAAM,CAMjB;AAED;;;;;GAKG;AACH,uCAFY,MAAM,CAMjB;AAED;;;;GAIG;AACH,wCAFY,MAAM,CAMjB;AAn1BM,kCAJI,MAAM,SACN,MAAM,YACN,YAAM;;WAiCf;AA0FK,gCAHI,MAAM,WACN,MAAM;;;WASf;AAOK,mCAFI,MAAM;;;;oBA0Hf;AAmBK;;;;oBA2BL;AAUK,iDAFI,MAAM,OAAC;;;oBAqBhB;AAEK;;;;;mBAkBL;AAKK;;WAIL;AAKK;;WAIL;AAgCK;;WAML;AAKK;;WAML;AAsHK,2DAFK,MAAM,OAAA;;;;WA8BhB;AAwBK,uCAFI,MAAM;;;;WAef;AAuBK,oDAJI,MAAM,GAEL,MAAM,CA0BhB;AAOK,mDAFI,MAAM;;WAyBf;AAqDK;;;WA0DL;AAOK,uCAFI,MAAM;;;WAuBf;AA2CD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC;AATD;;WASC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/editor",
3
- "version": "14.8.3",
3
+ "version": "14.8.5",
4
4
  "description": "Enhanced block editor for WordPress posts.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -32,38 +32,38 @@
32
32
  ],
33
33
  "dependencies": {
34
34
  "@babel/runtime": "^7.16.0",
35
- "@wordpress/a11y": "^4.8.1",
36
- "@wordpress/api-fetch": "^7.8.1",
35
+ "@wordpress/a11y": "^4.8.2",
36
+ "@wordpress/api-fetch": "^7.8.2",
37
37
  "@wordpress/blob": "^4.8.1",
38
- "@wordpress/block-editor": "^14.3.1",
39
- "@wordpress/blocks": "^13.8.1",
40
- "@wordpress/commands": "^1.8.1",
41
- "@wordpress/components": "^28.8.1",
42
- "@wordpress/compose": "^7.8.1",
43
- "@wordpress/core-data": "^7.8.1",
44
- "@wordpress/data": "^10.8.1",
45
- "@wordpress/dataviews": "^4.4.1",
46
- "@wordpress/date": "^5.8.1",
47
- "@wordpress/deprecated": "^4.8.1",
48
- "@wordpress/dom": "^4.8.1",
38
+ "@wordpress/block-editor": "^14.3.3",
39
+ "@wordpress/blocks": "^13.8.3",
40
+ "@wordpress/commands": "^1.8.3",
41
+ "@wordpress/components": "^28.8.3",
42
+ "@wordpress/compose": "^7.8.3",
43
+ "@wordpress/core-data": "^7.8.3",
44
+ "@wordpress/data": "^10.8.3",
45
+ "@wordpress/dataviews": "^4.4.3",
46
+ "@wordpress/date": "^5.8.2",
47
+ "@wordpress/deprecated": "^4.8.2",
48
+ "@wordpress/dom": "^4.8.2",
49
49
  "@wordpress/element": "^6.8.1",
50
- "@wordpress/fields": "^0.0.2",
51
- "@wordpress/hooks": "^4.8.1",
50
+ "@wordpress/fields": "^0.0.4",
51
+ "@wordpress/hooks": "^4.8.2",
52
52
  "@wordpress/html-entities": "^4.8.1",
53
- "@wordpress/i18n": "^5.8.1",
54
- "@wordpress/icons": "^10.8.1",
55
- "@wordpress/interface": "^6.8.1",
56
- "@wordpress/keyboard-shortcuts": "^5.8.1",
57
- "@wordpress/keycodes": "^4.8.1",
58
- "@wordpress/media-utils": "^5.8.1",
59
- "@wordpress/notices": "^5.8.1",
60
- "@wordpress/patterns": "^2.8.1",
61
- "@wordpress/plugins": "^7.8.1",
62
- "@wordpress/preferences": "^4.8.1",
53
+ "@wordpress/i18n": "^5.8.2",
54
+ "@wordpress/icons": "^10.8.2",
55
+ "@wordpress/interface": "^6.8.3",
56
+ "@wordpress/keyboard-shortcuts": "^5.8.3",
57
+ "@wordpress/keycodes": "^4.8.2",
58
+ "@wordpress/media-utils": "^5.8.2",
59
+ "@wordpress/notices": "^5.8.3",
60
+ "@wordpress/patterns": "^2.8.3",
61
+ "@wordpress/plugins": "^7.8.3",
62
+ "@wordpress/preferences": "^4.8.3",
63
63
  "@wordpress/private-apis": "^1.8.1",
64
- "@wordpress/reusable-blocks": "^5.8.1",
65
- "@wordpress/rich-text": "^7.8.1",
66
- "@wordpress/server-side-render": "^5.8.1",
64
+ "@wordpress/reusable-blocks": "^5.8.3",
65
+ "@wordpress/rich-text": "^7.8.3",
66
+ "@wordpress/server-side-render": "^5.8.3",
67
67
  "@wordpress/url": "^4.8.1",
68
68
  "@wordpress/warning": "^3.8.1",
69
69
  "@wordpress/wordcount": "^4.8.1",
@@ -86,5 +86,5 @@
86
86
  "publishConfig": {
87
87
  "access": "public"
88
88
  },
89
- "gitHead": "3686e926862c54c6326fe97277e0a19f8bbfafdd"
89
+ "gitHead": "6187079697e13c3292eb098d6338523a6676c6e8"
90
90
  }
@@ -9,26 +9,65 @@ import { store as coreDataStore } from '@wordpress/core-data';
9
9
  import { store as editorStore } from '../store';
10
10
  import { unlock } from '../lock-unlock';
11
11
 
12
- function getMetadata( registry, context, registeredFields ) {
13
- let metaFields = {};
14
- const type = registry.select( editorStore ).getCurrentPostType();
12
+ /**
13
+ * Gets a list of post meta fields with their values and labels
14
+ * to be consumed in the needed callbacks.
15
+ * If the value is not available based on context, like in templates,
16
+ * it falls back to the default value, label, or key.
17
+ *
18
+ * @param {Object} registry The registry context exposed through `useRegistry`.
19
+ * @param {Object} context The context provided.
20
+ * @return {Object} List of post meta fields with their value and label.
21
+ *
22
+ * @example
23
+ * ```js
24
+ * {
25
+ * field_1_key: {
26
+ * label: 'Field 1 Label',
27
+ * value: 'Field 1 Value',
28
+ * },
29
+ * field_2_key: {
30
+ * label: 'Field 2 Label',
31
+ * value: 'Field 2 Value',
32
+ * },
33
+ * ...
34
+ * }
35
+ * ```
36
+ */
37
+ function getPostMetaFields( registry, context ) {
15
38
  const { getEditedEntityRecord } = registry.select( coreDataStore );
39
+ const { getRegisteredPostMeta } = unlock(
40
+ registry.select( coreDataStore )
41
+ );
16
42
 
43
+ let entityMetaValues;
44
+ // Try to get the current entity meta values.
17
45
  if ( context?.postType && context?.postId ) {
18
- metaFields = getEditedEntityRecord(
46
+ entityMetaValues = getEditedEntityRecord(
19
47
  'postType',
20
48
  context?.postType,
21
49
  context?.postId
22
50
  ).meta;
23
- } else if ( type === 'wp_template' ) {
24
- // Populate the `metaFields` object with the default values.
25
- Object.entries( registeredFields || {} ).forEach(
26
- ( [ key, props ] ) => {
27
- if ( props.default ) {
28
- metaFields[ key ] = props.default;
29
- }
30
- }
31
- );
51
+ }
52
+
53
+ const registeredFields = getRegisteredPostMeta( context?.postType );
54
+ const metaFields = {};
55
+ Object.entries( registeredFields || {} ).forEach( ( [ key, props ] ) => {
56
+ // Don't include footnotes or private fields.
57
+ if ( key !== 'footnotes' && key.charAt( 0 ) !== '_' ) {
58
+ metaFields[ key ] = {
59
+ label: props.title || key,
60
+ value:
61
+ // When using the entity value, an empty string IS a valid value.
62
+ entityMetaValues?.[ key ] ??
63
+ // When using the default, an empty string IS NOT a valid value.
64
+ ( props.default || undefined ),
65
+ };
66
+ }
67
+ } );
68
+
69
+ if ( ! Object.keys( metaFields || {} ).length ) {
70
+ return null;
32
71
  }
33
72
 
34
73
  return metaFields;
@@ -37,20 +76,15 @@ function getMetadata( registry, context, registeredFields ) {
37
76
  export default {
38
77
  name: 'core/post-meta',
39
78
  getValues( { registry, context, bindings } ) {
40
- const { getRegisteredPostMeta } = unlock(
41
- registry.select( coreDataStore )
42
- );
43
- const registeredFields = getRegisteredPostMeta( context?.postType );
44
- const metaFields = getMetadata( registry, context, registeredFields );
79
+ const metaFields = getPostMetaFields( registry, context );
45
80
 
46
81
  const newValues = {};
47
82
  for ( const [ attributeName, source ] of Object.entries( bindings ) ) {
48
83
  // Use the value, the field label, or the field key.
49
- const metaKey = source.args.key;
50
- newValues[ attributeName ] =
51
- metaFields?.[ metaKey ] ??
52
- registeredFields?.[ metaKey ]?.title ??
53
- metaKey;
84
+ const fieldKey = source.args.key;
85
+ const { value: fieldValue, label: fieldLabel } =
86
+ metaFields?.[ fieldKey ] || {};
87
+ newValues[ attributeName ] = fieldValue ?? fieldLabel ?? fieldKey;
54
88
  }
55
89
  return newValues;
56
90
  },
@@ -65,44 +99,43 @@ export default {
65
99
  meta: newMeta,
66
100
  } );
67
101
  },
68
- canUserEditValue( { select, context, args } ) {
102
+ canUserEditValue( { registry, context, args } ) {
69
103
  // Lock editing in query loop.
70
104
  if ( context?.query || context?.queryId ) {
71
105
  return false;
72
106
  }
73
107
 
74
108
  const postType =
75
- context?.postType || select( editorStore ).getCurrentPostType();
109
+ context?.postType ||
110
+ registry.select( editorStore ).getCurrentPostType();
76
111
 
77
112
  // Check that editing is happening in the post editor and not a template.
78
113
  if ( postType === 'wp_template' ) {
79
114
  return false;
80
115
  }
81
116
 
82
- // Check that the custom field is not protected and available in the REST API.
117
+ const fieldValue = getPostMetaFields( registry, context )?.[ args.key ]
118
+ ?.value;
83
119
  // Empty string or `false` could be a valid value, so we need to check if the field value is undefined.
84
- const fieldValue = select( coreDataStore ).getEntityRecord(
85
- 'postType',
86
- postType,
87
- context?.postId
88
- )?.meta?.[ args.key ];
89
-
90
120
  if ( fieldValue === undefined ) {
91
121
  return false;
92
122
  }
93
123
  // Check that custom fields metabox is not enabled.
94
- const areCustomFieldsEnabled =
95
- select( editorStore ).getEditorSettings().enableCustomFields;
124
+ const areCustomFieldsEnabled = registry
125
+ .select( editorStore )
126
+ .getEditorSettings().enableCustomFields;
96
127
  if ( areCustomFieldsEnabled ) {
97
128
  return false;
98
129
  }
99
130
 
100
131
  // Check that the user has the capability to edit post meta.
101
- const canUserEdit = select( coreDataStore ).canUser( 'update', {
102
- kind: 'postType',
103
- name: context?.postType,
104
- id: context?.postId,
105
- } );
132
+ const canUserEdit = registry
133
+ .select( coreDataStore )
134
+ .canUser( 'update', {
135
+ kind: 'postType',
136
+ name: context?.postType,
137
+ id: context?.postId,
138
+ } );
106
139
  if ( ! canUserEdit ) {
107
140
  return false;
108
141
  }
@@ -110,31 +143,6 @@ export default {
110
143
  return true;
111
144
  },
112
145
  getFieldsList( { registry, context } ) {
113
- const { getRegisteredPostMeta } = unlock(
114
- registry.select( coreDataStore )
115
- );
116
- const registeredFields = getRegisteredPostMeta( context?.postType );
117
- const metaFields = getMetadata( registry, context, registeredFields );
118
-
119
- if ( ! metaFields || ! Object.keys( metaFields ).length ) {
120
- return null;
121
- }
122
-
123
- return Object.fromEntries(
124
- Object.entries( metaFields )
125
- // Remove footnotes or private keys from the list of fields.
126
- .filter(
127
- ( [ key ] ) =>
128
- key !== 'footnotes' && key.charAt( 0 ) !== '_'
129
- )
130
- // Return object with label and value.
131
- .map( ( [ key, value ] ) => [
132
- key,
133
- {
134
- label: registeredFields?.[ key ]?.title || key,
135
- value,
136
- },
137
- ] )
138
- );
146
+ return getPostMetaFields( registry, context );
139
147
  },
140
148
  };
@@ -32,6 +32,8 @@ import TextEditor from '../text-editor';
32
32
  import VisualEditor from '../visual-editor';
33
33
  import EditorContentSlotFill from './content-slot-fill';
34
34
 
35
+ import { unlock } from '../../lock-unlock';
36
+
35
37
  const interfaceLabels = {
36
38
  /* translators: accessibility text for the editor top bar landmark region. */
37
39
  header: __( 'Editor top bar' ),
@@ -71,12 +73,13 @@ export default function EditorInterface( {
71
73
  nextShortcut,
72
74
  showBlockBreadcrumbs,
73
75
  documentLabel,
74
- blockEditorMode,
76
+ isZoomOut,
75
77
  } = useSelect( ( select ) => {
76
78
  const { get } = select( preferencesStore );
77
79
  const { getEditorSettings, getPostTypeLabel } = select( editorStore );
78
80
  const editorSettings = getEditorSettings();
79
81
  const postTypeLabel = getPostTypeLabel();
82
+ const { isZoomOut: _isZoomOut } = unlock( select( blockEditorStore ) );
80
83
 
81
84
  return {
82
85
  mode: select( editorStore ).getEditorMode(),
@@ -94,8 +97,7 @@ export default function EditorInterface( {
94
97
  showBlockBreadcrumbs: get( 'core', 'showBlockBreadcrumbs' ),
95
98
  // translators: Default label for the Document in the Block Breadcrumb.
96
99
  documentLabel: postTypeLabel || _x( 'Document', 'noun' ),
97
- blockEditorMode:
98
- select( blockEditorStore ).__unstableGetEditorMode(),
100
+ isZoomOut: _isZoomOut(),
99
101
  };
100
102
  }, [] );
101
103
  const isLargeViewport = useViewportMatch( 'medium' );
@@ -206,7 +208,7 @@ export default function EditorInterface( {
206
208
  isLargeViewport &&
207
209
  showBlockBreadcrumbs &&
208
210
  isRichEditingEnabled &&
209
- blockEditorMode !== 'zoom-out' &&
211
+ ! isZoomOut &&
210
212
  mode === 'visual' && (
211
213
  <BlockBreadcrumb rootLabelText={ documentLabel } />
212
214
  )
@@ -128,11 +128,21 @@ export function EntitiesSavedStatesExtensible( {
128
128
  aria-describedby={ renderDialog ? dialogDescription : undefined }
129
129
  >
130
130
  <Flex className="entities-saved-states__panel-header" gap={ 2 }>
131
+ <FlexItem
132
+ isBlock
133
+ as={ Button }
134
+ variant="secondary"
135
+ size="compact"
136
+ onClick={ dismissPanel }
137
+ >
138
+ { __( 'Cancel' ) }
139
+ </FlexItem>
131
140
  <FlexItem
132
141
  isBlock
133
142
  as={ Button }
134
143
  ref={ saveButtonRef }
135
144
  variant="primary"
145
+ size="compact"
136
146
  disabled={ ! saveEnabled }
137
147
  accessibleWhenDisabled
138
148
  onClick={ () =>
@@ -147,14 +157,6 @@ export function EntitiesSavedStatesExtensible( {
147
157
  >
148
158
  { saveLabel }
149
159
  </FlexItem>
150
- <FlexItem
151
- isBlock
152
- as={ Button }
153
- variant="secondary"
154
- onClick={ dismissPanel }
155
- >
156
- { __( 'Cancel' ) }
157
- </FlexItem>
158
160
  </Flex>
159
161
 
160
162
  <div className="entities-saved-states__text-prompt">
@@ -1,8 +1,8 @@
1
1
  .entities-saved-states__panel-header {
2
2
  box-sizing: border-box;
3
3
  background: $white;
4
- padding-left: $grid-unit-10;
5
- padding-right: $grid-unit-10;
4
+ padding-left: $grid-unit-20;
5
+ padding-right: $grid-unit-20;
6
6
  height: $header-height;
7
7
  border-bottom: $border-width solid $gray-300;
8
8
  }
@@ -3,7 +3,6 @@
3
3
  */
4
4
  import { useSelect } from '@wordpress/data';
5
5
  import { __ } from '@wordpress/i18n';
6
- import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
7
6
  import { ComplementaryArea } from '@wordpress/interface';
8
7
 
9
8
  /**
@@ -77,12 +76,9 @@ import { store as editorStore } from '../../store';
77
76
  * ```
78
77
  */
79
78
  export default function PluginSidebar( { className, ...props } ) {
80
- const { postTitle, shortcut } = useSelect( ( select ) => {
79
+ const { postTitle } = useSelect( ( select ) => {
81
80
  return {
82
81
  postTitle: select( editorStore ).getEditedPostAttribute( 'title' ),
83
- shortcut: select(
84
- keyboardShortcutsStore
85
- ).getShortcutRepresentation( 'core/editor/toggle-sidebar' ),
86
82
  };
87
83
  }, [] );
88
84
  return (
@@ -91,7 +87,6 @@ export default function PluginSidebar( { className, ...props } ) {
91
87
  className="editor-sidebar"
92
88
  smallScreenTitle={ postTitle || __( '(no title)' ) }
93
89
  scope="core"
94
- toggleShortcut={ shortcut }
95
90
  { ...props }
96
91
  />
97
92
  );
@@ -98,8 +98,8 @@ function Image( { clientId, alt, url } ) {
98
98
  animate={ { opacity: 1 } }
99
99
  exit={ { opacity: 0, scale: 0 } }
100
100
  style={ {
101
- width: '36px',
102
- height: '36px',
101
+ width: '32px',
102
+ height: '32px',
103
103
  objectFit: 'cover',
104
104
  borderRadius: '2px',
105
105
  cursor: 'pointer',
@@ -256,7 +256,7 @@ export default function MaybeUploadMediaPanel() {
256
256
  <Spinner />
257
257
  ) : (
258
258
  <Button
259
- __next40pxDefaultSize
259
+ size="compact"
260
260
  variant="primary"
261
261
  onClick={ uploadImages }
262
262
  >
@@ -26,7 +26,9 @@ import { ActionItem } from '@wordpress/interface';
26
26
  * Internal dependencies
27
27
  */
28
28
  import { store as editorStore } from '../../store';
29
+ import { store as blockEditorStore } from '@wordpress/block-editor';
29
30
  import PostPreviewButton from '../post-preview-button';
31
+ import { unlock } from '../../lock-unlock';
30
32
 
31
33
  export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {
32
34
  const { deviceType, homeUrl, isTemplate, isViewable, showIconLabels } =
@@ -44,6 +46,14 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {
44
46
  };
45
47
  }, [] );
46
48
  const { setDeviceType } = useDispatch( editorStore );
49
+ const { __unstableSetEditorMode } = useDispatch( blockEditorStore );
50
+ const { resetZoomLevel } = unlock( useDispatch( blockEditorStore ) );
51
+
52
+ const handleDevicePreviewChange = ( newDeviceType ) => {
53
+ setDeviceType( newDeviceType );
54
+ __unstableSetEditorMode( 'edit' );
55
+ resetZoomLevel();
56
+ };
47
57
 
48
58
  const isMobile = useViewportMatch( 'medium', '<' );
49
59
  if ( isMobile ) {
@@ -113,7 +123,7 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {
113
123
  <MenuItemsChoice
114
124
  choices={ choices }
115
125
  value={ deviceType }
116
- onSelect={ setDeviceType }
126
+ onSelect={ handleDevicePreviewChange }
117
127
  />
118
128
  </MenuGroup>
119
129
  { isTemplate && (
@@ -188,26 +188,19 @@ export const ExperimentalEditorProvider = withRegistryProvider(
188
188
  const postContext = {};
189
189
  // If it is a template, try to inherit the post type from the slug.
190
190
  if ( post.type === 'wp_template' ) {
191
- if ( ! post.is_custom ) {
192
- const [ kind ] = post.slug.split( '-' );
193
- switch ( kind ) {
194
- case 'page':
195
- postContext.postType = 'page';
196
- break;
197
- case 'single':
198
- // Infer the post type from the slug.
199
- const postTypesSlugs =
200
- postTypes?.map( ( entity ) => entity.slug ) ||
201
- [];
202
- const match = post.slug.match(
203
- `^single-(${ postTypesSlugs.join(
204
- '|'
205
- ) })(?:-.+)?$`
206
- );
207
- if ( match ) {
208
- postContext.postType = match[ 1 ];
209
- }
210
- break;
191
+ if ( post.slug === 'page' ) {
192
+ postContext.postType = 'page';
193
+ } else if ( post.slug === 'single' ) {
194
+ postContext.postType = 'post';
195
+ } else if ( post.slug.split( '-' )[ 0 ] === 'single' ) {
196
+ // If the slug is single-{postType}, infer the post type from the slug.
197
+ const postTypesSlugs =
198
+ postTypes?.map( ( entity ) => entity.slug ) || [];
199
+ const match = post.slug.match(
200
+ `^single-(${ postTypesSlugs.join( '|' ) })(?:-.+)?$`
201
+ );
202
+ if ( match ) {
203
+ postContext.postType = match[ 1 ];
211
204
  }
212
205
  }
213
206
  } else if (
@@ -174,17 +174,19 @@ function VisualEditor( {
174
174
  hasRootPaddingAwareAlignments,
175
175
  themeHasDisabledLayoutStyles,
176
176
  themeSupportsLayout,
177
- isZoomOutMode,
177
+ isZoomedOut,
178
178
  } = useSelect( ( select ) => {
179
- const { getSettings, __unstableGetEditorMode } =
180
- select( blockEditorStore );
179
+ const { getSettings, isZoomOut: _isZoomOut } = unlock(
180
+ select( blockEditorStore )
181
+ );
182
+
181
183
  const _settings = getSettings();
182
184
  return {
183
185
  themeHasDisabledLayoutStyles: _settings.disableLayoutStyles,
184
186
  themeSupportsLayout: _settings.supportsLayout,
185
187
  hasRootPaddingAwareAlignments:
186
188
  _settings.__experimentalFeatures?.useRootPaddingAwareAlignments,
187
- isZoomOutMode: __unstableGetEditorMode() === 'zoom-out',
189
+ isZoomedOut: _isZoomOut(),
188
190
  };
189
191
  }, [] );
190
192
 
@@ -336,7 +338,7 @@ function VisualEditor( {
336
338
  ] );
337
339
 
338
340
  const zoomOutProps =
339
- isZoomOutMode && ! isTabletViewport
341
+ isZoomedOut && ! isTabletViewport
340
342
  ? {
341
343
  scale: 'default',
342
344
  frameSize: '48px',
@@ -355,7 +357,7 @@ function VisualEditor( {
355
357
  // Disable resizing in mobile viewport.
356
358
  ! isMobileViewport &&
357
359
  // Dsiable resizing in zoomed-out mode.
358
- ! isZoomOutMode;
360
+ ! isZoomedOut;
359
361
  const shouldIframe =
360
362
  ! disableIframe || [ 'Tablet', 'Mobile' ].includes( deviceType );
361
363
 
@@ -7,17 +7,33 @@ import { __ } from '@wordpress/i18n';
7
7
  import { useDispatch, useSelect } from '@wordpress/data';
8
8
  import { store as blockEditorStore } from '@wordpress/block-editor';
9
9
  import { square as zoomOutIcon } from '@wordpress/icons';
10
+ import { store as preferencesStore } from '@wordpress/preferences';
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import { unlock } from '../../lock-unlock';
10
16
 
11
17
  const ZoomOutToggle = () => {
12
- const { isZoomOutMode } = useSelect( ( select ) => ( {
13
- isZoomOutMode:
14
- select( blockEditorStore ).__unstableGetEditorMode() === 'zoom-out',
18
+ const { isZoomOut, showIconLabels } = useSelect( ( select ) => ( {
19
+ isZoomOut: unlock( select( blockEditorStore ) ).isZoomOut(),
20
+ showIconLabels: select( preferencesStore ).get(
21
+ 'core',
22
+ 'showIconLabels'
23
+ ),
15
24
  } ) );
16
25
 
17
- const { __unstableSetEditorMode } = useDispatch( blockEditorStore );
26
+ const { resetZoomLevel, setZoomLevel, __unstableSetEditorMode } = unlock(
27
+ useDispatch( blockEditorStore )
28
+ );
18
29
 
19
30
  const handleZoomOut = () => {
20
- __unstableSetEditorMode( isZoomOutMode ? 'edit' : 'zoom-out' );
31
+ if ( isZoomOut ) {
32
+ resetZoomLevel();
33
+ } else {
34
+ setZoomLevel( 50 );
35
+ }
36
+ __unstableSetEditorMode( isZoomOut ? 'edit' : 'zoom-out' );
21
37
  };
22
38
 
23
39
  return (
@@ -25,8 +41,9 @@ const ZoomOutToggle = () => {
25
41
  onClick={ handleZoomOut }
26
42
  icon={ zoomOutIcon }
27
43
  label={ __( 'Toggle Zoom Out' ) }
28
- isPressed={ isZoomOutMode }
44
+ isPressed={ isZoomOut }
29
45
  size="compact"
46
+ showTooltip={ ! showIconLabels }
30
47
  />
31
48
  );
32
49
  };