@wordpress/editor 13.9.0 → 13.10.0
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/CHANGELOG.md +2 -0
- package/build/components/entities-saved-states/index.js +47 -6
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/post-featured-image/index.js +24 -29
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-saved-state/index.js +0 -8
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-switch-to-draft-button/index.js +9 -4
- package/build/components/post-switch-to-draft-button/index.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +48 -7
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/post-featured-image/index.js +26 -32
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +0 -7
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-switch-to-draft-button/index.js +12 -7
- package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
- package/build-style/style-rtl.css +37 -15
- package/build-style/style.css +37 -15
- package/package.json +30 -30
- package/src/components/entities-saved-states/index.js +57 -15
- package/src/components/post-featured-image/index.js +26 -35
- package/src/components/post-featured-image/style.scss +38 -14
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +1 -1
- package/src/components/post-saved-state/index.js +0 -7
- package/src/components/post-saved-state/test/__snapshots__/index.js.snap +0 -9
- package/src/components/post-saved-state/test/index.js +0 -10
- package/src/components/post-switch-to-draft-button/index.js +7 -6
- package/src/components/post-taxonomies/style.scss +4 -4
- package/src/components/post-trash/style.scss +1 -3
|
@@ -282,10 +282,6 @@
|
|
|
282
282
|
.editor-post-featured-image {
|
|
283
283
|
padding: 0;
|
|
284
284
|
}
|
|
285
|
-
.editor-post-featured-image__container {
|
|
286
|
-
margin-bottom: 1em;
|
|
287
|
-
position: relative;
|
|
288
|
-
}
|
|
289
285
|
.editor-post-featured-image .components-spinner {
|
|
290
286
|
position: absolute;
|
|
291
287
|
top: 50%;
|
|
@@ -293,22 +289,28 @@
|
|
|
293
289
|
margin-top: -9px;
|
|
294
290
|
margin-right: -9px;
|
|
295
291
|
}
|
|
296
|
-
.editor-post-featured-image .components-button + .components-button {
|
|
297
|
-
display: block;
|
|
298
|
-
margin-top: 1em;
|
|
299
|
-
}
|
|
300
292
|
.editor-post-featured-image .components-responsive-wrapper__content {
|
|
301
293
|
max-width: 100%;
|
|
302
294
|
width: auto;
|
|
303
295
|
}
|
|
304
296
|
|
|
297
|
+
.editor-post-featured-image__container {
|
|
298
|
+
position: relative;
|
|
299
|
+
}
|
|
300
|
+
.editor-post-featured-image__container:hover .editor-post-featured-image__actions, .editor-post-featured-image__container:focus .editor-post-featured-image__actions, .editor-post-featured-image__container:focus-within .editor-post-featured-image__actions {
|
|
301
|
+
opacity: 1;
|
|
302
|
+
}
|
|
303
|
+
|
|
305
304
|
.editor-post-featured-image__toggle,
|
|
306
305
|
.editor-post-featured-image__preview {
|
|
307
|
-
display: block;
|
|
308
306
|
width: 100%;
|
|
309
307
|
padding: 0;
|
|
310
308
|
transition: all 0.1s ease-out;
|
|
311
309
|
box-shadow: 0 0 0 0 var(--wp-admin-theme-color);
|
|
310
|
+
overflow: hidden;
|
|
311
|
+
display: flex;
|
|
312
|
+
justify-content: center;
|
|
313
|
+
max-height: 150px;
|
|
312
314
|
}
|
|
313
315
|
@media (prefers-reduced-motion: reduce) {
|
|
314
316
|
.editor-post-featured-image__toggle,
|
|
@@ -321,9 +323,9 @@
|
|
|
321
323
|
.editor-post-featured-image__preview {
|
|
322
324
|
height: auto;
|
|
323
325
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
326
|
+
.editor-post-featured-image__preview .components-responsive-wrapper {
|
|
327
|
+
width: 100%;
|
|
328
|
+
background: #f0f0f0;
|
|
327
329
|
}
|
|
328
330
|
|
|
329
331
|
.editor-post-featured-image__toggle {
|
|
@@ -339,6 +341,28 @@
|
|
|
339
341
|
color: #1e1e1e;
|
|
340
342
|
}
|
|
341
343
|
|
|
344
|
+
.editor-post-featured-image__actions {
|
|
345
|
+
bottom: 0;
|
|
346
|
+
opacity: 0;
|
|
347
|
+
padding: 8px;
|
|
348
|
+
position: absolute;
|
|
349
|
+
transition: opacity 50ms ease-out;
|
|
350
|
+
}
|
|
351
|
+
@media (prefers-reduced-motion: reduce) {
|
|
352
|
+
.editor-post-featured-image__actions {
|
|
353
|
+
transition-duration: 0s;
|
|
354
|
+
transition-delay: 0s;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.editor-post-featured-image__action {
|
|
359
|
+
-webkit-backdrop-filter: blur(16px) saturate(180%);
|
|
360
|
+
backdrop-filter: blur(16px) saturate(180%);
|
|
361
|
+
background: rgba(255, 255, 255, 0.75);
|
|
362
|
+
flex-grow: 1;
|
|
363
|
+
justify-content: center;
|
|
364
|
+
}
|
|
365
|
+
|
|
342
366
|
[class].editor-post-format__suggestion {
|
|
343
367
|
margin: 4px 0 0 0;
|
|
344
368
|
}
|
|
@@ -833,10 +857,8 @@
|
|
|
833
857
|
}
|
|
834
858
|
|
|
835
859
|
.editor-post-trash.components-button {
|
|
836
|
-
display: flex;
|
|
837
|
-
justify-content: center;
|
|
838
|
-
margin-top: 4px;
|
|
839
860
|
width: 100%;
|
|
861
|
+
display: block;
|
|
840
862
|
}
|
|
841
863
|
|
|
842
864
|
.table-of-contents__popover.components-popover .components-popover__content {
|
package/build-style/style.css
CHANGED
|
@@ -282,10 +282,6 @@
|
|
|
282
282
|
.editor-post-featured-image {
|
|
283
283
|
padding: 0;
|
|
284
284
|
}
|
|
285
|
-
.editor-post-featured-image__container {
|
|
286
|
-
margin-bottom: 1em;
|
|
287
|
-
position: relative;
|
|
288
|
-
}
|
|
289
285
|
.editor-post-featured-image .components-spinner {
|
|
290
286
|
position: absolute;
|
|
291
287
|
top: 50%;
|
|
@@ -293,22 +289,28 @@
|
|
|
293
289
|
margin-top: -9px;
|
|
294
290
|
margin-left: -9px;
|
|
295
291
|
}
|
|
296
|
-
.editor-post-featured-image .components-button + .components-button {
|
|
297
|
-
display: block;
|
|
298
|
-
margin-top: 1em;
|
|
299
|
-
}
|
|
300
292
|
.editor-post-featured-image .components-responsive-wrapper__content {
|
|
301
293
|
max-width: 100%;
|
|
302
294
|
width: auto;
|
|
303
295
|
}
|
|
304
296
|
|
|
297
|
+
.editor-post-featured-image__container {
|
|
298
|
+
position: relative;
|
|
299
|
+
}
|
|
300
|
+
.editor-post-featured-image__container:hover .editor-post-featured-image__actions, .editor-post-featured-image__container:focus .editor-post-featured-image__actions, .editor-post-featured-image__container:focus-within .editor-post-featured-image__actions {
|
|
301
|
+
opacity: 1;
|
|
302
|
+
}
|
|
303
|
+
|
|
305
304
|
.editor-post-featured-image__toggle,
|
|
306
305
|
.editor-post-featured-image__preview {
|
|
307
|
-
display: block;
|
|
308
306
|
width: 100%;
|
|
309
307
|
padding: 0;
|
|
310
308
|
transition: all 0.1s ease-out;
|
|
311
309
|
box-shadow: 0 0 0 0 var(--wp-admin-theme-color);
|
|
310
|
+
overflow: hidden;
|
|
311
|
+
display: flex;
|
|
312
|
+
justify-content: center;
|
|
313
|
+
max-height: 150px;
|
|
312
314
|
}
|
|
313
315
|
@media (prefers-reduced-motion: reduce) {
|
|
314
316
|
.editor-post-featured-image__toggle,
|
|
@@ -321,9 +323,9 @@
|
|
|
321
323
|
.editor-post-featured-image__preview {
|
|
322
324
|
height: auto;
|
|
323
325
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
326
|
+
.editor-post-featured-image__preview .components-responsive-wrapper {
|
|
327
|
+
width: 100%;
|
|
328
|
+
background: #f0f0f0;
|
|
327
329
|
}
|
|
328
330
|
|
|
329
331
|
.editor-post-featured-image__toggle {
|
|
@@ -339,6 +341,28 @@
|
|
|
339
341
|
color: #1e1e1e;
|
|
340
342
|
}
|
|
341
343
|
|
|
344
|
+
.editor-post-featured-image__actions {
|
|
345
|
+
bottom: 0;
|
|
346
|
+
opacity: 0;
|
|
347
|
+
padding: 8px;
|
|
348
|
+
position: absolute;
|
|
349
|
+
transition: opacity 50ms ease-out;
|
|
350
|
+
}
|
|
351
|
+
@media (prefers-reduced-motion: reduce) {
|
|
352
|
+
.editor-post-featured-image__actions {
|
|
353
|
+
transition-duration: 0s;
|
|
354
|
+
transition-delay: 0s;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.editor-post-featured-image__action {
|
|
359
|
+
-webkit-backdrop-filter: blur(16px) saturate(180%);
|
|
360
|
+
backdrop-filter: blur(16px) saturate(180%);
|
|
361
|
+
background: rgba(255, 255, 255, 0.75);
|
|
362
|
+
flex-grow: 1;
|
|
363
|
+
justify-content: center;
|
|
364
|
+
}
|
|
365
|
+
|
|
342
366
|
[class].editor-post-format__suggestion {
|
|
343
367
|
margin: 4px 0 0 0;
|
|
344
368
|
}
|
|
@@ -837,10 +861,8 @@
|
|
|
837
861
|
}
|
|
838
862
|
|
|
839
863
|
.editor-post-trash.components-button {
|
|
840
|
-
display: flex;
|
|
841
|
-
justify-content: center;
|
|
842
|
-
margin-top: 4px;
|
|
843
864
|
width: 100%;
|
|
865
|
+
display: block;
|
|
844
866
|
}
|
|
845
867
|
|
|
846
868
|
.table-of-contents__popover.components-popover .components-popover__content {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/editor",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.10.0",
|
|
4
4
|
"description": "Enhanced block editor for WordPress posts.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -31,34 +31,34 @@
|
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.16.0",
|
|
34
|
-
"@wordpress/a11y": "^3.
|
|
35
|
-
"@wordpress/api-fetch": "^6.
|
|
36
|
-
"@wordpress/blob": "^3.
|
|
37
|
-
"@wordpress/block-editor": "^12.
|
|
38
|
-
"@wordpress/blocks": "^12.
|
|
39
|
-
"@wordpress/components": "^
|
|
40
|
-
"@wordpress/compose": "^6.
|
|
41
|
-
"@wordpress/core-data": "^6.
|
|
42
|
-
"@wordpress/data": "^9.
|
|
43
|
-
"@wordpress/date": "^4.
|
|
44
|
-
"@wordpress/deprecated": "^3.
|
|
45
|
-
"@wordpress/dom": "^3.
|
|
46
|
-
"@wordpress/element": "^5.
|
|
47
|
-
"@wordpress/hooks": "^3.
|
|
48
|
-
"@wordpress/html-entities": "^3.
|
|
49
|
-
"@wordpress/i18n": "^4.
|
|
50
|
-
"@wordpress/icons": "^9.
|
|
51
|
-
"@wordpress/keyboard-shortcuts": "^4.
|
|
52
|
-
"@wordpress/keycodes": "^3.
|
|
53
|
-
"@wordpress/media-utils": "^4.
|
|
54
|
-
"@wordpress/notices": "^4.
|
|
55
|
-
"@wordpress/preferences": "^3.
|
|
56
|
-
"@wordpress/private-apis": "^0.
|
|
57
|
-
"@wordpress/reusable-blocks": "^4.
|
|
58
|
-
"@wordpress/rich-text": "^6.
|
|
59
|
-
"@wordpress/server-side-render": "^4.
|
|
60
|
-
"@wordpress/url": "^3.
|
|
61
|
-
"@wordpress/wordcount": "^3.
|
|
34
|
+
"@wordpress/a11y": "^3.33.0",
|
|
35
|
+
"@wordpress/api-fetch": "^6.30.0",
|
|
36
|
+
"@wordpress/blob": "^3.33.0",
|
|
37
|
+
"@wordpress/block-editor": "^12.1.0",
|
|
38
|
+
"@wordpress/blocks": "^12.10.0",
|
|
39
|
+
"@wordpress/components": "^24.0.0",
|
|
40
|
+
"@wordpress/compose": "^6.10.0",
|
|
41
|
+
"@wordpress/core-data": "^6.10.0",
|
|
42
|
+
"@wordpress/data": "^9.3.0",
|
|
43
|
+
"@wordpress/date": "^4.33.0",
|
|
44
|
+
"@wordpress/deprecated": "^3.33.0",
|
|
45
|
+
"@wordpress/dom": "^3.33.0",
|
|
46
|
+
"@wordpress/element": "^5.10.0",
|
|
47
|
+
"@wordpress/hooks": "^3.33.0",
|
|
48
|
+
"@wordpress/html-entities": "^3.33.0",
|
|
49
|
+
"@wordpress/i18n": "^4.33.0",
|
|
50
|
+
"@wordpress/icons": "^9.24.0",
|
|
51
|
+
"@wordpress/keyboard-shortcuts": "^4.10.0",
|
|
52
|
+
"@wordpress/keycodes": "^3.33.0",
|
|
53
|
+
"@wordpress/media-utils": "^4.24.0",
|
|
54
|
+
"@wordpress/notices": "^4.1.0",
|
|
55
|
+
"@wordpress/preferences": "^3.10.0",
|
|
56
|
+
"@wordpress/private-apis": "^0.15.0",
|
|
57
|
+
"@wordpress/reusable-blocks": "^4.10.0",
|
|
58
|
+
"@wordpress/rich-text": "^6.10.0",
|
|
59
|
+
"@wordpress/server-side-render": "^4.10.0",
|
|
60
|
+
"@wordpress/url": "^3.34.0",
|
|
61
|
+
"@wordpress/wordcount": "^3.33.0",
|
|
62
62
|
"classnames": "^2.3.1",
|
|
63
63
|
"date-fns": "^2.28.0",
|
|
64
64
|
"escape-html": "^1.0.3",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "e936127e1e13881f1a940b7bd1593a9e500147f3"
|
|
78
78
|
}
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { Button, Flex, FlexItem } from '@wordpress/components';
|
|
5
|
-
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
6
6
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
7
|
import { useState, useCallback, useRef } from '@wordpress/element';
|
|
8
8
|
import { store as coreStore } from '@wordpress/core-data';
|
|
9
9
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
10
10
|
import { __experimentalUseDialog as useDialog } from '@wordpress/compose';
|
|
11
11
|
import { store as noticesStore } from '@wordpress/notices';
|
|
12
|
+
import { getQueryArg } from '@wordpress/url';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Internal dependencies
|
|
@@ -31,8 +32,28 @@ const PUBLISH_ON_SAVE_ENTITIES = [
|
|
|
31
32
|
},
|
|
32
33
|
];
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
function identity( values ) {
|
|
36
|
+
return values;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function isPreviewingTheme() {
|
|
40
|
+
return (
|
|
41
|
+
window?.__experimentalEnableThemePreviews &&
|
|
42
|
+
getQueryArg( window.location.href, 'theme_preview' ) !== undefined
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function currentlyPreviewingTheme() {
|
|
47
|
+
if ( isPreviewingTheme() ) {
|
|
48
|
+
return getQueryArg( window.location.href, 'theme_preview' );
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default function EntitiesSavedStates( { close, onSave = identity } ) {
|
|
35
54
|
const saveButtonRef = useRef();
|
|
55
|
+
const { getTheme } = useSelect( coreStore );
|
|
56
|
+
const theme = getTheme( currentlyPreviewingTheme() );
|
|
36
57
|
const { dirtyEntityRecords } = useSelect( ( select ) => {
|
|
37
58
|
const dirtyRecords =
|
|
38
59
|
select( coreStore ).__experimentalGetDirtyEntityRecords();
|
|
@@ -126,7 +147,7 @@ export default function EntitiesSavedStates( { close } ) {
|
|
|
126
147
|
}
|
|
127
148
|
};
|
|
128
149
|
|
|
129
|
-
const
|
|
150
|
+
const saveCheckedEntitiesAndActivate = () => {
|
|
130
151
|
const entitiesToSave = dirtyEntityRecords.filter(
|
|
131
152
|
( { kind, name, key, property } ) => {
|
|
132
153
|
return ! unselectedEntities.some(
|
|
@@ -176,6 +197,9 @@ export default function EntitiesSavedStates( { close } ) {
|
|
|
176
197
|
__unstableMarkLastChangeAsPersistent();
|
|
177
198
|
|
|
178
199
|
Promise.all( pendingSavedRecords )
|
|
200
|
+
.then( ( values ) => {
|
|
201
|
+
return onSave( values );
|
|
202
|
+
} )
|
|
179
203
|
.then( ( values ) => {
|
|
180
204
|
if (
|
|
181
205
|
values.some( ( value ) => typeof value === 'undefined' )
|
|
@@ -200,6 +224,18 @@ export default function EntitiesSavedStates( { close } ) {
|
|
|
200
224
|
onClose: () => dismissPanel(),
|
|
201
225
|
} );
|
|
202
226
|
|
|
227
|
+
const isDirty = dirtyEntityRecords.length - unselectedEntities.length > 0;
|
|
228
|
+
const activateSaveEnabled = isPreviewingTheme() || isDirty;
|
|
229
|
+
|
|
230
|
+
let activateSaveLabel;
|
|
231
|
+
if ( isPreviewingTheme() && isDirty ) {
|
|
232
|
+
activateSaveLabel = __( 'Activate & Save' );
|
|
233
|
+
} else if ( isPreviewingTheme() ) {
|
|
234
|
+
activateSaveLabel = __( 'Activate' );
|
|
235
|
+
} else {
|
|
236
|
+
activateSaveLabel = __( 'Save' );
|
|
237
|
+
}
|
|
238
|
+
|
|
203
239
|
return (
|
|
204
240
|
<div
|
|
205
241
|
ref={ saveDialogRef }
|
|
@@ -212,15 +248,11 @@ export default function EntitiesSavedStates( { close } ) {
|
|
|
212
248
|
as={ Button }
|
|
213
249
|
ref={ saveButtonRef }
|
|
214
250
|
variant="primary"
|
|
215
|
-
disabled={
|
|
216
|
-
|
|
217
|
-
unselectedEntities.length ===
|
|
218
|
-
0
|
|
219
|
-
}
|
|
220
|
-
onClick={ saveCheckedEntities }
|
|
251
|
+
disabled={ ! activateSaveEnabled }
|
|
252
|
+
onClick={ saveCheckedEntitiesAndActivate }
|
|
221
253
|
className="editor-entities-saved-states__save-button"
|
|
222
254
|
>
|
|
223
|
-
{
|
|
255
|
+
{ activateSaveLabel }
|
|
224
256
|
</FlexItem>
|
|
225
257
|
<FlexItem
|
|
226
258
|
isBlock
|
|
@@ -234,11 +266,21 @@ export default function EntitiesSavedStates( { close } ) {
|
|
|
234
266
|
|
|
235
267
|
<div className="entities-saved-states__text-prompt">
|
|
236
268
|
<strong>{ __( 'Are you ready to save?' ) }</strong>
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
269
|
+
{ isPreviewingTheme() && (
|
|
270
|
+
<p>
|
|
271
|
+
{ sprintf(
|
|
272
|
+
'Saving your changes will change your active theme to %1$s.',
|
|
273
|
+
theme?.name?.rendered
|
|
274
|
+
) }
|
|
275
|
+
</p>
|
|
276
|
+
) }
|
|
277
|
+
{ isDirty && (
|
|
278
|
+
<p>
|
|
279
|
+
{ __(
|
|
280
|
+
'The following changes have been made to your site, templates, and content.'
|
|
281
|
+
) }
|
|
282
|
+
</p>
|
|
283
|
+
) }
|
|
242
284
|
</div>
|
|
243
285
|
|
|
244
286
|
{ sortedPartitionedSavables.map( ( list ) => {
|
|
@@ -10,9 +10,10 @@ import {
|
|
|
10
10
|
ResponsiveWrapper,
|
|
11
11
|
withNotices,
|
|
12
12
|
withFilters,
|
|
13
|
+
__experimentalHStack as HStack,
|
|
13
14
|
} from '@wordpress/components';
|
|
14
15
|
import { isBlobURL } from '@wordpress/blob';
|
|
15
|
-
import { useState } from '@wordpress/element';
|
|
16
|
+
import { useState, useRef } from '@wordpress/element';
|
|
16
17
|
import { compose } from '@wordpress/compose';
|
|
17
18
|
import { useSelect, withDispatch, withSelect } from '@wordpress/data';
|
|
18
19
|
import {
|
|
@@ -33,7 +34,6 @@ const ALLOWED_MEDIA_TYPES = [ 'image' ];
|
|
|
33
34
|
// Used when labels from post type were not yet loaded or when they are not present.
|
|
34
35
|
const DEFAULT_FEATURE_IMAGE_LABEL = __( 'Featured image' );
|
|
35
36
|
const DEFAULT_SET_FEATURE_IMAGE_LABEL = __( 'Set featured image' );
|
|
36
|
-
const DEFAULT_REMOVE_FEATURE_IMAGE_LABEL = __( 'Remove image' );
|
|
37
37
|
|
|
38
38
|
const instructions = (
|
|
39
39
|
<p>
|
|
@@ -96,6 +96,7 @@ function PostFeaturedImage( {
|
|
|
96
96
|
noticeUI,
|
|
97
97
|
noticeOperations,
|
|
98
98
|
} ) {
|
|
99
|
+
const toggleRef = useRef();
|
|
99
100
|
const [ isLoading, setIsLoading ] = useState( false );
|
|
100
101
|
const mediaUpload = useSelect( ( select ) => {
|
|
101
102
|
return select( blockEditorStore ).getSettings().mediaUpload;
|
|
@@ -163,6 +164,7 @@ function PostFeaturedImage( {
|
|
|
163
164
|
render={ ( { open } ) => (
|
|
164
165
|
<div className="editor-post-featured-image__container">
|
|
165
166
|
<Button
|
|
167
|
+
ref={ toggleRef }
|
|
166
168
|
className={
|
|
167
169
|
! featuredImageId
|
|
168
170
|
? 'editor-post-featured-image__toggle'
|
|
@@ -172,7 +174,7 @@ function PostFeaturedImage( {
|
|
|
172
174
|
aria-label={
|
|
173
175
|
! featuredImageId
|
|
174
176
|
? null
|
|
175
|
-
: __( 'Edit or
|
|
177
|
+
: __( 'Edit or replace the image' )
|
|
176
178
|
}
|
|
177
179
|
aria-describedby={
|
|
178
180
|
! featuredImageId
|
|
@@ -199,44 +201,33 @@ function PostFeaturedImage( {
|
|
|
199
201
|
?.set_featured_image ||
|
|
200
202
|
DEFAULT_SET_FEATURE_IMAGE_LABEL ) }
|
|
201
203
|
</Button>
|
|
204
|
+
{ !! featuredImageId && (
|
|
205
|
+
<HStack className="editor-post-featured-image__actions">
|
|
206
|
+
<Button
|
|
207
|
+
className="editor-post-featured-image__action"
|
|
208
|
+
onClick={ open }
|
|
209
|
+
// Prefer that screen readers use the .editor-post-featured-image__preview button.
|
|
210
|
+
aria-hidden="true"
|
|
211
|
+
>
|
|
212
|
+
{ __( 'Replace' ) }
|
|
213
|
+
</Button>
|
|
214
|
+
<Button
|
|
215
|
+
className="editor-post-featured-image__action"
|
|
216
|
+
onClick={ () => {
|
|
217
|
+
onRemoveImage();
|
|
218
|
+
toggleRef.current.focus();
|
|
219
|
+
} }
|
|
220
|
+
>
|
|
221
|
+
{ __( 'Remove' ) }
|
|
222
|
+
</Button>
|
|
223
|
+
</HStack>
|
|
224
|
+
) }
|
|
202
225
|
<DropZone onFilesDrop={ onDropFiles } />
|
|
203
226
|
</div>
|
|
204
227
|
) }
|
|
205
228
|
value={ featuredImageId }
|
|
206
229
|
/>
|
|
207
230
|
</MediaUploadCheck>
|
|
208
|
-
{ !! featuredImageId && (
|
|
209
|
-
<MediaUploadCheck>
|
|
210
|
-
{ media && (
|
|
211
|
-
<MediaUpload
|
|
212
|
-
title={
|
|
213
|
-
postType?.labels?.featured_image ||
|
|
214
|
-
DEFAULT_FEATURE_IMAGE_LABEL
|
|
215
|
-
}
|
|
216
|
-
onSelect={ onUpdateImage }
|
|
217
|
-
unstableFeaturedImageFlow
|
|
218
|
-
allowedTypes={ ALLOWED_MEDIA_TYPES }
|
|
219
|
-
modalClass="editor-post-featured-image__media-modal"
|
|
220
|
-
render={ ( { open } ) => (
|
|
221
|
-
<Button
|
|
222
|
-
onClick={ open }
|
|
223
|
-
variant="secondary"
|
|
224
|
-
>
|
|
225
|
-
{ __( 'Replace Image' ) }
|
|
226
|
-
</Button>
|
|
227
|
-
) }
|
|
228
|
-
/>
|
|
229
|
-
) }
|
|
230
|
-
<Button
|
|
231
|
-
onClick={ onRemoveImage }
|
|
232
|
-
variant="link"
|
|
233
|
-
isDestructive
|
|
234
|
-
>
|
|
235
|
-
{ postType?.labels?.remove_featured_image ||
|
|
236
|
-
DEFAULT_REMOVE_FEATURE_IMAGE_LABEL }
|
|
237
|
-
</Button>
|
|
238
|
-
</MediaUploadCheck>
|
|
239
|
-
) }
|
|
240
231
|
</div>
|
|
241
232
|
</PostFeaturedImageCheck>
|
|
242
233
|
);
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
.editor-post-featured-image {
|
|
2
2
|
padding: 0;
|
|
3
3
|
|
|
4
|
-
&__container {
|
|
5
|
-
margin-bottom: 1em;
|
|
6
|
-
position: relative;
|
|
7
|
-
}
|
|
8
4
|
|
|
9
5
|
.components-spinner {
|
|
10
6
|
position: absolute;
|
|
@@ -14,12 +10,6 @@
|
|
|
14
10
|
margin-left: -9px;
|
|
15
11
|
}
|
|
16
12
|
|
|
17
|
-
// Stack consecutive buttons.
|
|
18
|
-
.components-button + .components-button {
|
|
19
|
-
display: block;
|
|
20
|
-
margin-top: 1em;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
13
|
// This keeps images at their intrinsic size (eg. a 50px
|
|
24
14
|
// image will never be wider than 50px).
|
|
25
15
|
.components-responsive-wrapper__content {
|
|
@@ -28,22 +18,40 @@
|
|
|
28
18
|
}
|
|
29
19
|
}
|
|
30
20
|
|
|
21
|
+
.editor-post-featured-image__container {
|
|
22
|
+
position: relative;
|
|
23
|
+
|
|
24
|
+
&:hover,
|
|
25
|
+
&:focus,
|
|
26
|
+
&:focus-within {
|
|
27
|
+
.editor-post-featured-image__actions {
|
|
28
|
+
opacity: 1;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
31
33
|
.editor-post-featured-image__toggle,
|
|
32
34
|
.editor-post-featured-image__preview {
|
|
33
|
-
display: block;
|
|
34
35
|
width: 100%;
|
|
35
36
|
padding: 0;
|
|
36
37
|
transition: all 0.1s ease-out;
|
|
37
38
|
@include reduce-motion("transition");
|
|
38
39
|
box-shadow: 0 0 0 0 var(--wp-admin-theme-color);
|
|
40
|
+
overflow: hidden; // Ensure the focus style properly encapsulates the image.
|
|
41
|
+
|
|
42
|
+
// Apply a max-height.
|
|
43
|
+
display: flex;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
max-height: 150px;
|
|
39
46
|
}
|
|
40
47
|
|
|
41
48
|
.editor-post-featured-image__preview {
|
|
42
49
|
height: auto;
|
|
43
|
-
}
|
|
44
50
|
|
|
45
|
-
.
|
|
46
|
-
|
|
51
|
+
.components-responsive-wrapper {
|
|
52
|
+
width: 100%;
|
|
53
|
+
background: $gray-100;
|
|
54
|
+
}
|
|
47
55
|
}
|
|
48
56
|
|
|
49
57
|
.editor-post-featured-image__toggle {
|
|
@@ -59,3 +67,19 @@
|
|
|
59
67
|
color: $gray-900;
|
|
60
68
|
}
|
|
61
69
|
}
|
|
70
|
+
|
|
71
|
+
.editor-post-featured-image__actions {
|
|
72
|
+
@include reduce-motion("transition");
|
|
73
|
+
bottom: 0;
|
|
74
|
+
opacity: 0; // Use opacity instead of visibility so that the buttons remain in the tab order.
|
|
75
|
+
padding: $grid-unit-10;
|
|
76
|
+
position: absolute;
|
|
77
|
+
transition: opacity 50ms ease-out;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.editor-post-featured-image__action {
|
|
81
|
+
backdrop-filter: blur(16px) saturate(180%);
|
|
82
|
+
background: rgba(255, 255, 255, 0.75);
|
|
83
|
+
flex-grow: 1;
|
|
84
|
+
justify-content: center;
|
|
85
|
+
}
|
|
@@ -593,7 +593,7 @@ exports[`PostPublishPanel should render the spinner if the post is being saved 1
|
|
|
593
593
|
display: inline-block;
|
|
594
594
|
margin: 5px 11px 0;
|
|
595
595
|
position: relative;
|
|
596
|
-
color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #
|
|
596
|
+
color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));
|
|
597
597
|
overflow: visible;
|
|
598
598
|
opacity: 1;
|
|
599
599
|
background-color: transparent;
|
|
@@ -20,7 +20,6 @@ import { displayShortcut } from '@wordpress/keycodes';
|
|
|
20
20
|
/**
|
|
21
21
|
* Internal dependencies
|
|
22
22
|
*/
|
|
23
|
-
import PostSwitchToDraftButton from '../post-switch-to-draft-button';
|
|
24
23
|
import { store as editorStore } from '../../store';
|
|
25
24
|
|
|
26
25
|
/**
|
|
@@ -48,10 +47,8 @@ export default function PostSavedState( {
|
|
|
48
47
|
isDirty,
|
|
49
48
|
isNew,
|
|
50
49
|
isPending,
|
|
51
|
-
isPublished,
|
|
52
50
|
isSaveable,
|
|
53
51
|
isSaving,
|
|
54
|
-
isScheduled,
|
|
55
52
|
hasPublishAction,
|
|
56
53
|
} = useSelect(
|
|
57
54
|
( select ) => {
|
|
@@ -106,10 +103,6 @@ export default function PostSavedState( {
|
|
|
106
103
|
return null;
|
|
107
104
|
}
|
|
108
105
|
|
|
109
|
-
if ( isPublished || isScheduled ) {
|
|
110
|
-
return <PostSwitchToDraftButton />;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
106
|
/* translators: button label text should, if possible, be under 16 characters. */
|
|
114
107
|
const label = isPending ? __( 'Save as pending' ) : __( 'Save draft' );
|
|
115
108
|
|
|
@@ -22,15 +22,6 @@ exports[`PostSavedState returns a disabled button if the post is not saveable 1`
|
|
|
22
22
|
</button>
|
|
23
23
|
`;
|
|
24
24
|
|
|
25
|
-
exports[`PostSavedState returns a switch to draft link if the post is published 1`] = `
|
|
26
|
-
<button
|
|
27
|
-
class="components-button editor-post-switch-to-draft is-tertiary"
|
|
28
|
-
type="button"
|
|
29
|
-
>
|
|
30
|
-
Switch to draft
|
|
31
|
-
</button>
|
|
32
|
-
`;
|
|
33
|
-
|
|
34
25
|
exports[`PostSavedState should return Save button if edits to be saved 1`] = `
|
|
35
26
|
<button
|
|
36
27
|
aria-disabled="false"
|
|
@@ -67,16 +67,6 @@ describe( 'PostSavedState', () => {
|
|
|
67
67
|
expect( screen.getByRole( 'button' ) ).toMatchSnapshot();
|
|
68
68
|
} );
|
|
69
69
|
|
|
70
|
-
it( 'returns a switch to draft link if the post is published', () => {
|
|
71
|
-
useSelect.mockImplementation( () => ( {
|
|
72
|
-
isPublished: true,
|
|
73
|
-
} ) );
|
|
74
|
-
|
|
75
|
-
render( <PostSavedState /> );
|
|
76
|
-
|
|
77
|
-
expect( screen.getByRole( 'button' ) ).toMatchSnapshot();
|
|
78
|
-
} );
|
|
79
|
-
|
|
80
70
|
it( 'should return Saved text if not new and not dirty', () => {
|
|
81
71
|
useSelect.mockImplementation( () => ( {
|
|
82
72
|
isDirty: false,
|