@wordpress/editor 11.0.2 → 12.0.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 +7 -0
- package/README.md +1 -1
- package/build/components/character-count/index.js +1 -1
- package/build/components/character-count/index.js.map +1 -1
- package/build/components/editor-help/help-get-support-button.native.js +46 -0
- package/build/components/editor-help/help-get-support-button.native.js.map +1 -0
- package/build/components/editor-help/index.native.js +20 -2
- package/build/components/editor-help/index.native.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/save-shortcut.js +12 -14
- package/build/components/global-keyboard-shortcuts/save-shortcut.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +0 -4
- package/build/components/global-keyboard-shortcuts/visual-editor-shortcuts.js.map +1 -1
- package/build/components/post-format/index.js +3 -1
- package/build/components/post-format/index.js.map +1 -1
- package/build/components/post-locked-modal/index.js +1 -1
- package/build/components/post-locked-modal/index.js.map +1 -1
- package/build/components/post-saved-state/index.js +37 -46
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-title/index.js +1 -1
- package/build/components/post-title/index.js.map +1 -1
- package/build/components/provider/index.native.js +3 -1
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +31 -4
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/word-count/index.js +1 -1
- package/build/components/word-count/index.js.map +1 -1
- package/build/store/actions.js +0 -25
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +3 -84
- package/build/store/selectors.js.map +1 -1
- package/build/{store/utils → utils}/get-template-part-icon.js +0 -0
- package/build/utils/get-template-part-icon.js.map +1 -0
- package/build/utils/index.js +8 -0
- package/build/utils/index.js.map +1 -1
- package/build-module/components/character-count/index.js +1 -1
- package/build-module/components/character-count/index.js.map +1 -1
- package/build-module/components/editor-help/help-get-support-button.native.js +34 -0
- package/build-module/components/editor-help/help-get-support-button.native.js.map +1 -0
- package/build-module/components/editor-help/index.native.js +18 -3
- package/build-module/components/editor-help/index.native.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/save-shortcut.js +12 -14
- package/build-module/components/global-keyboard-shortcuts/save-shortcut.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +0 -4
- package/build-module/components/global-keyboard-shortcuts/visual-editor-shortcuts.js.map +1 -1
- package/build-module/components/post-format/index.js +4 -2
- package/build-module/components/post-format/index.js.map +1 -1
- package/build-module/components/post-locked-modal/index.js +1 -1
- package/build-module/components/post-locked-modal/index.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +38 -46
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-title/index.js +1 -1
- package/build-module/components/post-title/index.js.map +1 -1
- package/build-module/components/provider/index.native.js +3 -1
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +30 -4
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/word-count/index.js +1 -1
- package/build-module/components/word-count/index.js.map +1 -1
- package/build-module/store/actions.js +0 -23
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +3 -80
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/{store/utils → utils}/get-template-part-icon.js +0 -0
- package/build-module/utils/get-template-part-icon.js.map +1 -0
- package/build-module/utils/index.js +1 -0
- package/build-module/utils/index.js.map +1 -1
- package/build-style/style-rtl.css +6 -1
- package/build-style/style.css +6 -1
- package/package.json +28 -28
- package/src/components/character-count/index.js +3 -2
- package/src/components/editor-help/help-get-support-button.native.js +38 -0
- package/src/components/editor-help/index.native.js +41 -1
- package/src/components/editor-help/style.android.scss +6 -0
- package/src/components/editor-help/style.ios.scss +6 -0
- package/src/components/editor-help/style.scss +21 -0
- package/src/components/editor-help/test/index.native.js +80 -0
- package/src/components/global-keyboard-shortcuts/save-shortcut.js +34 -42
- package/src/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +8 -16
- package/src/components/post-format/index.js +6 -2
- package/src/components/post-format/style.scss +1 -0
- package/src/components/post-locked-modal/index.js +1 -1
- package/src/components/post-saved-state/index.js +41 -55
- package/src/components/post-saved-state/style.scss +8 -1
- package/src/components/post-saved-state/test/__snapshots__/index.js.snap +20 -0
- package/src/components/post-saved-state/test/index.js +2 -2
- package/src/components/post-title/index.js +1 -1
- package/src/components/provider/index.native.js +2 -0
- package/src/components/provider/use-block-editor-settings.js +24 -0
- package/src/components/word-count/index.js +3 -2
- package/src/store/actions.js +0 -28
- package/src/store/selectors.js +2 -105
- package/src/{store/utils → utils}/get-template-part-icon.js +0 -0
- package/src/utils/index.js +1 -0
- package/build/store/utils/get-template-part-icon.js.map +0 -1
- package/build-module/store/utils/get-template-part-icon.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/editor",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.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.13.10",
|
|
34
|
-
"@wordpress/a11y": "^3.2.
|
|
35
|
-
"@wordpress/api-fetch": "^5.2.
|
|
36
|
-
"@wordpress/autop": "^3.2.
|
|
34
|
+
"@wordpress/a11y": "^3.2.3",
|
|
35
|
+
"@wordpress/api-fetch": "^5.2.3",
|
|
36
|
+
"@wordpress/autop": "^3.2.2",
|
|
37
37
|
"@wordpress/blob": "^3.2.1",
|
|
38
|
-
"@wordpress/block-editor": "^7.0.
|
|
39
|
-
"@wordpress/blocks": "^11.1.
|
|
40
|
-
"@wordpress/components": "^
|
|
41
|
-
"@wordpress/compose": "^5.0.
|
|
42
|
-
"@wordpress/core-data": "^4.0.
|
|
43
|
-
"@wordpress/data": "^6.1.
|
|
44
|
-
"@wordpress/data-controls": "^2.2.
|
|
45
|
-
"@wordpress/date": "^4.2.
|
|
46
|
-
"@wordpress/deprecated": "^3.2.
|
|
47
|
-
"@wordpress/element": "^4.0.
|
|
48
|
-
"@wordpress/hooks": "^3.2.
|
|
49
|
-
"@wordpress/html-entities": "^3.2.
|
|
50
|
-
"@wordpress/i18n": "^4.2.
|
|
51
|
-
"@wordpress/icons": "^
|
|
38
|
+
"@wordpress/block-editor": "^7.0.3",
|
|
39
|
+
"@wordpress/blocks": "^11.1.1",
|
|
40
|
+
"@wordpress/components": "^18.0.0",
|
|
41
|
+
"@wordpress/compose": "^5.0.3",
|
|
42
|
+
"@wordpress/core-data": "^4.0.3",
|
|
43
|
+
"@wordpress/data": "^6.1.1",
|
|
44
|
+
"@wordpress/data-controls": "^2.2.4",
|
|
45
|
+
"@wordpress/date": "^4.2.2",
|
|
46
|
+
"@wordpress/deprecated": "^3.2.2",
|
|
47
|
+
"@wordpress/element": "^4.0.2",
|
|
48
|
+
"@wordpress/hooks": "^3.2.1",
|
|
49
|
+
"@wordpress/html-entities": "^3.2.2",
|
|
50
|
+
"@wordpress/i18n": "^4.2.3",
|
|
51
|
+
"@wordpress/icons": "^6.0.0",
|
|
52
52
|
"@wordpress/is-shallow-equal": "^4.2.0",
|
|
53
|
-
"@wordpress/keyboard-shortcuts": "^3.0.
|
|
54
|
-
"@wordpress/keycodes": "^3.2.
|
|
55
|
-
"@wordpress/media-utils": "^3.0.
|
|
56
|
-
"@wordpress/notices": "^3.2.
|
|
57
|
-
"@wordpress/reusable-blocks": "^3.0.
|
|
58
|
-
"@wordpress/rich-text": "^5.0.
|
|
59
|
-
"@wordpress/server-side-render": "^3.0.
|
|
60
|
-
"@wordpress/url": "^3.2.
|
|
61
|
-
"@wordpress/wordcount": "^3.2.
|
|
53
|
+
"@wordpress/keyboard-shortcuts": "^3.0.3",
|
|
54
|
+
"@wordpress/keycodes": "^3.2.3",
|
|
55
|
+
"@wordpress/media-utils": "^3.0.2",
|
|
56
|
+
"@wordpress/notices": "^3.2.4",
|
|
57
|
+
"@wordpress/reusable-blocks": "^3.0.3",
|
|
58
|
+
"@wordpress/rich-text": "^5.0.3",
|
|
59
|
+
"@wordpress/server-side-render": "^3.0.3",
|
|
60
|
+
"@wordpress/url": "^3.2.3",
|
|
61
|
+
"@wordpress/wordcount": "^3.2.2",
|
|
62
62
|
"classnames": "^2.3.1",
|
|
63
63
|
"lodash": "^4.17.21",
|
|
64
64
|
"memize": "^1.1.0",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"publishConfig": {
|
|
69
69
|
"access": "public"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "8f7f052bc04e3f4eb50f479ced14be1489b9fa79"
|
|
72
72
|
}
|
|
@@ -10,8 +10,9 @@ import { count as characterCount } from '@wordpress/wordcount';
|
|
|
10
10
|
import { store as editorStore } from '../../store';
|
|
11
11
|
|
|
12
12
|
export default function CharacterCount() {
|
|
13
|
-
const content = useSelect(
|
|
14
|
-
select( editorStore ).getEditedPostAttribute( 'content' )
|
|
13
|
+
const content = useSelect(
|
|
14
|
+
( select ) => select( editorStore ).getEditedPostAttribute( 'content' ),
|
|
15
|
+
[]
|
|
15
16
|
);
|
|
16
17
|
|
|
17
18
|
return characterCount( content, 'characters_including_spaces' );
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { Pressable, Text } from 'react-native';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import styles from './style.scss';
|
|
15
|
+
|
|
16
|
+
const HelpGetSupportButton = ( { onPress, title } ) => {
|
|
17
|
+
const buttonStyle = usePreferredColorSchemeStyle(
|
|
18
|
+
styles.button,
|
|
19
|
+
styles.buttonDark
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const textStyle = usePreferredColorSchemeStyle(
|
|
23
|
+
styles.buttonText,
|
|
24
|
+
styles.buttonTextDark
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<Pressable
|
|
29
|
+
style={ buttonStyle }
|
|
30
|
+
onPress={ onPress }
|
|
31
|
+
accessibilityRole={ 'button' }
|
|
32
|
+
>
|
|
33
|
+
<Text style={ textStyle }>{ title }</Text>
|
|
34
|
+
</Pressable>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default HelpGetSupportButton;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { kebabCase } from 'lodash';
|
|
5
|
-
import { ScrollView, StyleSheet, View } from 'react-native';
|
|
5
|
+
import { Text, ScrollView, StyleSheet, View } from 'react-native';
|
|
6
6
|
import { TransitionPresets } from '@react-navigation/stack';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -23,6 +23,11 @@ import {
|
|
|
23
23
|
} from '@wordpress/icons';
|
|
24
24
|
import { useSelect } from '@wordpress/data';
|
|
25
25
|
import { store as editorStore } from '@wordpress/editor';
|
|
26
|
+
import { usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
27
|
+
import {
|
|
28
|
+
requestContactCustomerSupport,
|
|
29
|
+
requestGotoCustomerSupportOptions,
|
|
30
|
+
} from '@wordpress/react-native-bridge';
|
|
26
31
|
|
|
27
32
|
/**
|
|
28
33
|
* Internal dependencies
|
|
@@ -30,6 +35,7 @@ import { store as editorStore } from '@wordpress/editor';
|
|
|
30
35
|
import styles from './style.scss';
|
|
31
36
|
import HelpDetailNavigationScreen from './help-detail-navigation-screen';
|
|
32
37
|
import HelpTopicRow from './help-topic-row';
|
|
38
|
+
import HelpGetSupportButton from './help-get-support-button';
|
|
33
39
|
import IntroToBlocks from './intro-to-blocks';
|
|
34
40
|
import AddBlocks from './add-blocks';
|
|
35
41
|
import MoveBlocks from './move-blocks';
|
|
@@ -61,6 +67,11 @@ function EditorHelpTopics( { close, isVisible, onClose } ) {
|
|
|
61
67
|
postType: select( editorStore ).getEditedPostAttribute( 'type' ),
|
|
62
68
|
} ) );
|
|
63
69
|
|
|
70
|
+
const sectionTitle = usePreferredColorSchemeStyle(
|
|
71
|
+
styles.helpDetailSectionHeading,
|
|
72
|
+
styles.helpDetailSectionHeadingDark
|
|
73
|
+
);
|
|
74
|
+
|
|
64
75
|
const title =
|
|
65
76
|
postType === 'page'
|
|
66
77
|
? __( 'How to edit your page' )
|
|
@@ -73,6 +84,7 @@ function EditorHelpTopics( { close, isVisible, onClose } ) {
|
|
|
73
84
|
hideHeader
|
|
74
85
|
hasNavigation
|
|
75
86
|
contentStyle={ styles.contentContainer }
|
|
87
|
+
testID="editor-help-modal"
|
|
76
88
|
>
|
|
77
89
|
<BottomSheet.NavigationContainer animate main>
|
|
78
90
|
<BottomSheet.NavigationScreen
|
|
@@ -113,6 +125,9 @@ function EditorHelpTopics( { close, isVisible, onClose } ) {
|
|
|
113
125
|
} }
|
|
114
126
|
>
|
|
115
127
|
<PanelBody>
|
|
128
|
+
<Text style={ sectionTitle }>
|
|
129
|
+
{ __( 'The basics' ) }
|
|
130
|
+
</Text>
|
|
116
131
|
{ /* Print out help topics */ }
|
|
117
132
|
{ HELP_TOPICS.map(
|
|
118
133
|
( { label, icon } ) => {
|
|
@@ -131,6 +146,31 @@ function EditorHelpTopics( { close, isVisible, onClose } ) {
|
|
|
131
146
|
);
|
|
132
147
|
}
|
|
133
148
|
) }
|
|
149
|
+
{
|
|
150
|
+
<Text style={ sectionTitle }>
|
|
151
|
+
{ __( 'Get support' ) }
|
|
152
|
+
</Text>
|
|
153
|
+
}
|
|
154
|
+
{
|
|
155
|
+
<HelpGetSupportButton
|
|
156
|
+
title={ __(
|
|
157
|
+
'Contact support'
|
|
158
|
+
) }
|
|
159
|
+
onPress={
|
|
160
|
+
requestContactCustomerSupport
|
|
161
|
+
}
|
|
162
|
+
/>
|
|
163
|
+
}
|
|
164
|
+
{
|
|
165
|
+
<HelpGetSupportButton
|
|
166
|
+
title={ __(
|
|
167
|
+
'More support options'
|
|
168
|
+
) }
|
|
169
|
+
onPress={
|
|
170
|
+
requestGotoCustomerSupportOptions
|
|
171
|
+
}
|
|
172
|
+
/>
|
|
173
|
+
}
|
|
134
174
|
</PanelBody>
|
|
135
175
|
</ScrollView>
|
|
136
176
|
);
|
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
.button {
|
|
2
|
+
margin: $grid-unit-10 $grid-unit-05;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
border: $border-width solid $gray-300;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.buttonDark {
|
|
9
|
+
border-color: $gray-700;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.buttonText {
|
|
13
|
+
font-weight: 600;
|
|
14
|
+
font-size: 16px;
|
|
15
|
+
color: $light-primary;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.buttonTextDark {
|
|
19
|
+
color: $dark-primary;
|
|
20
|
+
}
|
|
21
|
+
|
|
1
22
|
.container {
|
|
2
23
|
height: 100%;
|
|
3
24
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { fireEvent, render, waitForElementToBeRemoved } from 'test/helpers';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import EditorHelp from '../index';
|
|
10
|
+
|
|
11
|
+
it( 'lists help topics', async () => {
|
|
12
|
+
const screen = render( <EditorHelp isVisible /> );
|
|
13
|
+
const helpTopic = await screen.findByText( 'Customize blocks' );
|
|
14
|
+
|
|
15
|
+
expect( helpTopic ).toBeTruthy();
|
|
16
|
+
} );
|
|
17
|
+
|
|
18
|
+
it( 'navigates to help topic detail screen', async () => {
|
|
19
|
+
const screen = render( <EditorHelp isVisible /> );
|
|
20
|
+
const helpTopic = await screen.findByText( 'Customize blocks' );
|
|
21
|
+
fireEvent.press( helpTopic );
|
|
22
|
+
|
|
23
|
+
expect(
|
|
24
|
+
screen.getByText(
|
|
25
|
+
'Each block has its own settings. To find them, tap on a block. Its settings will appear on the toolbar at the bottom of the screen.'
|
|
26
|
+
)
|
|
27
|
+
).toBeTruthy();
|
|
28
|
+
} );
|
|
29
|
+
|
|
30
|
+
it( 'navigates back from help topic detail screen', async () => {
|
|
31
|
+
const screen = render( <EditorHelp isVisible /> );
|
|
32
|
+
const helpTopic = await screen.findByText( 'Customize blocks' );
|
|
33
|
+
fireEvent.press( helpTopic );
|
|
34
|
+
|
|
35
|
+
const backButton = screen.getAllByA11yLabel( 'Go back' );
|
|
36
|
+
fireEvent.press( backButton[ backButton.length - 1 ] );
|
|
37
|
+
|
|
38
|
+
// Currently logs `act` warning due to https://git.io/JYYGE
|
|
39
|
+
await waitForElementToBeRemoved( () =>
|
|
40
|
+
screen.getByText(
|
|
41
|
+
'Each block has its own settings. To find them, tap on a block. Its settings will appear on the toolbar at the bottom of the screen.'
|
|
42
|
+
)
|
|
43
|
+
);
|
|
44
|
+
} );
|
|
45
|
+
|
|
46
|
+
it( 'dismisses when close button is pressed', async () => {
|
|
47
|
+
const closeMock = jest.fn();
|
|
48
|
+
const screen = render( <EditorHelp isVisible close={ closeMock } /> );
|
|
49
|
+
const closeButton = await screen.findByA11yLabel( 'Go back' );
|
|
50
|
+
fireEvent.press( closeButton );
|
|
51
|
+
|
|
52
|
+
expect( closeMock ).toHaveBeenCalled();
|
|
53
|
+
} );
|
|
54
|
+
|
|
55
|
+
it( 'dismisses when parent modal backdrop is pressed', async () => {
|
|
56
|
+
const onCloseMock = jest.fn();
|
|
57
|
+
const screen = render( <EditorHelp isVisible onClose={ onCloseMock } /> );
|
|
58
|
+
const modal = await screen.findByTestId( 'editor-help-modal' );
|
|
59
|
+
fireEvent( modal, 'backdropPress' );
|
|
60
|
+
|
|
61
|
+
expect( onCloseMock ).toHaveBeenCalled();
|
|
62
|
+
} );
|
|
63
|
+
|
|
64
|
+
it( 'dismisses when parent modal backdrop is swiped', async () => {
|
|
65
|
+
const onCloseMock = jest.fn();
|
|
66
|
+
const screen = render( <EditorHelp isVisible onClose={ onCloseMock } /> );
|
|
67
|
+
const modal = await screen.findByTestId( 'editor-help-modal' );
|
|
68
|
+
fireEvent( modal, 'swipeComplete' );
|
|
69
|
+
|
|
70
|
+
expect( onCloseMock ).toHaveBeenCalled();
|
|
71
|
+
} );
|
|
72
|
+
|
|
73
|
+
it( 'dismisses when hardware back button is pressed', async () => {
|
|
74
|
+
const onCloseMock = jest.fn();
|
|
75
|
+
const screen = render( <EditorHelp isVisible onClose={ onCloseMock } /> );
|
|
76
|
+
const modal = await screen.findByTestId( 'editor-help-modal' );
|
|
77
|
+
fireEvent( modal, 'backButtonPress' );
|
|
78
|
+
|
|
79
|
+
expect( onCloseMock ).toHaveBeenCalled();
|
|
80
|
+
} );
|
|
@@ -12,51 +12,43 @@ import { store as editorStore } from '../../store';
|
|
|
12
12
|
|
|
13
13
|
function SaveShortcut( { resetBlocksOnSave } ) {
|
|
14
14
|
const { resetEditorBlocks, savePost } = useDispatch( editorStore );
|
|
15
|
-
const { isEditedPostDirty, getPostEdits } = useSelect(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
getPostEdits: _getPostEdits,
|
|
19
|
-
} = select( editorStore );
|
|
20
|
-
|
|
21
|
-
return {
|
|
22
|
-
isEditedPostDirty: _isEditedPostDirty,
|
|
23
|
-
getPostEdits: _getPostEdits,
|
|
24
|
-
};
|
|
25
|
-
}, [] );
|
|
26
|
-
|
|
27
|
-
useShortcut(
|
|
28
|
-
'core/editor/save',
|
|
29
|
-
( event ) => {
|
|
30
|
-
event.preventDefault();
|
|
31
|
-
|
|
32
|
-
// TODO: This should be handled in the `savePost` effect in
|
|
33
|
-
// considering `isSaveable`. See note on `isEditedPostSaveable`
|
|
34
|
-
// selector about dirtiness and meta-boxes.
|
|
35
|
-
//
|
|
36
|
-
// See: `isEditedPostSaveable`
|
|
37
|
-
if ( ! isEditedPostDirty() ) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
15
|
+
const { isEditedPostDirty, getPostEdits, isPostSavingLocked } = useSelect(
|
|
16
|
+
editorStore
|
|
17
|
+
);
|
|
40
18
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
19
|
+
useShortcut( 'core/editor/save', ( event ) => {
|
|
20
|
+
event.preventDefault();
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Do not save the post if post saving is locked.
|
|
24
|
+
*/
|
|
25
|
+
if ( isPostSavingLocked() ) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// TODO: This should be handled in the `savePost` effect in
|
|
30
|
+
// considering `isSaveable`. See note on `isEditedPostSaveable`
|
|
31
|
+
// selector about dirtiness and meta-boxes.
|
|
32
|
+
//
|
|
33
|
+
// See: `isEditedPostSaveable`
|
|
34
|
+
if ( ! isEditedPostDirty() ) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// The text editor requires that editor blocks are updated for a
|
|
39
|
+
// save to work correctly. Usually this happens when the textarea
|
|
40
|
+
// for the code editors blurs, but the shortcut can be used without
|
|
41
|
+
// blurring the textarea.
|
|
42
|
+
if ( resetBlocksOnSave ) {
|
|
43
|
+
const postEdits = getPostEdits();
|
|
44
|
+
if ( postEdits.content && typeof postEdits.content === 'string' ) {
|
|
45
|
+
const blocks = parse( postEdits.content );
|
|
46
|
+
resetEditorBlocks( blocks );
|
|
54
47
|
}
|
|
48
|
+
}
|
|
55
49
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
{ bindGlobal: true }
|
|
59
|
-
);
|
|
50
|
+
savePost();
|
|
51
|
+
} );
|
|
60
52
|
|
|
61
53
|
return null;
|
|
62
54
|
}
|
|
@@ -13,23 +13,15 @@ import { store as editorStore } from '../../store';
|
|
|
13
13
|
function VisualEditorGlobalKeyboardShortcuts() {
|
|
14
14
|
const { redo, undo } = useDispatch( editorStore );
|
|
15
15
|
|
|
16
|
-
useShortcut(
|
|
17
|
-
|
|
18
|
-
(
|
|
19
|
-
|
|
20
|
-
event.preventDefault();
|
|
21
|
-
},
|
|
22
|
-
{ bindGlobal: true }
|
|
23
|
-
);
|
|
16
|
+
useShortcut( 'core/editor/undo', ( event ) => {
|
|
17
|
+
undo();
|
|
18
|
+
event.preventDefault();
|
|
19
|
+
} );
|
|
24
20
|
|
|
25
|
-
useShortcut(
|
|
26
|
-
|
|
27
|
-
(
|
|
28
|
-
|
|
29
|
-
event.preventDefault();
|
|
30
|
-
},
|
|
31
|
-
{ bindGlobal: true }
|
|
32
|
-
);
|
|
21
|
+
useShortcut( 'core/editor/redo', ( event ) => {
|
|
22
|
+
redo();
|
|
23
|
+
event.preventDefault();
|
|
24
|
+
} );
|
|
33
25
|
|
|
34
26
|
return <SaveShortcut />;
|
|
35
27
|
}
|
|
@@ -6,7 +6,7 @@ import { find, get, includes, union } from 'lodash';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { __ } from '@wordpress/i18n';
|
|
9
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
10
10
|
import { Button, SelectControl } from '@wordpress/components';
|
|
11
11
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
12
12
|
import { useInstanceId } from '@wordpress/compose';
|
|
@@ -107,7 +107,11 @@ export default function PostFormat() {
|
|
|
107
107
|
onUpdatePostFormat( suggestion.id )
|
|
108
108
|
}
|
|
109
109
|
>
|
|
110
|
-
{
|
|
110
|
+
{ sprintf(
|
|
111
|
+
/* translators: %s: post format */
|
|
112
|
+
__( 'Apply format: %s' ),
|
|
113
|
+
suggestion.caption
|
|
114
|
+
) }
|
|
111
115
|
</Button>
|
|
112
116
|
</div>
|
|
113
117
|
) }
|
|
@@ -100,79 +100,65 @@ export default function PostSavedState( {
|
|
|
100
100
|
return () => clearTimeout( timeoutId );
|
|
101
101
|
}, [ isSaving ] );
|
|
102
102
|
|
|
103
|
-
if ( isSaving ) {
|
|
104
|
-
// TODO: Classes generation should be common across all return
|
|
105
|
-
// paths of this function, including proper naming convention for
|
|
106
|
-
// the "Save Draft" button.
|
|
107
|
-
const classes = classnames(
|
|
108
|
-
'editor-post-saved-state',
|
|
109
|
-
'is-saving',
|
|
110
|
-
getAnimateClassName( { type: 'loading' } ),
|
|
111
|
-
{
|
|
112
|
-
'is-autosaving': isAutosaving,
|
|
113
|
-
}
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
return (
|
|
117
|
-
<span className={ classes }>
|
|
118
|
-
<Icon icon={ cloud } />
|
|
119
|
-
{ isAutosaving ? __( 'Autosaving' ) : __( 'Saving' ) }
|
|
120
|
-
</span>
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if ( isPublished || isScheduled ) {
|
|
125
|
-
return <PostSwitchToDraftButton />;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if ( ! isSaveable ) {
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if ( forceSavedMessage || ( ! isNew && ! isDirty ) ) {
|
|
133
|
-
return (
|
|
134
|
-
<span className="editor-post-saved-state is-saved">
|
|
135
|
-
<Icon icon={ check } />
|
|
136
|
-
{ __( 'Saved' ) }
|
|
137
|
-
</span>
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
103
|
// Once the post has been submitted for review this button
|
|
142
104
|
// is not needed for the contributor role.
|
|
143
|
-
|
|
144
105
|
if ( ! hasPublishAction && isPending ) {
|
|
145
106
|
return null;
|
|
146
107
|
}
|
|
147
108
|
|
|
109
|
+
if ( isPublished || isScheduled ) {
|
|
110
|
+
return <PostSwitchToDraftButton />;
|
|
111
|
+
}
|
|
112
|
+
|
|
148
113
|
/* translators: button label text should, if possible, be under 16 characters. */
|
|
149
114
|
const label = isPending ? __( 'Save as pending' ) : __( 'Save draft' );
|
|
150
115
|
|
|
151
116
|
/* translators: button label text should, if possible, be under 16 characters. */
|
|
152
117
|
const shortLabel = __( 'Save' );
|
|
153
118
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
119
|
+
const isSaved = forceSavedMessage || ( ! isNew && ! isDirty );
|
|
120
|
+
const isSavedState = isSaving || isSaved;
|
|
121
|
+
const isDisabled = isSaving || isSaved || ! isSaveable;
|
|
122
|
+
|
|
123
|
+
let text;
|
|
124
|
+
|
|
125
|
+
if ( isSaving ) {
|
|
126
|
+
text = isAutosaving ? __( 'Autosaving' ) : __( 'Saving' );
|
|
127
|
+
} else if ( isSaved ) {
|
|
128
|
+
text = __( 'Saved' );
|
|
129
|
+
} else if ( isLargeViewport ) {
|
|
130
|
+
text = label;
|
|
131
|
+
} else if ( showIconLabels ) {
|
|
132
|
+
text = shortLabel;
|
|
166
133
|
}
|
|
167
134
|
|
|
135
|
+
// Use common Button instance for all saved states so that focus is not
|
|
136
|
+
// lost.
|
|
168
137
|
return (
|
|
169
138
|
<Button
|
|
170
|
-
className=
|
|
171
|
-
|
|
139
|
+
className={
|
|
140
|
+
isSaveable || isSaving
|
|
141
|
+
? classnames( {
|
|
142
|
+
'editor-post-save-draft': ! isSavedState,
|
|
143
|
+
'editor-post-saved-state': isSavedState,
|
|
144
|
+
'is-saving': isSaving,
|
|
145
|
+
'is-autosaving': isAutosaving,
|
|
146
|
+
'is-saved': isSaved,
|
|
147
|
+
[ getAnimateClassName( {
|
|
148
|
+
type: 'loading',
|
|
149
|
+
} ) ]: isSaving,
|
|
150
|
+
} )
|
|
151
|
+
: undefined
|
|
152
|
+
}
|
|
153
|
+
onClick={ isDisabled ? undefined : () => savePost() }
|
|
172
154
|
shortcut={ displayShortcut.primary( 's' ) }
|
|
173
|
-
variant=
|
|
155
|
+
variant={ isLargeViewport ? 'tertiary' : undefined }
|
|
156
|
+
icon={ isLargeViewport ? undefined : cloudUpload }
|
|
157
|
+
label={ label }
|
|
158
|
+
aria-disabled={ isDisabled }
|
|
174
159
|
>
|
|
175
|
-
{
|
|
160
|
+
{ isSavedState && <Icon icon={ isSaved ? check : cloud } /> }
|
|
161
|
+
{ text }
|
|
176
162
|
</Button>
|
|
177
163
|
);
|
|
178
164
|
}
|
|
@@ -7,6 +7,13 @@
|
|
|
7
7
|
overflow: hidden;
|
|
8
8
|
white-space: nowrap;
|
|
9
9
|
|
|
10
|
+
// The disabled version of the save state should be legible as an indicator.
|
|
11
|
+
&.is-saved[aria-disabled="true"],
|
|
12
|
+
&.is-saved[aria-disabled="true"]:hover {
|
|
13
|
+
background: transparent;
|
|
14
|
+
color: $gray-700;
|
|
15
|
+
}
|
|
16
|
+
|
|
10
17
|
svg {
|
|
11
18
|
display: inline-block;
|
|
12
19
|
flex: 0 0 auto;
|
|
@@ -20,7 +27,7 @@
|
|
|
20
27
|
text-indent: inherit;
|
|
21
28
|
|
|
22
29
|
svg {
|
|
23
|
-
margin-right:
|
|
30
|
+
margin-right: 0;
|
|
24
31
|
}
|
|
25
32
|
}
|
|
26
33
|
}
|
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
+
exports[`PostSavedState returns a disabled button if the post is not saveable 1`] = `
|
|
4
|
+
<ForwardRef(Button)
|
|
5
|
+
aria-disabled={true}
|
|
6
|
+
icon={
|
|
7
|
+
<SVG
|
|
8
|
+
viewBox="0 0 24 24"
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
>
|
|
11
|
+
<Path
|
|
12
|
+
d="M17.3 10.1c0-2.5-2.1-4.4-4.8-4.4-2.2 0-4.1 1.4-4.6 3.3h-.2C5.7 9 4 10.7 4 12.8c0 2.1 1.7 3.8 3.7 3.8h9c1.8 0 3.2-1.5 3.2-3.3.1-1.6-1.1-2.9-2.6-3.2zm-.5 5.1h-4v-2.4L14 14l1-1-3-3-3 3 1 1 1.2-1.2v2.4H7.7c-1.2 0-2.2-1.1-2.2-2.3s1-2.4 2.2-2.4H9l.3-1.1c.4-1.3 1.7-2.2 3.2-2.2 1.8 0 3.3 1.3 3.3 2.9v1.3l1.3.2c.8.1 1.4.9 1.4 1.8 0 1-.8 1.8-1.7 1.8z"
|
|
13
|
+
/>
|
|
14
|
+
</SVG>
|
|
15
|
+
}
|
|
16
|
+
label="Save draft"
|
|
17
|
+
shortcut="Ctrl+S"
|
|
18
|
+
/>
|
|
19
|
+
`;
|
|
20
|
+
|
|
3
21
|
exports[`PostSavedState returns a switch to draft link if the post is published 1`] = `<WithSelect(WithDispatch(PostSwitchToDraftButton)) />`;
|
|
4
22
|
|
|
5
23
|
exports[`PostSavedState should return Save button if edits to be saved 1`] = `
|
|
6
24
|
<ForwardRef(Button)
|
|
25
|
+
aria-disabled={false}
|
|
7
26
|
className="editor-post-save-draft"
|
|
27
|
+
label="Save draft"
|
|
8
28
|
onClick={[Function]}
|
|
9
29
|
shortcut="Ctrl+S"
|
|
10
30
|
variant="tertiary"
|