@wordpress/editor 14.8.4 → 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.
- package/build/bindings/post-meta.js +64 -42
- package/build/bindings/post-meta.js.map +1 -1
- package/build/components/entities-saved-states/index.js +8 -6
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-upload-media.js +3 -3
- package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build/components/preview-dropdown/index.js +5 -0
- package/build/components/preview-dropdown/index.js.map +1 -1
- package/build/components/provider/index.js +10 -14
- package/build/components/provider/index.js.map +1 -1
- package/build/components/zoom-out-toggle/index.js +7 -3
- package/build/components/zoom-out-toggle/index.js.map +1 -1
- package/build/store/actions.js +15 -4
- package/build/store/actions.js.map +1 -1
- package/build-module/bindings/post-meta.js +65 -42
- package/build-module/bindings/post-meta.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +8 -6
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-upload-media.js +3 -3
- package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js +5 -0
- package/build-module/components/preview-dropdown/index.js.map +1 -1
- package/build-module/components/provider/index.js +10 -14
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/zoom-out-toggle/index.js +7 -3
- package/build-module/components/zoom-out-toggle/index.js.map +1 -1
- package/build-module/store/actions.js +16 -5
- package/build-module/store/actions.js.map +1 -1
- package/build-style/style-rtl.css +2 -2
- package/build-style/style.css +2 -2
- package/build-types/bindings/post-meta.d.ts +3 -8
- package/build-types/bindings/post-meta.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/index.d.ts.map +1 -1
- package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/build-types/components/zoom-out-toggle/index.d.ts.map +1 -1
- package/build-types/store/actions.d.ts.map +1 -1
- package/package.json +30 -30
- package/src/bindings/post-meta.js +73 -65
- package/src/components/entities-saved-states/index.js +10 -8
- package/src/components/entities-saved-states/style.scss +2 -2
- package/src/components/post-publish-panel/maybe-upload-media.js +3 -3
- package/src/components/preview-dropdown/index.js +3 -0
- package/src/components/provider/index.js +13 -20
- package/src/components/zoom-out-toggle/index.js +7 -1
- package/src/store/actions.js +26 -11
- package/tsconfig.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/editor",
|
|
3
|
-
"version": "14.8.
|
|
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.
|
|
36
|
-
"@wordpress/api-fetch": "^7.8.
|
|
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.
|
|
39
|
-
"@wordpress/blocks": "^13.8.
|
|
40
|
-
"@wordpress/commands": "^1.8.
|
|
41
|
-
"@wordpress/components": "^28.8.
|
|
42
|
-
"@wordpress/compose": "^7.8.
|
|
43
|
-
"@wordpress/core-data": "^7.8.
|
|
44
|
-
"@wordpress/data": "^10.8.
|
|
45
|
-
"@wordpress/dataviews": "^4.4.
|
|
46
|
-
"@wordpress/date": "^5.8.
|
|
47
|
-
"@wordpress/deprecated": "^4.8.
|
|
48
|
-
"@wordpress/dom": "^4.8.
|
|
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.
|
|
51
|
-
"@wordpress/hooks": "^4.8.
|
|
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.
|
|
54
|
-
"@wordpress/icons": "^10.8.
|
|
55
|
-
"@wordpress/interface": "^6.8.
|
|
56
|
-
"@wordpress/keyboard-shortcuts": "^5.8.
|
|
57
|
-
"@wordpress/keycodes": "^4.8.
|
|
58
|
-
"@wordpress/media-utils": "^5.8.
|
|
59
|
-
"@wordpress/notices": "^5.8.
|
|
60
|
-
"@wordpress/patterns": "^2.8.
|
|
61
|
-
"@wordpress/plugins": "^7.8.
|
|
62
|
-
"@wordpress/preferences": "^4.8.
|
|
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.
|
|
65
|
-
"@wordpress/rich-text": "^7.8.
|
|
66
|
-
"@wordpress/server-side-render": "^5.8.
|
|
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": "
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
46
|
+
entityMetaValues = getEditedEntityRecord(
|
|
19
47
|
'postType',
|
|
20
48
|
context?.postType,
|
|
21
49
|
context?.postId
|
|
22
50
|
).meta;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
|
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
|
|
50
|
-
|
|
51
|
-
metaFields?.[
|
|
52
|
-
|
|
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( {
|
|
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 ||
|
|
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
|
-
|
|
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 )
|
|
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 =
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
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
|
};
|
|
@@ -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-
|
|
5
|
-
padding-right: $grid-unit-
|
|
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
|
}
|
|
@@ -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: '
|
|
102
|
-
height: '
|
|
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
|
-
|
|
259
|
+
size="compact"
|
|
260
260
|
variant="primary"
|
|
261
261
|
onClick={ uploadImages }
|
|
262
262
|
>
|
|
@@ -28,6 +28,7 @@ import { ActionItem } from '@wordpress/interface';
|
|
|
28
28
|
import { store as editorStore } from '../../store';
|
|
29
29
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
30
30
|
import PostPreviewButton from '../post-preview-button';
|
|
31
|
+
import { unlock } from '../../lock-unlock';
|
|
31
32
|
|
|
32
33
|
export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {
|
|
33
34
|
const { deviceType, homeUrl, isTemplate, isViewable, showIconLabels } =
|
|
@@ -46,10 +47,12 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {
|
|
|
46
47
|
}, [] );
|
|
47
48
|
const { setDeviceType } = useDispatch( editorStore );
|
|
48
49
|
const { __unstableSetEditorMode } = useDispatch( blockEditorStore );
|
|
50
|
+
const { resetZoomLevel } = unlock( useDispatch( blockEditorStore ) );
|
|
49
51
|
|
|
50
52
|
const handleDevicePreviewChange = ( newDeviceType ) => {
|
|
51
53
|
setDeviceType( newDeviceType );
|
|
52
54
|
__unstableSetEditorMode( 'edit' );
|
|
55
|
+
resetZoomLevel();
|
|
53
56
|
};
|
|
54
57
|
|
|
55
58
|
const isMobile = useViewportMatch( 'medium', '<' );
|
|
@@ -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 (
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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 (
|
|
@@ -7,6 +7,7 @@ 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';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Internal dependencies
|
|
@@ -14,8 +15,12 @@ import { square as zoomOutIcon } from '@wordpress/icons';
|
|
|
14
15
|
import { unlock } from '../../lock-unlock';
|
|
15
16
|
|
|
16
17
|
const ZoomOutToggle = () => {
|
|
17
|
-
const { isZoomOut } = useSelect( ( select ) => ( {
|
|
18
|
+
const { isZoomOut, showIconLabels } = useSelect( ( select ) => ( {
|
|
18
19
|
isZoomOut: unlock( select( blockEditorStore ) ).isZoomOut(),
|
|
20
|
+
showIconLabels: select( preferencesStore ).get(
|
|
21
|
+
'core',
|
|
22
|
+
'showIconLabels'
|
|
23
|
+
),
|
|
19
24
|
} ) );
|
|
20
25
|
|
|
21
26
|
const { resetZoomLevel, setZoomLevel, __unstableSetEditorMode } = unlock(
|
|
@@ -38,6 +43,7 @@ const ZoomOutToggle = () => {
|
|
|
38
43
|
label={ __( 'Toggle Zoom Out' ) }
|
|
39
44
|
isPressed={ isZoomOut }
|
|
40
45
|
size="compact"
|
|
46
|
+
showTooltip={ ! showIconLabels }
|
|
41
47
|
/>
|
|
42
48
|
);
|
|
43
49
|
};
|
package/src/store/actions.js
CHANGED
|
@@ -12,7 +12,11 @@ import {
|
|
|
12
12
|
import { store as noticesStore } from '@wordpress/notices';
|
|
13
13
|
import { store as coreStore } from '@wordpress/core-data';
|
|
14
14
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
applyFilters,
|
|
17
|
+
applyFiltersAsync,
|
|
18
|
+
doActionAsync,
|
|
19
|
+
} from '@wordpress/hooks';
|
|
16
20
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
17
21
|
import { __ } from '@wordpress/i18n';
|
|
18
22
|
|
|
@@ -184,7 +188,7 @@ export const savePost =
|
|
|
184
188
|
}
|
|
185
189
|
|
|
186
190
|
const previousRecord = select.getCurrentPost();
|
|
187
|
-
|
|
191
|
+
let edits = {
|
|
188
192
|
id: previousRecord.id,
|
|
189
193
|
...registry
|
|
190
194
|
.select( coreStore )
|
|
@@ -199,9 +203,9 @@ export const savePost =
|
|
|
199
203
|
|
|
200
204
|
let error = false;
|
|
201
205
|
try {
|
|
202
|
-
|
|
203
|
-
'editor.
|
|
204
|
-
|
|
206
|
+
edits = await applyFiltersAsync(
|
|
207
|
+
'editor.preSavePost',
|
|
208
|
+
edits,
|
|
205
209
|
options
|
|
206
210
|
);
|
|
207
211
|
} catch ( err ) {
|
|
@@ -236,14 +240,25 @@ export const savePost =
|
|
|
236
240
|
);
|
|
237
241
|
}
|
|
238
242
|
|
|
243
|
+
// Run the hook with legacy unstable name for backward compatibility
|
|
239
244
|
if ( ! error ) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
+
try {
|
|
246
|
+
await applyFilters(
|
|
247
|
+
'editor.__unstableSavePost',
|
|
248
|
+
Promise.resolve(),
|
|
249
|
+
options
|
|
250
|
+
);
|
|
251
|
+
} catch ( err ) {
|
|
245
252
|
error = err;
|
|
246
|
-
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if ( ! error ) {
|
|
257
|
+
try {
|
|
258
|
+
await doActionAsync( 'editor.savePost', options );
|
|
259
|
+
} catch ( err ) {
|
|
260
|
+
error = err;
|
|
261
|
+
}
|
|
247
262
|
}
|
|
248
263
|
dispatch( { type: 'REQUEST_POST_UPDATE_FINISH', options } );
|
|
249
264
|
|