@wordpress/editor 12.2.1 → 12.4.0-next.e230fbab09.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 +6 -0
- package/build/components/deprecated.js +1 -1
- package/build/components/deprecated.js.map +1 -1
- package/build/components/deprecated.native.js.map +1 -1
- package/build/components/editor-help/index.native.js.map +1 -1
- package/build/components/entities-saved-states/entity-record-item.js +1 -1
- package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js.map +1 -1
- package/build/components/local-autosave-monitor/index.js +5 -5
- package/build/components/local-autosave-monitor/index.js.map +1 -1
- package/build/components/post-featured-image/index.js +4 -4
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-last-revision/index.js +3 -3
- package/build/components/post-last-revision/index.js.map +1 -1
- package/build/components/post-locked-modal/index.js +1 -3
- package/build/components/post-locked-modal/index.js.map +1 -1
- package/build/components/post-saved-state/index.js +1 -1
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-schedule/index.js +3 -3
- package/build/components/post-schedule/index.js.map +1 -1
- package/build/components/post-slug/index.js +2 -4
- package/build/components/post-slug/index.js.map +1 -1
- package/build/components/post-switch-to-draft-button/index.js +19 -14
- package/build/components/post-switch-to-draft-button/index.js.map +1 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js +2 -2
- package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build/components/post-title/index.native.js +2 -2
- package/build/components/post-title/index.native.js.map +1 -1
- package/build/components/post-trash/index.js +15 -29
- package/build/components/post-trash/index.js.map +1 -1
- package/build/components/provider/index.js +1 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/index.native.js +24 -15
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +3 -8
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/store/actions.js +231 -225
- package/build/store/actions.js.map +1 -1
- package/build/store/actions.native.js +6 -4
- package/build/store/actions.native.js.map +1 -1
- package/build/store/index.js +1 -8
- package/build/store/index.js.map +1 -1
- package/build/store/{controls.js → local-autosave.js} +1 -18
- package/build/store/local-autosave.js.map +1 -0
- package/build/store/reducer.js +0 -2
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +8 -10
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils/notice-builder.js +9 -4
- package/build/store/utils/notice-builder.js.map +1 -1
- package/build/utils/url.js +9 -26
- package/build/utils/url.js.map +1 -1
- package/build-module/components/deprecated.js +1 -1
- package/build-module/components/deprecated.js.map +1 -1
- package/build-module/components/deprecated.native.js +1 -1
- package/build-module/components/deprecated.native.js.map +1 -1
- package/build-module/components/editor-help/index.native.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-record-item.js +1 -1
- package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build-module/components/index.js +3 -3
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +3 -3
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/local-autosave-monitor/index.js +1 -1
- package/build-module/components/local-autosave-monitor/index.js.map +1 -1
- package/build-module/components/post-featured-image/index.js +4 -4
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-last-revision/index.js +2 -2
- package/build-module/components/post-last-revision/index.js.map +1 -1
- package/build-module/components/post-locked-modal/index.js +1 -2
- package/build-module/components/post-locked-modal/index.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +1 -1
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-schedule/index.js +3 -3
- package/build-module/components/post-schedule/index.js.map +1 -1
- package/build-module/components/post-slug/index.js +1 -2
- package/build-module/components/post-slug/index.js.map +1 -1
- package/build-module/components/post-switch-to-draft-button/index.js +22 -16
- package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js +2 -2
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build-module/components/post-title/index.native.js +2 -2
- package/build-module/components/post-title/index.native.js.map +1 -1
- package/build-module/components/post-trash/index.js +15 -27
- package/build-module/components/post-trash/index.js.map +1 -1
- package/build-module/components/provider/index.js +1 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/index.native.js +26 -17
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +3 -8
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/store/actions.js +208 -207
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/actions.native.js +3 -3
- package/build-module/store/actions.native.js.map +1 -1
- package/build-module/store/index.js +1 -6
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/{controls.js → local-autosave.js} +1 -15
- package/build-module/store/local-autosave.js.map +1 -0
- package/build-module/store/reducer.js +0 -2
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +8 -9
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils/notice-builder.js +9 -4
- package/build-module/store/utils/notice-builder.js.map +1 -1
- package/build-module/utils/url.js +8 -25
- package/build-module/utils/url.js.map +1 -1
- package/package.json +26 -27
- package/src/components/deprecated.js +1 -1
- package/src/components/deprecated.native.js +1 -1
- package/src/components/document-outline/test/index.js +1 -1
- package/src/components/editor-help/index.native.js +2 -2
- package/src/components/entities-saved-states/entity-record-item.js +1 -1
- package/src/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
- package/src/components/index.js +3 -3
- package/src/components/index.native.js +3 -3
- package/src/components/local-autosave-monitor/index.js +4 -1
- package/src/components/post-author/test/check.js +1 -1
- package/src/components/post-featured-image/index.js +4 -4
- package/src/components/post-last-revision/index.js +2 -2
- package/src/components/post-locked-modal/index.js +1 -2
- package/src/components/post-saved-state/index.js +1 -1
- package/src/components/post-saved-state/test/index.js +2 -2
- package/src/components/post-schedule/index.js +3 -3
- package/src/components/post-slug/index.js +1 -2
- package/src/components/post-switch-to-draft-button/index.js +35 -24
- package/src/components/post-taxonomies/hierarchical-term-selector.js +2 -2
- package/src/components/post-text-editor/test/index.js +1 -1
- package/src/components/post-title/index.native.js +2 -2
- package/src/components/post-trash/index.js +12 -24
- package/src/components/provider/index.js +1 -1
- package/src/components/provider/index.native.js +27 -23
- package/src/components/provider/use-block-editor-settings.js +3 -14
- package/src/store/actions.js +137 -249
- package/src/store/actions.native.js +3 -3
- package/src/store/index.js +0 -6
- package/src/store/{controls.js → local-autosave.js} +0 -8
- package/src/store/reducer.js +0 -2
- package/src/store/selectors.js +8 -9
- package/src/store/test/actions.js +244 -416
- package/src/store/test/selectors.js +1 -1
- package/src/store/utils/notice-builder.js +9 -4
- package/src/store/utils/test/notice-builder.js +1 -0
- package/src/utils/url.js +8 -30
- package/build/store/controls.js.map +0 -1
- package/build-module/store/controls.js.map +0 -1
- package/src/utils/test/url.js +0 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/editor",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.4.0-next.e230fbab09.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,31 +31,30 @@
|
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.16.0",
|
|
34
|
-
"@wordpress/a11y": "^3.
|
|
35
|
-
"@wordpress/api-fetch": "^6.0.
|
|
36
|
-
"@wordpress/block-editor": "^8.
|
|
37
|
-
"@wordpress/blocks": "^11.
|
|
38
|
-
"@wordpress/components": "^19.
|
|
39
|
-
"@wordpress/compose": "^5.
|
|
40
|
-
"@wordpress/core-data": "^4.
|
|
41
|
-
"@wordpress/data": "^6.
|
|
42
|
-
"@wordpress/
|
|
43
|
-
"@wordpress/
|
|
44
|
-
"@wordpress/
|
|
45
|
-
"@wordpress/
|
|
46
|
-
"@wordpress/
|
|
47
|
-
"@wordpress/
|
|
48
|
-
"@wordpress/
|
|
49
|
-
"@wordpress/
|
|
50
|
-
"@wordpress/
|
|
51
|
-
"@wordpress/
|
|
52
|
-
"@wordpress/
|
|
53
|
-
"@wordpress/
|
|
54
|
-
"@wordpress/
|
|
55
|
-
"@wordpress/
|
|
56
|
-
"@wordpress/
|
|
57
|
-
"@wordpress/
|
|
58
|
-
"@wordpress/wordcount": "^3.3.1",
|
|
34
|
+
"@wordpress/a11y": "^3.4.0-next.e230fbab09.0",
|
|
35
|
+
"@wordpress/api-fetch": "^6.1.0-next.e230fbab09.0",
|
|
36
|
+
"@wordpress/block-editor": "^8.3.0-next.e230fbab09.0",
|
|
37
|
+
"@wordpress/blocks": "^11.3.0-next.e230fbab09.0",
|
|
38
|
+
"@wordpress/components": "^19.7.0-next.e230fbab09.0",
|
|
39
|
+
"@wordpress/compose": "^5.2.0-next.e230fbab09.0",
|
|
40
|
+
"@wordpress/core-data": "^4.2.0-next.e230fbab09.0",
|
|
41
|
+
"@wordpress/data": "^6.4.0-next.e230fbab09.0",
|
|
42
|
+
"@wordpress/date": "^4.4.0-next.e230fbab09.0",
|
|
43
|
+
"@wordpress/deprecated": "^3.4.0-next.e230fbab09.0",
|
|
44
|
+
"@wordpress/element": "^4.3.0-next.e230fbab09.0",
|
|
45
|
+
"@wordpress/hooks": "^3.4.0-next.e230fbab09.0",
|
|
46
|
+
"@wordpress/html-entities": "^3.4.0-next.e230fbab09.0",
|
|
47
|
+
"@wordpress/i18n": "^4.4.0-next.e230fbab09.0",
|
|
48
|
+
"@wordpress/icons": "^7.1.0-next.e230fbab09.0",
|
|
49
|
+
"@wordpress/keyboard-shortcuts": "^3.2.0-next.e230fbab09.0",
|
|
50
|
+
"@wordpress/keycodes": "^3.4.0-next.e230fbab09.0",
|
|
51
|
+
"@wordpress/media-utils": "^3.2.0-next.e230fbab09.0",
|
|
52
|
+
"@wordpress/notices": "^3.4.0-next.e230fbab09.0",
|
|
53
|
+
"@wordpress/reusable-blocks": "^3.2.0-next.e230fbab09.0",
|
|
54
|
+
"@wordpress/rich-text": "^5.2.0-next.e230fbab09.0",
|
|
55
|
+
"@wordpress/server-side-render": "^3.2.0-next.e230fbab09.0",
|
|
56
|
+
"@wordpress/url": "^3.5.0-next.e230fbab09.0",
|
|
57
|
+
"@wordpress/wordcount": "^3.4.0-next.e230fbab09.0",
|
|
59
58
|
"classnames": "^2.3.1",
|
|
60
59
|
"lodash": "^4.17.21",
|
|
61
60
|
"memize": "^1.1.0",
|
|
@@ -69,5 +68,5 @@
|
|
|
69
68
|
"publishConfig": {
|
|
70
69
|
"access": "public"
|
|
71
70
|
},
|
|
72
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "308df03e6a96ded732f9c4e32471b1b4f8dea54a"
|
|
73
72
|
}
|
|
@@ -147,7 +147,7 @@ describe( 'DocumentOutline', () => {
|
|
|
147
147
|
const blocks = [ headingH2, nestedHeading ];
|
|
148
148
|
const wrapper = mount( <DocumentOutline blocks={ blocks } /> );
|
|
149
149
|
|
|
150
|
-
// Unnested heading and nested heading should appear as items
|
|
150
|
+
// Unnested heading and nested heading should appear as items.
|
|
151
151
|
const tableOfContentItems = wrapper.find(
|
|
152
152
|
tableOfContentItemsSelector
|
|
153
153
|
);
|
|
@@ -133,7 +133,7 @@ function EditorHelpTopics( { close, isVisible, onClose } ) {
|
|
|
133
133
|
<Text style={ sectionTitle }>
|
|
134
134
|
{ __( 'The basics' ) }
|
|
135
135
|
</Text>
|
|
136
|
-
{ /* Print out help topics */ }
|
|
136
|
+
{ /* Print out help topics. */ }
|
|
137
137
|
{ HELP_TOPICS.map(
|
|
138
138
|
( { label, icon } ) => {
|
|
139
139
|
const labelSlug = kebabCase(
|
|
@@ -187,7 +187,7 @@ function EditorHelpTopics( { close, isVisible, onClose } ) {
|
|
|
187
187
|
</BottomSheetConsumer>
|
|
188
188
|
</View>
|
|
189
189
|
</BottomSheet.NavigationScreen>
|
|
190
|
-
{ /* Print out help detail screens */ }
|
|
190
|
+
{ /* Print out help detail screens. */ }
|
|
191
191
|
{ HELP_TOPICS.map( ( { view, label } ) => {
|
|
192
192
|
const labelSlug = kebabCase( label );
|
|
193
193
|
return (
|
|
@@ -36,7 +36,7 @@ export default function EntityRecordItem( {
|
|
|
36
36
|
return parents[ parents.length - 1 ];
|
|
37
37
|
}, [] );
|
|
38
38
|
|
|
39
|
-
// Handle templates that might use default descriptive titles
|
|
39
|
+
// Handle templates that might use default descriptive titles.
|
|
40
40
|
const entityRecordTitle = useSelect(
|
|
41
41
|
( select ) => {
|
|
42
42
|
if ( 'postType' !== kind || 'wp_template' !== name ) {
|
|
@@ -8,7 +8,7 @@ import { BlockEditorKeyboardShortcuts } from '@wordpress/block-editor';
|
|
|
8
8
|
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
9
9
|
|
|
10
10
|
function EditorKeyboardShortcutsRegister() {
|
|
11
|
-
// Registering the shortcuts
|
|
11
|
+
// Registering the shortcuts.
|
|
12
12
|
const { registerShortcut } = useDispatch( keyboardShortcutsStore );
|
|
13
13
|
useEffect( () => {
|
|
14
14
|
registerShortcut( {
|
package/src/components/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// Block Creation Components
|
|
1
|
+
// Block Creation Components.
|
|
2
2
|
export * from './autocompleters';
|
|
3
3
|
|
|
4
|
-
// Post Related Components
|
|
4
|
+
// Post Related Components.
|
|
5
5
|
export { default as AutosaveMonitor } from './autosave-monitor';
|
|
6
6
|
export { default as DocumentOutline } from './document-outline';
|
|
7
7
|
export { default as DocumentOutlineCheck } from './document-outline/check';
|
|
@@ -64,7 +64,7 @@ export { default as ThemeSupportCheck } from './theme-support-check';
|
|
|
64
64
|
export { default as UnsavedChangesWarning } from './unsaved-changes-warning';
|
|
65
65
|
export { default as WordCount } from './word-count';
|
|
66
66
|
|
|
67
|
-
// State Related Components
|
|
67
|
+
// State Related Components.
|
|
68
68
|
export { default as EditorProvider } from './provider';
|
|
69
69
|
|
|
70
70
|
export * from './deprecated';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
// Post Related Components
|
|
1
|
+
// Post Related Components.
|
|
2
2
|
export { default as AutosaveMonitor } from './autosave-monitor';
|
|
3
3
|
export { default as PostTitle } from './post-title';
|
|
4
4
|
export { default as EditorHistoryRedo } from './editor-history/redo';
|
|
5
5
|
export { default as EditorHistoryUndo } from './editor-history/undo';
|
|
6
6
|
|
|
7
|
-
// State Related Components
|
|
7
|
+
// State Related Components.
|
|
8
8
|
export { default as EditorProvider } from './provider';
|
|
9
9
|
|
|
10
|
-
// Other Components
|
|
10
|
+
// Other Components.
|
|
11
11
|
export { default as EditorHelpTopics } from './editor-help';
|
|
12
12
|
|
|
13
13
|
export * from './deprecated';
|
|
@@ -17,7 +17,10 @@ import { store as noticesStore } from '@wordpress/notices';
|
|
|
17
17
|
* Internal dependencies
|
|
18
18
|
*/
|
|
19
19
|
import AutosaveMonitor from '../autosave-monitor';
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
localAutosaveGet,
|
|
22
|
+
localAutosaveClear,
|
|
23
|
+
} from '../../store/local-autosave';
|
|
21
24
|
import { store as editorStore } from '../../store';
|
|
22
25
|
|
|
23
26
|
const requestIdleCallback = window.requestIdleCallback
|
|
@@ -14,7 +14,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
14
14
|
import PostAuthorCheck from '../check';
|
|
15
15
|
|
|
16
16
|
jest.mock( '@wordpress/data/src/components/use-select', () => {
|
|
17
|
-
// This allows us to tweak the returned value on each test
|
|
17
|
+
// This allows us to tweak the returned value on each test.
|
|
18
18
|
const mock = jest.fn();
|
|
19
19
|
return mock;
|
|
20
20
|
} );
|
|
@@ -66,12 +66,12 @@ function PostFeaturedImage( {
|
|
|
66
66
|
currentPostId
|
|
67
67
|
);
|
|
68
68
|
if ( has( media, [ 'media_details', 'sizes', mediaSize ] ) ) {
|
|
69
|
-
//
|
|
69
|
+
// Use mediaSize when available.
|
|
70
70
|
mediaWidth = media.media_details.sizes[ mediaSize ].width;
|
|
71
71
|
mediaHeight = media.media_details.sizes[ mediaSize ].height;
|
|
72
72
|
mediaSourceUrl = media.media_details.sizes[ mediaSize ].source_url;
|
|
73
73
|
} else {
|
|
74
|
-
//
|
|
74
|
+
// Get fallbackMediaSize if mediaSize is not available.
|
|
75
75
|
const fallbackMediaSize = applyFilters(
|
|
76
76
|
'editor.PostFeaturedImage.imageSize',
|
|
77
77
|
'thumbnail',
|
|
@@ -81,7 +81,7 @@ function PostFeaturedImage( {
|
|
|
81
81
|
if (
|
|
82
82
|
has( media, [ 'media_details', 'sizes', fallbackMediaSize ] )
|
|
83
83
|
) {
|
|
84
|
-
//
|
|
84
|
+
// Use fallbackMediaSize when mediaSize is not available.
|
|
85
85
|
mediaWidth =
|
|
86
86
|
media.media_details.sizes[ fallbackMediaSize ].width;
|
|
87
87
|
mediaHeight =
|
|
@@ -89,7 +89,7 @@ function PostFeaturedImage( {
|
|
|
89
89
|
mediaSourceUrl =
|
|
90
90
|
media.media_details.sizes[ fallbackMediaSize ].source_url;
|
|
91
91
|
} else {
|
|
92
|
-
//
|
|
92
|
+
// Use full image size when mediaFallbackSize and mediaSize are not available.
|
|
93
93
|
mediaWidth = media.media_details.width;
|
|
94
94
|
mediaHeight = media.media_details.height;
|
|
95
95
|
mediaSourceUrl = media.source_url;
|
|
@@ -5,19 +5,19 @@ import { sprintf, _n } from '@wordpress/i18n';
|
|
|
5
5
|
import { Button } from '@wordpress/components';
|
|
6
6
|
import { withSelect } from '@wordpress/data';
|
|
7
7
|
import { backup } from '@wordpress/icons';
|
|
8
|
+
import { addQueryArgs } from '@wordpress/url';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
11
12
|
*/
|
|
12
13
|
import PostLastRevisionCheck from './check';
|
|
13
|
-
import { getWPAdminURL } from '../../utils/url';
|
|
14
14
|
import { store as editorStore } from '../../store';
|
|
15
15
|
|
|
16
16
|
function LastRevision( { lastRevisionId, revisionsCount } ) {
|
|
17
17
|
return (
|
|
18
18
|
<PostLastRevisionCheck>
|
|
19
19
|
<Button
|
|
20
|
-
href={
|
|
20
|
+
href={ addQueryArgs( 'revision.php', {
|
|
21
21
|
revision: lastRevisionId,
|
|
22
22
|
gutenberg: true,
|
|
23
23
|
} ) }
|
|
@@ -24,7 +24,6 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
24
24
|
/**
|
|
25
25
|
* Internal dependencies
|
|
26
26
|
*/
|
|
27
|
-
import { getWPAdminURL } from '../../utils/url';
|
|
28
27
|
import { store as editorStore } from '../../store';
|
|
29
28
|
|
|
30
29
|
export default function PostLockedModal() {
|
|
@@ -164,7 +163,7 @@ export default function PostLockedModal() {
|
|
|
164
163
|
action: 'edit',
|
|
165
164
|
_wpnonce: postLockUtils.nonce,
|
|
166
165
|
} );
|
|
167
|
-
const allPostsUrl =
|
|
166
|
+
const allPostsUrl = addQueryArgs( 'edit.php', {
|
|
168
167
|
post_type: get( postType, [ 'slug' ] ),
|
|
169
168
|
} );
|
|
170
169
|
const allPostsLabel = __( 'Exit editor' );
|
|
@@ -154,7 +154,7 @@ export default function PostSavedState( {
|
|
|
154
154
|
shortcut={ displayShortcut.primary( 's' ) }
|
|
155
155
|
variant={ isLargeViewport ? 'tertiary' : undefined }
|
|
156
156
|
icon={ isLargeViewport ? undefined : cloudUpload }
|
|
157
|
-
label={ label }
|
|
157
|
+
label={ showIconLabels ? undefined : label }
|
|
158
158
|
aria-disabled={ isDisabled }
|
|
159
159
|
>
|
|
160
160
|
{ isSavedState && <Icon icon={ isSaved ? check : cloud } /> }
|
|
@@ -23,13 +23,13 @@ jest.mock( '@wordpress/data/src/components/use-dispatch', () => {
|
|
|
23
23
|
} );
|
|
24
24
|
|
|
25
25
|
jest.mock( '@wordpress/data/src/components/use-select', () => {
|
|
26
|
-
// This allows us to tweak the returned value on each test
|
|
26
|
+
// This allows us to tweak the returned value on each test.
|
|
27
27
|
const mock = jest.fn();
|
|
28
28
|
return mock;
|
|
29
29
|
} );
|
|
30
30
|
|
|
31
31
|
jest.mock( '@wordpress/compose/src/hooks/use-viewport-match', () => {
|
|
32
|
-
// This allows us to tweak the returned value on each test
|
|
32
|
+
// This allows us to tweak the returned value on each test.
|
|
33
33
|
const mock = jest.fn();
|
|
34
34
|
return mock;
|
|
35
35
|
} );
|
|
@@ -68,11 +68,11 @@ export default function PostSchedule() {
|
|
|
68
68
|
// We also make sure this a is not escaped by a "/"
|
|
69
69
|
const is12HourTime = /a(?!\\)/i.test(
|
|
70
70
|
settings.formats.time
|
|
71
|
-
.toLowerCase() // Test only the lower case a
|
|
72
|
-
.replace( /\\\\/g, '' ) // Replace "//" with empty strings
|
|
71
|
+
.toLowerCase() // Test only the lower case a.
|
|
72
|
+
.replace( /\\\\/g, '' ) // Replace "//" with empty strings.
|
|
73
73
|
.split( '' )
|
|
74
74
|
.reverse()
|
|
75
|
-
.join( '' ) // Reverse the string and test for "a" not followed by a slash
|
|
75
|
+
.join( '' ) // Reverse the string and test for "a" not followed by a slash.
|
|
76
76
|
);
|
|
77
77
|
|
|
78
78
|
function onChange( newDate ) {
|
|
@@ -5,13 +5,12 @@ import { withDispatch, withSelect } from '@wordpress/data';
|
|
|
5
5
|
import { Component } from '@wordpress/element';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
import { withInstanceId, compose } from '@wordpress/compose';
|
|
8
|
-
import { safeDecodeURIComponent } from '@wordpress/url';
|
|
8
|
+
import { safeDecodeURIComponent, cleanForSlug } from '@wordpress/url';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
13
|
import PostSlugCheck from './check';
|
|
14
|
-
import { cleanForSlug } from '../../utils/url';
|
|
15
14
|
import { store as editorStore } from '../../store';
|
|
16
15
|
|
|
17
16
|
export class PostSlug extends Component {
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
__experimentalConfirmDialog as ConfirmDialog,
|
|
7
|
+
} from '@wordpress/components';
|
|
5
8
|
import { __ } from '@wordpress/i18n';
|
|
6
9
|
import { withSelect, withDispatch } from '@wordpress/data';
|
|
7
10
|
import { compose, useViewportMatch } from '@wordpress/compose';
|
|
11
|
+
import { useState } from '@wordpress/element';
|
|
8
12
|
|
|
9
13
|
/**
|
|
10
14
|
* Internal dependencies
|
|
@@ -18,37 +22,44 @@ function PostSwitchToDraftButton( {
|
|
|
18
22
|
onClick,
|
|
19
23
|
} ) {
|
|
20
24
|
const isMobileViewport = useViewportMatch( 'small', '<' );
|
|
25
|
+
const [ showConfirmDialog, setShowConfirmDialog ] = useState( false );
|
|
21
26
|
|
|
22
27
|
if ( ! isPublished && ! isScheduled ) {
|
|
23
28
|
return null;
|
|
24
29
|
}
|
|
25
30
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
// eslint-disable-next-line no-alert
|
|
38
|
-
if ( window.confirm( alertMessage ) ) {
|
|
39
|
-
onClick();
|
|
40
|
-
}
|
|
31
|
+
let alertMessage;
|
|
32
|
+
if ( isPublished ) {
|
|
33
|
+
alertMessage = __( 'Are you sure you want to unpublish this post?' );
|
|
34
|
+
} else if ( isScheduled ) {
|
|
35
|
+
alertMessage = __( 'Are you sure you want to unschedule this post?' );
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const handleConfirm = () => {
|
|
39
|
+
setShowConfirmDialog( false );
|
|
40
|
+
onClick();
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
return (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
<>
|
|
45
|
+
<Button
|
|
46
|
+
className="editor-post-switch-to-draft"
|
|
47
|
+
onClick={ () => {
|
|
48
|
+
setShowConfirmDialog( true );
|
|
49
|
+
} }
|
|
50
|
+
disabled={ isSaving }
|
|
51
|
+
variant="tertiary"
|
|
52
|
+
>
|
|
53
|
+
{ isMobileViewport ? __( 'Draft' ) : __( 'Switch to draft' ) }
|
|
54
|
+
</Button>
|
|
55
|
+
<ConfirmDialog
|
|
56
|
+
isOpen={ showConfirmDialog }
|
|
57
|
+
onConfirm={ handleConfirm }
|
|
58
|
+
onCancel={ () => setShowConfirmDialog( false ) }
|
|
59
|
+
>
|
|
60
|
+
{ alertMessage }
|
|
61
|
+
</ConfirmDialog>
|
|
62
|
+
</>
|
|
52
63
|
);
|
|
53
64
|
}
|
|
54
65
|
|
|
@@ -288,10 +288,10 @@ function HierarchicalTermSelector( { slug } ) {
|
|
|
288
288
|
return;
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
-
//
|
|
291
|
+
// Check if the term we are adding already exists.
|
|
292
292
|
const existingTerm = findTerm( availableTerms, formParent, formName );
|
|
293
293
|
if ( existingTerm ) {
|
|
294
|
-
//
|
|
294
|
+
// If the term we are adding exists but is not selected select it.
|
|
295
295
|
if ( ! some( terms, ( term ) => term === existingTerm.id ) ) {
|
|
296
296
|
onUpdateTerms( [ ...terms, existingTerm.id ] );
|
|
297
297
|
}
|
|
@@ -21,7 +21,7 @@ jest.mock( 'react-autosize-textarea', () => ( props ) => (
|
|
|
21
21
|
) );
|
|
22
22
|
|
|
23
23
|
jest.mock( '@wordpress/data/src/components/use-select', () => {
|
|
24
|
-
// This allows us to tweak the returned value on each test
|
|
24
|
+
// This allows us to tweak the returned value on each test.
|
|
25
25
|
const mock = jest.fn();
|
|
26
26
|
return mock;
|
|
27
27
|
} );
|
|
@@ -34,7 +34,7 @@ class PostTitle extends Component {
|
|
|
34
34
|
this.setRef = this.setRef.bind( this );
|
|
35
35
|
}
|
|
36
36
|
componentDidUpdate( prevProps ) {
|
|
37
|
-
// Unselect if any other block is selected and blur the RichText
|
|
37
|
+
// Unselect if any other block is selected and blur the RichText.
|
|
38
38
|
if (
|
|
39
39
|
this.props.isSelected &&
|
|
40
40
|
! prevProps.isAnyBlockSelected &&
|
|
@@ -142,7 +142,7 @@ class PostTitle extends Component {
|
|
|
142
142
|
tagName={ 'p' }
|
|
143
143
|
tagsToEliminate={ [ 'strong' ] }
|
|
144
144
|
unstableOnFocus={ this.props.onSelect }
|
|
145
|
-
onBlur={ this.props.onBlur } //
|
|
145
|
+
onBlur={ this.props.onBlur } // Always assign onBlur as a props.
|
|
146
146
|
multiline={ false }
|
|
147
147
|
style={ titleStyles }
|
|
148
148
|
styles={ styles }
|
|
@@ -3,47 +3,35 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { Button } from '@wordpress/components';
|
|
6
|
-
import {
|
|
7
|
-
import { compose } from '@wordpress/compose';
|
|
6
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Internal dependencies
|
|
11
10
|
*/
|
|
12
11
|
import { store as editorStore } from '../../store';
|
|
13
12
|
|
|
14
|
-
function PostTrash(
|
|
13
|
+
export default function PostTrash() {
|
|
14
|
+
const { isNew, postId } = useSelect( ( select ) => {
|
|
15
|
+
const store = select( editorStore );
|
|
16
|
+
return {
|
|
17
|
+
isNew: store.isEditedPostNew(),
|
|
18
|
+
postId: store.getCurrentPostId(),
|
|
19
|
+
};
|
|
20
|
+
}, [] );
|
|
21
|
+
const { trashPost } = useDispatch( editorStore );
|
|
22
|
+
|
|
15
23
|
if ( isNew || ! postId ) {
|
|
16
24
|
return null;
|
|
17
25
|
}
|
|
18
26
|
|
|
19
|
-
const onClick = () => props.trashPost( postId, postType );
|
|
20
|
-
|
|
21
27
|
return (
|
|
22
28
|
<Button
|
|
23
29
|
className="editor-post-trash"
|
|
24
30
|
isDestructive
|
|
25
31
|
variant="secondary"
|
|
26
|
-
onClick={
|
|
32
|
+
onClick={ () => trashPost() }
|
|
27
33
|
>
|
|
28
34
|
{ __( 'Move to trash' ) }
|
|
29
35
|
</Button>
|
|
30
36
|
);
|
|
31
37
|
}
|
|
32
|
-
|
|
33
|
-
export default compose( [
|
|
34
|
-
withSelect( ( select ) => {
|
|
35
|
-
const {
|
|
36
|
-
isEditedPostNew,
|
|
37
|
-
getCurrentPostId,
|
|
38
|
-
getCurrentPostType,
|
|
39
|
-
} = select( editorStore );
|
|
40
|
-
return {
|
|
41
|
-
isNew: isEditedPostNew(),
|
|
42
|
-
postId: getCurrentPostId(),
|
|
43
|
-
postType: getCurrentPostType(),
|
|
44
|
-
};
|
|
45
|
-
} ),
|
|
46
|
-
withDispatch( ( dispatch ) => ( {
|
|
47
|
-
trashPost: dispatch( editorStore ).trashPost,
|
|
48
|
-
} ) ),
|
|
49
|
-
] )( PostTrash );
|
|
@@ -31,12 +31,8 @@ import {
|
|
|
31
31
|
import { withDispatch, withSelect } from '@wordpress/data';
|
|
32
32
|
import { compose } from '@wordpress/compose';
|
|
33
33
|
import { applyFilters } from '@wordpress/hooks';
|
|
34
|
-
import {
|
|
35
|
-
|
|
36
|
-
validateThemeGradients,
|
|
37
|
-
store as blockEditorStore,
|
|
38
|
-
} from '@wordpress/block-editor';
|
|
39
|
-
import { getGlobalStyles } from '@wordpress/components';
|
|
34
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
35
|
+
import { getGlobalStyles, getColorsAndGradients } from '@wordpress/components';
|
|
40
36
|
import { NEW_BLOCK_TYPES } from '@wordpress/block-library';
|
|
41
37
|
|
|
42
38
|
const postTypeEntities = [
|
|
@@ -70,7 +66,7 @@ class NativeEditorProvider extends Component {
|
|
|
70
66
|
constructor() {
|
|
71
67
|
super( ...arguments );
|
|
72
68
|
|
|
73
|
-
// Keep a local reference to `post` to detect changes
|
|
69
|
+
// Keep a local reference to `post` to detect changes.
|
|
74
70
|
this.post = this.props.post;
|
|
75
71
|
this.props.addEntities( postTypeEntities );
|
|
76
72
|
this.props.receiveEntityRecords(
|
|
@@ -171,15 +167,15 @@ class NativeEditorProvider extends Component {
|
|
|
171
167
|
this.setState( { isHelpVisible: true } );
|
|
172
168
|
} );
|
|
173
169
|
|
|
174
|
-
// Request current block impressions from native app
|
|
170
|
+
// Request current block impressions from native app.
|
|
175
171
|
requestBlockTypeImpressions( ( storedImpressions ) => {
|
|
176
172
|
const impressions = { ...NEW_BLOCK_TYPES, ...storedImpressions };
|
|
177
173
|
|
|
178
|
-
// Persist impressions to JavaScript store
|
|
174
|
+
// Persist impressions to JavaScript store.
|
|
179
175
|
updateSettings( { impressions } );
|
|
180
176
|
|
|
181
177
|
// Persist impressions to native store if they do not include latest
|
|
182
|
-
// `NEW_BLOCK_TYPES` configuration
|
|
178
|
+
// `NEW_BLOCK_TYPES` configuration.
|
|
183
179
|
const storedImpressionKeys = Object.keys( storedImpressions );
|
|
184
180
|
const storedImpressionsCurrent = Object.keys(
|
|
185
181
|
NEW_BLOCK_TYPES
|
|
@@ -232,15 +228,18 @@ class NativeEditorProvider extends Component {
|
|
|
232
228
|
}
|
|
233
229
|
}
|
|
234
230
|
|
|
235
|
-
getThemeColors( {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
231
|
+
getThemeColors( { rawStyles, rawFeatures } ) {
|
|
232
|
+
const { defaultEditorColors, defaultEditorGradients } = this.props;
|
|
233
|
+
|
|
234
|
+
if ( rawStyles && rawFeatures ) {
|
|
235
|
+
return getGlobalStyles( rawStyles, rawFeatures );
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return getColorsAndGradients(
|
|
239
|
+
defaultEditorColors,
|
|
240
|
+
defaultEditorGradients,
|
|
241
|
+
rawFeatures
|
|
242
|
+
);
|
|
244
243
|
}
|
|
245
244
|
|
|
246
245
|
componentDidUpdate( prevProps ) {
|
|
@@ -263,7 +262,7 @@ class NativeEditorProvider extends Component {
|
|
|
263
262
|
|
|
264
263
|
if ( this.props.mode === 'text' ) {
|
|
265
264
|
// The HTMLTextInput component does not update the store when user is doing changes
|
|
266
|
-
// Let's request the HTML from the component's state directly
|
|
265
|
+
// Let's request the HTML from the component's state directly.
|
|
267
266
|
html = applyFilters( 'native.persist-html' );
|
|
268
267
|
} else {
|
|
269
268
|
html = serialize( this.props.blocks );
|
|
@@ -306,9 +305,9 @@ class NativeEditorProvider extends Component {
|
|
|
306
305
|
|
|
307
306
|
toggleMode() {
|
|
308
307
|
const { mode, switchMode } = this.props;
|
|
309
|
-
//
|
|
308
|
+
// Refresh html content first.
|
|
310
309
|
this.serializeToNativeAction();
|
|
311
|
-
//
|
|
310
|
+
// Make sure to blur the selected block and dismiss the keyboard.
|
|
312
311
|
this.props.clearSelectedBlock();
|
|
313
312
|
switchMode( mode === 'visual' ? 'text' : 'visual' );
|
|
314
313
|
}
|
|
@@ -363,6 +362,10 @@ export default compose( [
|
|
|
363
362
|
getSettings: getBlockEditorSettings,
|
|
364
363
|
} = select( blockEditorStore );
|
|
365
364
|
|
|
365
|
+
const settings = getBlockEditorSettings();
|
|
366
|
+
const defaultEditorColors = settings?.colors ?? [];
|
|
367
|
+
const defaultEditorGradients = settings?.gradients ?? [];
|
|
368
|
+
|
|
366
369
|
const selectedBlockClientId = getSelectedBlockClientId();
|
|
367
370
|
return {
|
|
368
371
|
mode: getEditorMode(),
|
|
@@ -370,7 +373,8 @@ export default compose( [
|
|
|
370
373
|
blocks: getEditorBlocks(),
|
|
371
374
|
title: getEditedPostAttribute( 'title' ),
|
|
372
375
|
getEditedPostContent,
|
|
373
|
-
|
|
376
|
+
defaultEditorColors,
|
|
377
|
+
defaultEditorGradients,
|
|
374
378
|
selectedBlockIndex: getBlockIndex( selectedBlockClientId ),
|
|
375
379
|
blockCount: getGlobalBlockCount(),
|
|
376
380
|
paragraphCount: getGlobalBlockCount( 'core/paragraph' ),
|