@wordpress/edit-post 6.5.0 → 6.6.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/device-preview/index.js +26 -7
- package/build/components/device-preview/index.js.map +1 -1
- package/build/components/header/template-title/delete-template.js +6 -5
- package/build/components/header/template-title/delete-template.js.map +1 -1
- package/build/components/header/template-title/edit-template-title.js +6 -4
- package/build/components/header/template-title/edit-template-title.js.map +1 -1
- package/build/components/header/template-title/template-description.js +3 -1
- package/build/components/header/template-title/template-description.js.map +1 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/preferences-modal/index.js +10 -6
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/sidebar/post-schedule/index.js +1 -1
- package/build/components/sidebar/post-schedule/index.js.map +1 -1
- package/build/components/text-editor/index.js +11 -24
- package/build/components/text-editor/index.js.map +1 -1
- package/build/index.js +7 -1
- package/build/index.js.map +1 -1
- package/build/store/selectors.js +4 -4
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/device-preview/index.js +24 -7
- package/build-module/components/device-preview/index.js.map +1 -1
- package/build-module/components/header/template-title/delete-template.js +6 -5
- package/build-module/components/header/template-title/delete-template.js.map +1 -1
- package/build-module/components/header/template-title/edit-template-title.js +6 -4
- package/build-module/components/header/template-title/edit-template-title.js.map +1 -1
- package/build-module/components/header/template-title/template-description.js +4 -2
- package/build-module/components/header/template-title/template-description.js.map +1 -1
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +10 -6
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/sidebar/post-schedule/index.js +1 -1
- package/build-module/components/sidebar/post-schedule/index.js.map +1 -1
- package/build-module/components/text-editor/index.js +11 -22
- package/build-module/components/text-editor/index.js.map +1 -1
- package/build-module/index.js +7 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/selectors.js +4 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +26 -11
- package/build-style/style.css +26 -11
- package/package.json +27 -27
- package/src/components/device-preview/index.js +36 -23
- package/src/components/header/style.scss +2 -4
- package/src/components/header/template-title/delete-template.js +11 -4
- package/src/components/header/template-title/edit-template-title.js +29 -26
- package/src/components/header/template-title/style.scss +26 -5
- package/src/components/header/template-title/template-description.js +3 -2
- package/src/components/layout/index.js +1 -0
- package/src/components/preferences-modal/index.js +18 -9
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +24 -14
- package/src/components/sidebar/post-schedule/index.js +1 -1
- package/src/components/sidebar/post-schedule/style.scss +2 -2
- package/src/components/sidebar/settings-header/style.scss +1 -1
- package/src/components/text-editor/index.js +9 -19
- package/src/components/visual-editor/test/index.native.js +93 -0
- package/src/index.js +7 -0
- package/src/store/selectors.js +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-post",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.0",
|
|
4
4
|
"description": "Edit Post module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -27,31 +27,31 @@
|
|
|
27
27
|
"react-native": "src/index",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@babel/runtime": "^7.16.0",
|
|
30
|
-
"@wordpress/a11y": "^3.
|
|
31
|
-
"@wordpress/api-fetch": "^6.
|
|
32
|
-
"@wordpress/block-editor": "^9.
|
|
33
|
-
"@wordpress/block-library": "^7.
|
|
34
|
-
"@wordpress/blocks": "^11.
|
|
35
|
-
"@wordpress/components": "^19.
|
|
36
|
-
"@wordpress/compose": "^5.
|
|
37
|
-
"@wordpress/core-data": "^4.
|
|
38
|
-
"@wordpress/data": "^6.
|
|
39
|
-
"@wordpress/deprecated": "^3.
|
|
40
|
-
"@wordpress/editor": "^12.
|
|
41
|
-
"@wordpress/element": "^4.
|
|
42
|
-
"@wordpress/hooks": "^3.
|
|
43
|
-
"@wordpress/i18n": "^4.
|
|
44
|
-
"@wordpress/icons": "^
|
|
45
|
-
"@wordpress/interface": "^4.
|
|
46
|
-
"@wordpress/keyboard-shortcuts": "^3.
|
|
47
|
-
"@wordpress/keycodes": "^3.
|
|
48
|
-
"@wordpress/media-utils": "^
|
|
49
|
-
"@wordpress/notices": "^3.
|
|
50
|
-
"@wordpress/plugins": "^4.
|
|
51
|
-
"@wordpress/preferences": "^2.
|
|
52
|
-
"@wordpress/url": "^3.
|
|
53
|
-
"@wordpress/viewport": "^4.
|
|
54
|
-
"@wordpress/warning": "^2.
|
|
30
|
+
"@wordpress/a11y": "^3.9.0",
|
|
31
|
+
"@wordpress/api-fetch": "^6.6.0",
|
|
32
|
+
"@wordpress/block-editor": "^9.1.0",
|
|
33
|
+
"@wordpress/block-library": "^7.6.0",
|
|
34
|
+
"@wordpress/blocks": "^11.8.0",
|
|
35
|
+
"@wordpress/components": "^19.11.0",
|
|
36
|
+
"@wordpress/compose": "^5.7.0",
|
|
37
|
+
"@wordpress/core-data": "^4.7.0",
|
|
38
|
+
"@wordpress/data": "^6.9.0",
|
|
39
|
+
"@wordpress/deprecated": "^3.9.0",
|
|
40
|
+
"@wordpress/editor": "^12.8.0",
|
|
41
|
+
"@wordpress/element": "^4.7.0",
|
|
42
|
+
"@wordpress/hooks": "^3.9.0",
|
|
43
|
+
"@wordpress/i18n": "^4.9.0",
|
|
44
|
+
"@wordpress/icons": "^9.0.0",
|
|
45
|
+
"@wordpress/interface": "^4.8.0",
|
|
46
|
+
"@wordpress/keyboard-shortcuts": "^3.7.0",
|
|
47
|
+
"@wordpress/keycodes": "^3.9.0",
|
|
48
|
+
"@wordpress/media-utils": "^4.0.0",
|
|
49
|
+
"@wordpress/notices": "^3.9.0",
|
|
50
|
+
"@wordpress/plugins": "^4.7.0",
|
|
51
|
+
"@wordpress/preferences": "^2.1.0",
|
|
52
|
+
"@wordpress/url": "^3.10.0",
|
|
53
|
+
"@wordpress/viewport": "^4.7.0",
|
|
54
|
+
"@wordpress/warning": "^2.9.0",
|
|
55
55
|
"classnames": "^2.3.1",
|
|
56
56
|
"lodash": "^4.17.21",
|
|
57
57
|
"memize": "^1.1.0",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "198fa129cf1af8dc615918987ea6795cd40ab7df"
|
|
68
68
|
}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { get } from 'lodash';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
@@ -7,6 +12,7 @@ import { external } from '@wordpress/icons';
|
|
|
7
12
|
import { __ } from '@wordpress/i18n';
|
|
8
13
|
import { __experimentalPreviewOptions as PreviewOptions } from '@wordpress/block-editor';
|
|
9
14
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
15
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
10
16
|
|
|
11
17
|
/**
|
|
12
18
|
* Internal dependencies
|
|
@@ -18,18 +24,23 @@ export default function DevicePreview() {
|
|
|
18
24
|
hasActiveMetaboxes,
|
|
19
25
|
isPostSaveable,
|
|
20
26
|
isSaving,
|
|
27
|
+
isViewable,
|
|
21
28
|
deviceType,
|
|
22
|
-
} = useSelect(
|
|
23
|
-
|
|
29
|
+
} = useSelect( ( select ) => {
|
|
30
|
+
const { getEditedPostAttribute } = select( editorStore );
|
|
31
|
+
const { getPostType } = select( coreStore );
|
|
32
|
+
const postType = getPostType( getEditedPostAttribute( 'type' ) );
|
|
33
|
+
|
|
34
|
+
return {
|
|
24
35
|
hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
|
|
25
36
|
isSaving: select( editPostStore ).isSavingMetaBoxes(),
|
|
26
37
|
isPostSaveable: select( editorStore ).isEditedPostSaveable(),
|
|
38
|
+
isViewable: get( postType, [ 'viewable' ], false ),
|
|
27
39
|
deviceType: select(
|
|
28
40
|
editPostStore
|
|
29
41
|
).__experimentalGetPreviewDeviceType(),
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
);
|
|
42
|
+
};
|
|
43
|
+
}, [] );
|
|
33
44
|
const {
|
|
34
45
|
__experimentalSetPreviewDeviceType: setPreviewDeviceType,
|
|
35
46
|
} = useDispatch( editPostStore );
|
|
@@ -41,24 +52,26 @@ export default function DevicePreview() {
|
|
|
41
52
|
deviceType={ deviceType }
|
|
42
53
|
setDeviceType={ setPreviewDeviceType }
|
|
43
54
|
>
|
|
44
|
-
|
|
45
|
-
<
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
{ isViewable && (
|
|
56
|
+
<MenuGroup>
|
|
57
|
+
<div className="edit-post-header-preview__grouping-external">
|
|
58
|
+
<PostPreviewButton
|
|
59
|
+
className={
|
|
60
|
+
'edit-post-header-preview__button-external'
|
|
61
|
+
}
|
|
62
|
+
role="menuitem"
|
|
63
|
+
forceIsAutosaveable={ hasActiveMetaboxes }
|
|
64
|
+
forcePreviewLink={ isSaving ? null : undefined }
|
|
65
|
+
textContent={
|
|
66
|
+
<>
|
|
67
|
+
{ __( 'Preview in new tab' ) }
|
|
68
|
+
<Icon icon={ external } />
|
|
69
|
+
</>
|
|
70
|
+
}
|
|
71
|
+
/>
|
|
72
|
+
</div>
|
|
73
|
+
</MenuGroup>
|
|
74
|
+
) }
|
|
62
75
|
</PreviewOptions>
|
|
63
76
|
);
|
|
64
77
|
}
|
|
@@ -48,6 +48,8 @@ export default function DeleteTemplate() {
|
|
|
48
48
|
templateTitle = template.title;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
const isRevertable = template?.has_theme_file;
|
|
52
|
+
|
|
51
53
|
const onDelete = () => {
|
|
52
54
|
clearSelectedBlock();
|
|
53
55
|
setIsEditingTemplate( false );
|
|
@@ -77,14 +79,19 @@ export default function DeleteTemplate() {
|
|
|
77
79
|
<>
|
|
78
80
|
<MenuItem
|
|
79
81
|
className="edit-post-template-top-area__delete-template-button"
|
|
80
|
-
isDestructive
|
|
81
|
-
variant="secondary"
|
|
82
|
-
aria-label={ __( 'Delete template' ) }
|
|
82
|
+
isDestructive={ ! isRevertable }
|
|
83
83
|
onClick={ () => {
|
|
84
84
|
setShowConfirmDialog( true );
|
|
85
85
|
} }
|
|
86
|
+
info={
|
|
87
|
+
isRevertable
|
|
88
|
+
? __( 'Restore template to default state' )
|
|
89
|
+
: undefined
|
|
90
|
+
}
|
|
86
91
|
>
|
|
87
|
-
{
|
|
92
|
+
{ isRevertable
|
|
93
|
+
? __( 'Clear customizations' )
|
|
94
|
+
: __( 'Delete template' ) }
|
|
88
95
|
</MenuItem>
|
|
89
96
|
<ConfirmDialog
|
|
90
97
|
isOpen={ showConfirmDialog }
|
|
@@ -29,7 +29,8 @@ export default function EditTemplateTitle() {
|
|
|
29
29
|
const { getEditorSettings } = useSelect( editorStore );
|
|
30
30
|
const { updateEditorSettings } = useDispatch( editorStore );
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
// Only user-created and non-default templates can change the name.
|
|
33
|
+
if ( ! template.is_custom || template.has_theme_file ) {
|
|
33
34
|
return null;
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -41,31 +42,33 @@ export default function EditTemplateTitle() {
|
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
return (
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
45
|
+
<div className="edit-site-template-details__group">
|
|
46
|
+
<TextControl
|
|
47
|
+
label={ __( 'Title' ) }
|
|
48
|
+
value={ templateTitle }
|
|
49
|
+
help={ __(
|
|
50
|
+
'Give the template a title that indicates its purpose, e.g. "Full Width".'
|
|
51
|
+
) }
|
|
52
|
+
onChange={ ( newTitle ) => {
|
|
53
|
+
const settings = getEditorSettings();
|
|
54
|
+
const newAvailableTemplates = mapValues(
|
|
55
|
+
settings.availableTemplates,
|
|
56
|
+
( existingTitle, id ) => {
|
|
57
|
+
if ( id !== template.slug ) {
|
|
58
|
+
return existingTitle;
|
|
59
|
+
}
|
|
60
|
+
return newTitle;
|
|
57
61
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/>
|
|
62
|
+
);
|
|
63
|
+
updateEditorSettings( {
|
|
64
|
+
...settings,
|
|
65
|
+
availableTemplates: newAvailableTemplates,
|
|
66
|
+
} );
|
|
67
|
+
editEntityRecord( 'postType', 'wp_template', template.id, {
|
|
68
|
+
title: newTitle,
|
|
69
|
+
} );
|
|
70
|
+
} }
|
|
71
|
+
/>
|
|
72
|
+
</div>
|
|
70
73
|
);
|
|
71
74
|
}
|
|
@@ -49,7 +49,18 @@
|
|
|
49
49
|
.edit-post-template-top-area__popover {
|
|
50
50
|
.components-popover__content {
|
|
51
51
|
min-width: 280px;
|
|
52
|
-
|
|
52
|
+
|
|
53
|
+
> div {
|
|
54
|
+
padding: 0;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.edit-site-template-details__group {
|
|
59
|
+
padding: $grid-unit-20;
|
|
60
|
+
|
|
61
|
+
.components-base-control__help {
|
|
62
|
+
margin-bottom: 0;
|
|
63
|
+
}
|
|
53
64
|
}
|
|
54
65
|
|
|
55
66
|
.edit-post-template-details__description {
|
|
@@ -58,19 +69,29 @@
|
|
|
58
69
|
}
|
|
59
70
|
|
|
60
71
|
.edit-post-template-top-area__second-menu-group {
|
|
61
|
-
margin-left: -$grid-unit-20;
|
|
62
|
-
margin-right: -$grid-unit-20;
|
|
63
|
-
padding: $grid-unit-20;
|
|
64
|
-
padding-bottom: 0;
|
|
65
72
|
border-top: $border-width solid $gray-300;
|
|
73
|
+
padding: $grid-unit-20 $grid-unit-10;
|
|
66
74
|
|
|
67
75
|
.edit-post-template-top-area__delete-template-button {
|
|
68
76
|
display: flex;
|
|
69
77
|
justify-content: center;
|
|
78
|
+
padding: $grid-unit-05 $grid-unit;
|
|
79
|
+
|
|
80
|
+
&.is-destructive {
|
|
81
|
+
padding: inherit;
|
|
82
|
+
margin-left: $grid-unit-10;
|
|
83
|
+
margin-right: $grid-unit-10;
|
|
84
|
+
width: calc(100% - #{($grid-unit * 2)});
|
|
85
|
+
|
|
86
|
+
.components-menu-item__item {
|
|
87
|
+
width: auto;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
70
90
|
|
|
71
91
|
.components-menu-item__item {
|
|
72
92
|
margin-right: 0;
|
|
73
93
|
min-width: 0;
|
|
94
|
+
width: 100%;
|
|
74
95
|
}
|
|
75
96
|
}
|
|
76
97
|
}
|
|
@@ -23,8 +23,9 @@ export default function TemplateDescription() {
|
|
|
23
23
|
if ( ! description ) {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
|
+
|
|
26
27
|
return (
|
|
27
|
-
|
|
28
|
+
<div className="edit-site-template-details__group">
|
|
28
29
|
<Heading level={ 4 } weight={ 600 }>
|
|
29
30
|
{ title }
|
|
30
31
|
</Heading>
|
|
@@ -36,6 +37,6 @@ export default function TemplateDescription() {
|
|
|
36
37
|
>
|
|
37
38
|
{ description }
|
|
38
39
|
</Text>
|
|
39
|
-
|
|
40
|
+
</div>
|
|
40
41
|
);
|
|
41
42
|
}
|
|
@@ -101,13 +101,6 @@ export default function EditPostPreferencesModal() {
|
|
|
101
101
|
'Customize options related to the block editor interface and editing flow.'
|
|
102
102
|
) }
|
|
103
103
|
>
|
|
104
|
-
<EnableFeature
|
|
105
|
-
featureName="reducedUI"
|
|
106
|
-
help={ __(
|
|
107
|
-
'Compacts options and outlines in the toolbar.'
|
|
108
|
-
) }
|
|
109
|
-
label={ __( 'Reduce the interface' ) }
|
|
110
|
-
/>
|
|
111
104
|
<EnableFeature
|
|
112
105
|
featureName="focusMode"
|
|
113
106
|
help={ __(
|
|
@@ -117,8 +110,24 @@ export default function EditPostPreferencesModal() {
|
|
|
117
110
|
/>
|
|
118
111
|
<EnableFeature
|
|
119
112
|
featureName="showIconLabels"
|
|
120
|
-
|
|
121
|
-
|
|
113
|
+
label={ __( 'Show button text labels' ) }
|
|
114
|
+
help={ __(
|
|
115
|
+
'Show text instead of icons on buttons.'
|
|
116
|
+
) }
|
|
117
|
+
/>
|
|
118
|
+
<EnableFeature
|
|
119
|
+
featureName="showListViewByDefault"
|
|
120
|
+
help={ __(
|
|
121
|
+
'Opens the block list view sidebar by default.'
|
|
122
|
+
) }
|
|
123
|
+
label={ __( 'Always open list view' ) }
|
|
124
|
+
/>
|
|
125
|
+
<EnableFeature
|
|
126
|
+
featureName="reducedUI"
|
|
127
|
+
help={ __(
|
|
128
|
+
'Compacts options and outlines in the toolbar.'
|
|
129
|
+
) }
|
|
130
|
+
label={ __( 'Reduce the interface' ) }
|
|
122
131
|
/>
|
|
123
132
|
<EnableFeature
|
|
124
133
|
featureName="themeStyles"
|
|
@@ -22,11 +22,6 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
|
|
|
22
22
|
description="Customize options related to the block editor interface and editing flow."
|
|
23
23
|
title="Appearance"
|
|
24
24
|
>
|
|
25
|
-
<WithSelect(WithDispatch(BaseOption))
|
|
26
|
-
featureName="reducedUI"
|
|
27
|
-
help="Compacts options and outlines in the toolbar."
|
|
28
|
-
label="Reduce the interface"
|
|
29
|
-
/>
|
|
30
25
|
<WithSelect(WithDispatch(BaseOption))
|
|
31
26
|
featureName="focusMode"
|
|
32
27
|
help="Highlights the current block and fades other content."
|
|
@@ -34,8 +29,18 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
|
|
|
34
29
|
/>
|
|
35
30
|
<WithSelect(WithDispatch(BaseOption))
|
|
36
31
|
featureName="showIconLabels"
|
|
37
|
-
help="
|
|
38
|
-
label="
|
|
32
|
+
help="Show text instead of icons on buttons."
|
|
33
|
+
label="Show button text labels"
|
|
34
|
+
/>
|
|
35
|
+
<WithSelect(WithDispatch(BaseOption))
|
|
36
|
+
featureName="showListViewByDefault"
|
|
37
|
+
help="Opens the block list view sidebar by default."
|
|
38
|
+
label="Always open list view"
|
|
39
|
+
/>
|
|
40
|
+
<WithSelect(WithDispatch(BaseOption))
|
|
41
|
+
featureName="reducedUI"
|
|
42
|
+
help="Compacts options and outlines in the toolbar."
|
|
43
|
+
label="Reduce the interface"
|
|
39
44
|
/>
|
|
40
45
|
<WithSelect(WithDispatch(BaseOption))
|
|
41
46
|
featureName="themeStyles"
|
|
@@ -148,11 +153,6 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
|
|
|
148
153
|
description="Customize options related to the block editor interface and editing flow."
|
|
149
154
|
title="Appearance"
|
|
150
155
|
>
|
|
151
|
-
<WithSelect(WithDispatch(BaseOption))
|
|
152
|
-
featureName="reducedUI"
|
|
153
|
-
help="Compacts options and outlines in the toolbar."
|
|
154
|
-
label="Reduce the interface"
|
|
155
|
-
/>
|
|
156
156
|
<WithSelect(WithDispatch(BaseOption))
|
|
157
157
|
featureName="focusMode"
|
|
158
158
|
help="Highlights the current block and fades other content."
|
|
@@ -160,8 +160,18 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
|
|
|
160
160
|
/>
|
|
161
161
|
<WithSelect(WithDispatch(BaseOption))
|
|
162
162
|
featureName="showIconLabels"
|
|
163
|
-
help="
|
|
164
|
-
label="
|
|
163
|
+
help="Show text instead of icons on buttons."
|
|
164
|
+
label="Show button text labels"
|
|
165
|
+
/>
|
|
166
|
+
<WithSelect(WithDispatch(BaseOption))
|
|
167
|
+
featureName="showListViewByDefault"
|
|
168
|
+
help="Opens the block list view sidebar by default."
|
|
169
|
+
label="Always open list view"
|
|
170
|
+
/>
|
|
171
|
+
<WithSelect(WithDispatch(BaseOption))
|
|
172
|
+
featureName="reducedUI"
|
|
173
|
+
help="Compacts options and outlines in the toolbar."
|
|
174
|
+
label="Reduce the interface"
|
|
165
175
|
/>
|
|
166
176
|
<WithSelect(WithDispatch(BaseOption))
|
|
167
177
|
featureName="themeStyles"
|
|
@@ -18,7 +18,7 @@ export function PostSchedule() {
|
|
|
18
18
|
<PanelRow className="edit-post-post-schedule" ref={ anchorRef }>
|
|
19
19
|
<span>{ __( 'Publish' ) }</span>
|
|
20
20
|
<Dropdown
|
|
21
|
-
popoverProps={ { anchorRef
|
|
21
|
+
popoverProps={ { anchorRef } }
|
|
22
22
|
position="bottom left"
|
|
23
23
|
contentClassName="edit-post-post-schedule__dialog"
|
|
24
24
|
renderToggle={ ( { onToggle, isOpen } ) => (
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
text-align: right;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
// Zero out a blanket padding that is set on the
|
|
16
|
+
// Zero out a blanket padding that is set on the dropdown component.
|
|
17
17
|
// The datetime component has its own padding.
|
|
18
|
-
.edit-post-post-schedule__dialog .components-popover__content
|
|
18
|
+
.edit-post-post-schedule__dialog .components-popover__content {
|
|
19
19
|
padding: 0;
|
|
20
20
|
}
|
|
@@ -48,6 +48,6 @@
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
&.is-active:focus {
|
|
51
|
-
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color), inset 0
|
|
51
|
+
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color), inset 0 -#{$border-width-tab * 2} 0 0 var(--wp-admin-theme-color);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -8,30 +8,34 @@ import {
|
|
|
8
8
|
store as editorStore,
|
|
9
9
|
} from '@wordpress/editor';
|
|
10
10
|
import { Button } from '@wordpress/components';
|
|
11
|
-
import {
|
|
11
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
12
12
|
import { __ } from '@wordpress/i18n';
|
|
13
13
|
import { displayShortcut } from '@wordpress/keycodes';
|
|
14
|
-
import { compose } from '@wordpress/compose';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Internal dependencies
|
|
18
17
|
*/
|
|
19
18
|
import { store as editPostStore } from '../../store';
|
|
20
19
|
|
|
21
|
-
function TextEditor(
|
|
20
|
+
export default function TextEditor() {
|
|
21
|
+
const isRichEditingEnabled = useSelect( ( select ) => {
|
|
22
|
+
return select( editorStore ).getEditorSettings().richEditingEnabled;
|
|
23
|
+
}, [] );
|
|
24
|
+
const { switchEditorMode } = useDispatch( editPostStore );
|
|
25
|
+
|
|
22
26
|
return (
|
|
23
27
|
<div className="edit-post-text-editor">
|
|
28
|
+
<TextEditorGlobalKeyboardShortcuts />
|
|
24
29
|
{ isRichEditingEnabled && (
|
|
25
30
|
<div className="edit-post-text-editor__toolbar">
|
|
26
31
|
<h2>{ __( 'Editing code' ) }</h2>
|
|
27
32
|
<Button
|
|
28
33
|
variant="tertiary"
|
|
29
|
-
onClick={
|
|
34
|
+
onClick={ () => switchEditorMode( 'visual' ) }
|
|
30
35
|
shortcut={ displayShortcut.secondary( 'm' ) }
|
|
31
36
|
>
|
|
32
37
|
{ __( 'Exit code editor' ) }
|
|
33
38
|
</Button>
|
|
34
|
-
<TextEditorGlobalKeyboardShortcuts />
|
|
35
39
|
</div>
|
|
36
40
|
) }
|
|
37
41
|
<div className="edit-post-text-editor__body">
|
|
@@ -41,17 +45,3 @@ function TextEditor( { onExit, isRichEditingEnabled } ) {
|
|
|
41
45
|
</div>
|
|
42
46
|
);
|
|
43
47
|
}
|
|
44
|
-
|
|
45
|
-
export default compose(
|
|
46
|
-
withSelect( ( select ) => ( {
|
|
47
|
-
isRichEditingEnabled: select( editorStore ).getEditorSettings()
|
|
48
|
-
.richEditingEnabled,
|
|
49
|
-
} ) ),
|
|
50
|
-
withDispatch( ( dispatch ) => {
|
|
51
|
-
return {
|
|
52
|
-
onExit() {
|
|
53
|
-
dispatch( editPostStore ).switchEditorMode( 'visual' );
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
} )
|
|
57
|
-
)( TextEditor );
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { initializeEditor, fireEvent } from 'test/helpers';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
|
|
10
|
+
import { registerCoreBlocks } from '@wordpress/block-library';
|
|
11
|
+
|
|
12
|
+
beforeAll( () => {
|
|
13
|
+
// Register all core blocks
|
|
14
|
+
registerCoreBlocks();
|
|
15
|
+
} );
|
|
16
|
+
|
|
17
|
+
afterAll( () => {
|
|
18
|
+
// Clean up registered blocks
|
|
19
|
+
getBlockTypes().forEach( ( block ) => {
|
|
20
|
+
unregisterBlockType( block.name );
|
|
21
|
+
} );
|
|
22
|
+
} );
|
|
23
|
+
|
|
24
|
+
const initialHtml = `
|
|
25
|
+
<!-- wp:paragraph -->
|
|
26
|
+
<p>First example paragraph.</p>
|
|
27
|
+
<!-- /wp:paragraph -->
|
|
28
|
+
|
|
29
|
+
<!-- wp:paragraph -->
|
|
30
|
+
<p>Second example paragraph.</p>
|
|
31
|
+
<!-- /wp:paragraph -->
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
describe( 'when title is focused', () => {
|
|
35
|
+
it( 'new blocks are inserted after the title', async () => {
|
|
36
|
+
const screen = await initializeEditor( {
|
|
37
|
+
initialHtml,
|
|
38
|
+
} );
|
|
39
|
+
|
|
40
|
+
// Focus first block
|
|
41
|
+
fireEvent.press( screen.getByA11yLabel( /Paragraph Block. Row 1/ ) );
|
|
42
|
+
|
|
43
|
+
// Focus title
|
|
44
|
+
fireEvent(
|
|
45
|
+
screen.getAllByA11yLabel( 'Post title. test' )[ 0 ],
|
|
46
|
+
'select'
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// Add new Heading block
|
|
50
|
+
fireEvent.press( screen.getByA11yLabel( 'Add block' ) );
|
|
51
|
+
fireEvent.press( screen.getByText( 'Heading' ) );
|
|
52
|
+
|
|
53
|
+
expect( screen.getByA11yLabel( /Heading Block. Row 1/ ) ).toBeDefined();
|
|
54
|
+
expect(
|
|
55
|
+
screen.getByA11yLabel( /Paragraph Block. Row 2/ )
|
|
56
|
+
).toBeDefined();
|
|
57
|
+
expect(
|
|
58
|
+
screen.getByA11yLabel( /Paragraph Block. Row 3/ )
|
|
59
|
+
).toBeDefined();
|
|
60
|
+
} );
|
|
61
|
+
} );
|
|
62
|
+
|
|
63
|
+
describe( 'when title is no longer focused', () => {
|
|
64
|
+
it( 'new blocks are inserted after the currently focused block', async () => {
|
|
65
|
+
const screen = await initializeEditor( {
|
|
66
|
+
initialHtml,
|
|
67
|
+
} );
|
|
68
|
+
|
|
69
|
+
// Focus first block
|
|
70
|
+
fireEvent.press( screen.getByA11yLabel( /Paragraph Block. Row 1/ ) );
|
|
71
|
+
|
|
72
|
+
// Focus title
|
|
73
|
+
fireEvent(
|
|
74
|
+
screen.getAllByA11yLabel( 'Post title. test' )[ 0 ],
|
|
75
|
+
'select'
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// Focus last block
|
|
79
|
+
fireEvent.press( screen.getByA11yLabel( /Paragraph Block. Row 2/ ) );
|
|
80
|
+
|
|
81
|
+
// Add new Heading block
|
|
82
|
+
fireEvent.press( screen.getByA11yLabel( 'Add block' ) );
|
|
83
|
+
fireEvent.press( screen.getByText( 'Heading' ) );
|
|
84
|
+
|
|
85
|
+
expect(
|
|
86
|
+
screen.getByA11yLabel( /Paragraph Block. Row 1/ )
|
|
87
|
+
).toBeDefined();
|
|
88
|
+
expect(
|
|
89
|
+
screen.getByA11yLabel( /Paragraph Block. Row 2/ )
|
|
90
|
+
).toBeDefined();
|
|
91
|
+
expect( screen.getByA11yLabel( /Heading Block. Row 3/ ) ).toBeDefined();
|
|
92
|
+
} );
|
|
93
|
+
} );
|
package/src/index.js
CHANGED
|
@@ -117,12 +117,19 @@ export function initializeEditor(
|
|
|
117
117
|
preferredStyleVariations: {},
|
|
118
118
|
showBlockBreadcrumbs: true,
|
|
119
119
|
showIconLabels: false,
|
|
120
|
+
showListViewByDefault: false,
|
|
120
121
|
themeStyles: true,
|
|
121
122
|
welcomeGuide: true,
|
|
122
123
|
welcomeGuideTemplate: true,
|
|
123
124
|
} );
|
|
124
125
|
|
|
125
126
|
dispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();
|
|
127
|
+
|
|
128
|
+
// Check if the block list view should be open by default.
|
|
129
|
+
if ( select( editPostStore ).isFeatureActive( 'showListViewByDefault' ) ) {
|
|
130
|
+
dispatch( editPostStore ).setIsListViewOpened( true );
|
|
131
|
+
}
|
|
132
|
+
|
|
126
133
|
registerCoreBlocks();
|
|
127
134
|
if ( process.env.IS_GUTENBERG_PLUGIN ) {
|
|
128
135
|
__experimentalRegisterExperimentalCoreBlocks( {
|