@wordpress/edit-post 6.0.1 → 6.0.2
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/header/fullscreen-mode-close/index.js +11 -4
- package/build/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build/components/header/index.js +3 -1
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/template-title/delete-template.js +29 -20
- package/build/components/header/template-title/delete-template.js.map +1 -1
- package/build/components/preferences-modal/index.js +4 -41
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +0 -11
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/store/actions.js +135 -87
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +0 -3
- package/build/store/index.js.map +1 -1
- package/build-module/components/header/fullscreen-mode-close/index.js +8 -4
- package/build-module/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build-module/components/header/index.js +3 -1
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/template-title/delete-template.js +32 -22
- package/build-module/components/header/template-title/delete-template.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +5 -42
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +1 -12
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/store/actions.js +107 -75
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +0 -2
- package/build-module/store/index.js.map +1 -1
- package/build-style/style-rtl.css +14 -9
- package/build-style/style.css +14 -9
- package/package.json +17 -17
- package/src/components/header/fullscreen-mode-close/index.js +9 -4
- package/src/components/header/fullscreen-mode-close/style.scss +5 -1
- package/src/components/header/index.js +1 -1
- package/src/components/header/template-title/delete-template.js +57 -46
- package/src/components/preferences-modal/index.js +5 -33
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +9 -9
- package/src/components/secondary-sidebar/list-view-sidebar.js +1 -11
- package/src/store/actions.js +85 -121
- package/src/store/index.js +0 -2
- package/src/store/test/actions.js +107 -97
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { get } from 'lodash';
|
|
5
|
+
import classnames from 'classnames';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* WordPress dependencies
|
|
@@ -59,9 +60,8 @@ function FullscreenModeClose( { showTooltip, icon, href } ) {
|
|
|
59
60
|
|
|
60
61
|
const effect = {
|
|
61
62
|
expand: {
|
|
62
|
-
scale: 1.
|
|
63
|
-
|
|
64
|
-
transition: { type: 'tween', duration: '0.2' },
|
|
63
|
+
scale: 1.25,
|
|
64
|
+
transition: { type: 'tween', duration: '0.3' },
|
|
65
65
|
},
|
|
66
66
|
};
|
|
67
67
|
|
|
@@ -85,10 +85,15 @@ function FullscreenModeClose( { showTooltip, icon, href } ) {
|
|
|
85
85
|
buttonIcon = <Icon size="36px" icon={ icon } />;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
const classes = classnames( {
|
|
89
|
+
'edit-post-fullscreen-mode-close': true,
|
|
90
|
+
'has-icon': siteIconUrl,
|
|
91
|
+
} );
|
|
92
|
+
|
|
88
93
|
return (
|
|
89
94
|
<motion.div whileHover="expand">
|
|
90
95
|
<Button
|
|
91
|
-
className=
|
|
96
|
+
className={ classes }
|
|
92
97
|
href={
|
|
93
98
|
href ??
|
|
94
99
|
addQueryArgs( 'edit.php', {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Developer notes: these rules are duplicated for the site editor.
|
|
2
2
|
// They need to be updated in both places.
|
|
3
3
|
|
|
4
|
-
.edit-post-fullscreen-mode-close.
|
|
4
|
+
.edit-post-fullscreen-mode-close.components-button {
|
|
5
5
|
// Do not show the toolbar icon on small screens,
|
|
6
6
|
// when Fullscreen Mode is not an option in the "More" menu.
|
|
7
7
|
display: none;
|
|
@@ -46,6 +46,10 @@
|
|
|
46
46
|
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $gray-700;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
&.has-icon:hover::before {
|
|
50
|
+
box-shadow: none;
|
|
51
|
+
}
|
|
52
|
+
|
|
49
53
|
// Lightened spot color focus.
|
|
50
54
|
&:focus::before {
|
|
51
55
|
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) rgba($white, 0.1), inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
@@ -56,7 +56,7 @@ function Header( { setEntitiesSavedStatesCallback } ) {
|
|
|
56
56
|
return (
|
|
57
57
|
<div className={ classes }>
|
|
58
58
|
<MainDashboardButton.Slot>
|
|
59
|
-
<FullscreenModeClose />
|
|
59
|
+
<FullscreenModeClose showTooltip />
|
|
60
60
|
</MainDashboardButton.Slot>
|
|
61
61
|
<div className="edit-post-header__toolbar">
|
|
62
62
|
<HeaderToolbar />
|
|
@@ -7,11 +7,16 @@ import { pickBy } from 'lodash';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { __, sprintf } from '@wordpress/i18n';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
MenuGroup,
|
|
12
|
+
MenuItem,
|
|
13
|
+
__experimentalConfirmDialog as ConfirmDialog,
|
|
14
|
+
} from '@wordpress/components';
|
|
11
15
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
12
16
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
13
17
|
import { store as editorStore } from '@wordpress/editor';
|
|
14
18
|
import { store as coreStore } from '@wordpress/core-data';
|
|
19
|
+
import { useState } from '@wordpress/element';
|
|
15
20
|
|
|
16
21
|
/**
|
|
17
22
|
* Internal dependencies
|
|
@@ -33,6 +38,7 @@ export default function DeleteTemplate() {
|
|
|
33
38
|
template: _isEditing ? getEditedPostTemplate() : null,
|
|
34
39
|
};
|
|
35
40
|
}, [] );
|
|
41
|
+
const [ showConfirmDialog, setShowConfirmDialog ] = useState( false );
|
|
36
42
|
|
|
37
43
|
if ( ! template || ! template.wp_id ) {
|
|
38
44
|
return null;
|
|
@@ -42,53 +48,58 @@ export default function DeleteTemplate() {
|
|
|
42
48
|
templateTitle = template.title;
|
|
43
49
|
}
|
|
44
50
|
|
|
51
|
+
const onDelete = () => {
|
|
52
|
+
clearSelectedBlock();
|
|
53
|
+
setIsEditingTemplate( false );
|
|
54
|
+
setShowConfirmDialog( false );
|
|
55
|
+
|
|
56
|
+
editPost( {
|
|
57
|
+
template: '',
|
|
58
|
+
} );
|
|
59
|
+
const settings = getEditorSettings();
|
|
60
|
+
const newAvailableTemplates = pickBy(
|
|
61
|
+
settings.availableTemplates,
|
|
62
|
+
( _title, id ) => {
|
|
63
|
+
return id !== template.slug;
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
updateEditorSettings( {
|
|
67
|
+
...settings,
|
|
68
|
+
availableTemplates: newAvailableTemplates,
|
|
69
|
+
} );
|
|
70
|
+
deleteEntityRecord( 'postType', 'wp_template', template.id );
|
|
71
|
+
};
|
|
72
|
+
|
|
45
73
|
return (
|
|
46
74
|
<MenuGroup className="edit-post-template-top-area__second-menu-group">
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
template
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return id !== template.slug;
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
updateEditorSettings( {
|
|
79
|
-
...settings,
|
|
80
|
-
availableTemplates: newAvailableTemplates,
|
|
81
|
-
} );
|
|
82
|
-
deleteEntityRecord(
|
|
83
|
-
'postType',
|
|
84
|
-
'wp_template',
|
|
85
|
-
template.id
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
} }
|
|
89
|
-
>
|
|
90
|
-
{ __( 'Delete template' ) }
|
|
91
|
-
</MenuItem>
|
|
75
|
+
<>
|
|
76
|
+
<MenuItem
|
|
77
|
+
className="edit-post-template-top-area__delete-template-button"
|
|
78
|
+
isDestructive
|
|
79
|
+
variant="secondary"
|
|
80
|
+
aria-label={ __( 'Delete template' ) }
|
|
81
|
+
onClick={ () => {
|
|
82
|
+
setShowConfirmDialog( true );
|
|
83
|
+
} }
|
|
84
|
+
>
|
|
85
|
+
{ __( 'Delete template' ) }
|
|
86
|
+
</MenuItem>
|
|
87
|
+
<ConfirmDialog
|
|
88
|
+
isOpen={ showConfirmDialog }
|
|
89
|
+
onConfirm={ onDelete }
|
|
90
|
+
onCancel={ () => {
|
|
91
|
+
setShowConfirmDialog( false );
|
|
92
|
+
} }
|
|
93
|
+
>
|
|
94
|
+
{ sprintf(
|
|
95
|
+
/* translators: %s: template name */
|
|
96
|
+
__(
|
|
97
|
+
'Are you sure you want to delete the %s template? It may be used by other pages or posts.'
|
|
98
|
+
),
|
|
99
|
+
templateTitle
|
|
100
|
+
) }
|
|
101
|
+
</ConfirmDialog>
|
|
102
|
+
</>
|
|
92
103
|
</MenuGroup>
|
|
93
104
|
);
|
|
94
105
|
}
|
|
@@ -9,7 +9,8 @@ import { get } from 'lodash';
|
|
|
9
9
|
import {
|
|
10
10
|
__experimentalNavigatorProvider as NavigatorProvider,
|
|
11
11
|
__experimentalNavigatorScreen as NavigatorScreen,
|
|
12
|
-
|
|
12
|
+
__experimentalNavigatorButton as NavigatorButton,
|
|
13
|
+
__experimentalNavigatorBackButton as NavigatorBackButton,
|
|
13
14
|
__experimentalItemGroup as ItemGroup,
|
|
14
15
|
__experimentalItem as Item,
|
|
15
16
|
__experimentalHStack as HStack,
|
|
@@ -18,7 +19,6 @@ import {
|
|
|
18
19
|
FlexItem,
|
|
19
20
|
Modal,
|
|
20
21
|
TabPanel,
|
|
21
|
-
Button,
|
|
22
22
|
Card,
|
|
23
23
|
CardHeader,
|
|
24
24
|
CardBody,
|
|
@@ -55,34 +55,6 @@ import BlockManager from '../block-manager';
|
|
|
55
55
|
const MODAL_NAME = 'edit-post/preferences';
|
|
56
56
|
const PREFERENCES_MENU = 'preferences-menu';
|
|
57
57
|
|
|
58
|
-
function NavigationButton( { as: Tag = Button, path, ...props } ) {
|
|
59
|
-
const { goTo } = useNavigator();
|
|
60
|
-
|
|
61
|
-
const dataAttrName = 'data-navigator-focusable-id';
|
|
62
|
-
const dataAttrValue = path;
|
|
63
|
-
|
|
64
|
-
const dataAttrCssSelector = `[${ dataAttrName }="${ dataAttrValue }"]`;
|
|
65
|
-
|
|
66
|
-
const tagProps = {
|
|
67
|
-
...props,
|
|
68
|
-
[ dataAttrName ]: dataAttrValue,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
<Tag
|
|
73
|
-
onClick={ () =>
|
|
74
|
-
goTo( path, { focusTargetSelector: dataAttrCssSelector } )
|
|
75
|
-
}
|
|
76
|
-
{ ...tagProps }
|
|
77
|
-
/>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function NavigationBackButton( { as: Tag = Button, ...props } ) {
|
|
82
|
-
const { goBack } = useNavigator();
|
|
83
|
-
return <Tag onClick={ goBack } { ...props } />;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
58
|
export default function PreferencesModal() {
|
|
87
59
|
const isLargeViewport = useViewportMatch( 'medium' );
|
|
88
60
|
const { closeModal } = useDispatch( editPostStore );
|
|
@@ -347,7 +319,7 @@ export default function PreferencesModal() {
|
|
|
347
319
|
<ItemGroup>
|
|
348
320
|
{ tabs.map( ( tab ) => {
|
|
349
321
|
return (
|
|
350
|
-
<
|
|
322
|
+
<NavigatorButton
|
|
351
323
|
key={ tab.name }
|
|
352
324
|
path={ tab.name }
|
|
353
325
|
as={ Item }
|
|
@@ -369,7 +341,7 @@ export default function PreferencesModal() {
|
|
|
369
341
|
/>
|
|
370
342
|
</FlexItem>
|
|
371
343
|
</HStack>
|
|
372
|
-
</
|
|
344
|
+
</NavigatorButton>
|
|
373
345
|
);
|
|
374
346
|
} ) }
|
|
375
347
|
</ItemGroup>
|
|
@@ -389,7 +361,7 @@ export default function PreferencesModal() {
|
|
|
389
361
|
size="small"
|
|
390
362
|
gap="6"
|
|
391
363
|
>
|
|
392
|
-
<
|
|
364
|
+
<NavigatorBackButton
|
|
393
365
|
icon={
|
|
394
366
|
isRTL() ? chevronRight : chevronLeft
|
|
395
367
|
}
|
|
@@ -52,7 +52,7 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
|
|
|
52
52
|
>
|
|
53
53
|
<CardBody>
|
|
54
54
|
<ItemGroup>
|
|
55
|
-
<
|
|
55
|
+
<NavigatorButton
|
|
56
56
|
as={
|
|
57
57
|
Object {
|
|
58
58
|
"$$typeof": Symbol(react.forward_ref),
|
|
@@ -90,8 +90,8 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
|
|
|
90
90
|
/>
|
|
91
91
|
</FlexItem>
|
|
92
92
|
</HStack>
|
|
93
|
-
</
|
|
94
|
-
<
|
|
93
|
+
</NavigatorButton>
|
|
94
|
+
<NavigatorButton
|
|
95
95
|
as={
|
|
96
96
|
Object {
|
|
97
97
|
"$$typeof": Symbol(react.forward_ref),
|
|
@@ -129,8 +129,8 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
|
|
|
129
129
|
/>
|
|
130
130
|
</FlexItem>
|
|
131
131
|
</HStack>
|
|
132
|
-
</
|
|
133
|
-
<
|
|
132
|
+
</NavigatorButton>
|
|
133
|
+
<NavigatorButton
|
|
134
134
|
as={
|
|
135
135
|
Object {
|
|
136
136
|
"$$typeof": Symbol(react.forward_ref),
|
|
@@ -168,7 +168,7 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
|
|
|
168
168
|
/>
|
|
169
169
|
</FlexItem>
|
|
170
170
|
</HStack>
|
|
171
|
-
</
|
|
171
|
+
</NavigatorButton>
|
|
172
172
|
</ItemGroup>
|
|
173
173
|
</CardBody>
|
|
174
174
|
</Card>
|
|
@@ -187,7 +187,7 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
|
|
|
187
187
|
justify="left"
|
|
188
188
|
size="small"
|
|
189
189
|
>
|
|
190
|
-
<
|
|
190
|
+
<NavigatorBackButton
|
|
191
191
|
aria-label="Navigate to the previous view"
|
|
192
192
|
icon={
|
|
193
193
|
<SVG
|
|
@@ -254,7 +254,7 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
|
|
|
254
254
|
justify="left"
|
|
255
255
|
size="small"
|
|
256
256
|
>
|
|
257
|
-
<
|
|
257
|
+
<NavigatorBackButton
|
|
258
258
|
aria-label="Navigate to the previous view"
|
|
259
259
|
icon={
|
|
260
260
|
<SVG
|
|
@@ -312,7 +312,7 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
|
|
|
312
312
|
justify="left"
|
|
313
313
|
size="small"
|
|
314
314
|
>
|
|
315
|
-
<
|
|
315
|
+
<NavigatorBackButton
|
|
316
316
|
aria-label="Navigate to the previous view"
|
|
317
317
|
icon={
|
|
318
318
|
<SVG
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
__experimentalListView as ListView,
|
|
6
|
-
store as blockEditorStore,
|
|
7
|
-
} from '@wordpress/block-editor';
|
|
4
|
+
import { __experimentalListView as ListView } from '@wordpress/block-editor';
|
|
8
5
|
import { Button } from '@wordpress/components';
|
|
9
6
|
import {
|
|
10
7
|
useFocusOnMount,
|
|
@@ -25,12 +22,6 @@ import { store as editPostStore } from '../../store';
|
|
|
25
22
|
export default function ListViewSidebar() {
|
|
26
23
|
const { setIsListViewOpened } = useDispatch( editPostStore );
|
|
27
24
|
|
|
28
|
-
const { clearSelectedBlock, selectBlock } = useDispatch( blockEditorStore );
|
|
29
|
-
async function selectEditorBlock( clientId ) {
|
|
30
|
-
await clearSelectedBlock();
|
|
31
|
-
selectBlock( clientId, -1 );
|
|
32
|
-
}
|
|
33
|
-
|
|
34
25
|
const focusOnMountRef = useFocusOnMount( 'firstElement' );
|
|
35
26
|
const headerFocusReturnRef = useFocusReturn();
|
|
36
27
|
const contentFocusReturnRef = useFocusReturn();
|
|
@@ -70,7 +61,6 @@ export default function ListViewSidebar() {
|
|
|
70
61
|
] ) }
|
|
71
62
|
>
|
|
72
63
|
<ListView
|
|
73
|
-
onSelect={ selectEditorBlock }
|
|
74
64
|
showNestedBlocks
|
|
75
65
|
__experimentalFeatures
|
|
76
66
|
__experimentalPersistentListViewFeatures
|