@wordpress/editor 12.0.18 → 12.2.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 +16 -0
- package/LICENSE.md +1 -1
- package/README.md +7 -1
- package/build/components/deprecated.js +5 -5
- package/build/components/deprecated.js.map +1 -1
- package/build/components/editor-help/add-blocks.native.js +1 -1
- package/build/components/editor-help/add-blocks.native.js.map +1 -1
- package/build/components/editor-help/index.native.js +1 -1
- package/build/components/editor-help/index.native.js.map +1 -1
- package/build/components/entities-saved-states/index.js +19 -10
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/index.js +18 -0
- package/build/components/index.js.map +1 -1
- package/build/components/post-format/index.js +6 -4
- package/build/components/post-format/index.js.map +1 -1
- package/build/components/post-locked-modal/index.js +34 -25
- package/build/components/post-locked-modal/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-category-panel.js +81 -0
- package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -0
- package/build/components/post-publish-panel/prepublish.js +3 -1
- package/build/components/post-publish-panel/prepublish.js.map +1 -1
- package/build/components/post-taxonomies/most-used-terms.js +3 -3
- package/build/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build/components/post-title/index.native.js +1 -0
- package/build/components/post-title/index.native.js.map +1 -1
- package/build/components/post-trash/index.js +1 -1
- package/build/components/post-trash/index.js.map +1 -1
- package/build/components/post-visibility/index.js +30 -14
- package/build/components/post-visibility/index.js.map +1 -1
- package/build/components/provider/index.native.js +12 -6
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +11 -6
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/store/actions.js +21 -15
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +12 -39
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils/notice-builder.js +1 -1
- package/build/store/utils/notice-builder.js.map +1 -1
- package/build-module/components/deprecated.js +5 -4
- package/build-module/components/deprecated.js.map +1 -1
- package/build-module/components/editor-help/add-blocks.native.js +1 -1
- package/build-module/components/editor-help/add-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/index.native.js +1 -1
- package/build-module/components/editor-help/index.native.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +19 -10
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/index.js +2 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/post-format/index.js +7 -5
- package/build-module/components/post-format/index.js.map +1 -1
- package/build-module/components/post-locked-modal/index.js +37 -25
- package/build-module/components/post-locked-modal/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-category-panel.js +66 -0
- package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -0
- package/build-module/components/post-publish-panel/prepublish.js +2 -1
- package/build-module/components/post-publish-panel/prepublish.js.map +1 -1
- package/build-module/components/post-taxonomies/most-used-terms.js +3 -3
- package/build-module/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build-module/components/post-title/index.native.js +1 -0
- package/build-module/components/post-title/index.native.js.map +1 -1
- package/build-module/components/post-trash/index.js +1 -1
- package/build-module/components/post-trash/index.js.map +1 -1
- package/build-module/components/post-visibility/index.js +31 -15
- package/build-module/components/post-visibility/index.js.map +1 -1
- package/build-module/components/provider/index.native.js +10 -7
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +11 -6
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/store/actions.js +21 -15
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +10 -35
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils/notice-builder.js +1 -1
- package/build-module/store/utils/notice-builder.js.map +1 -1
- package/build-style/style-rtl.css +9 -27
- package/build-style/style.css +9 -27
- package/package.json +31 -30
- package/src/components/autosave-monitor/test/index.js +1 -1
- package/src/components/deprecated.js +2 -5
- package/src/components/editor-help/add-blocks.native.js +1 -1
- package/src/components/editor-help/index.native.js +1 -1
- package/src/components/entities-saved-states/index.js +21 -10
- package/src/components/entities-saved-states/style.scss +0 -12
- package/src/components/index.js +2 -0
- package/src/components/post-format/index.js +9 -10
- package/src/components/post-locked-modal/index.js +92 -53
- package/src/components/post-locked-modal/style.scss +7 -17
- package/src/components/post-publish-panel/maybe-category-panel.js +88 -0
- package/src/components/post-publish-panel/prepublish.js +2 -0
- package/src/components/post-taxonomies/README.md +25 -1
- package/src/components/post-taxonomies/most-used-terms.js +3 -3
- package/src/components/post-title/index.native.js +1 -0
- package/src/components/post-trash/index.js +1 -1
- package/src/components/post-visibility/index.js +25 -11
- package/src/components/provider/index.native.js +10 -7
- package/src/components/provider/use-block-editor-settings.js +14 -3
- package/src/store/actions.js +18 -23
- package/src/store/selectors.js +9 -40
- package/src/store/test/actions.js +1 -41
- package/src/store/utils/notice-builder.js +1 -1
- package/src/store/utils/test/notice-builder.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/editor",
|
|
3
|
-
"version": "12.0
|
|
3
|
+
"version": "12.2.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,42 +31,43 @@
|
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.16.0",
|
|
34
|
-
"@wordpress/a11y": "^3.
|
|
35
|
-
"@wordpress/api-fetch": "^
|
|
36
|
-
"@wordpress/
|
|
37
|
-
"@wordpress/
|
|
38
|
-
"@wordpress/
|
|
39
|
-
"@wordpress/
|
|
40
|
-
"@wordpress/
|
|
41
|
-
"@wordpress/
|
|
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/
|
|
59
|
-
"@wordpress/server-side-render": "^3.0.19",
|
|
60
|
-
"@wordpress/url": "^3.3.1",
|
|
61
|
-
"@wordpress/wordcount": "^3.2.3",
|
|
34
|
+
"@wordpress/a11y": "^3.3.1",
|
|
35
|
+
"@wordpress/api-fetch": "^6.0.1",
|
|
36
|
+
"@wordpress/block-editor": "^8.1.1",
|
|
37
|
+
"@wordpress/blocks": "^11.2.1",
|
|
38
|
+
"@wordpress/components": "^19.4.0",
|
|
39
|
+
"@wordpress/compose": "^5.1.1",
|
|
40
|
+
"@wordpress/core-data": "^4.1.1",
|
|
41
|
+
"@wordpress/data": "^6.2.1",
|
|
42
|
+
"@wordpress/data-controls": "^2.3.1",
|
|
43
|
+
"@wordpress/date": "^4.3.1",
|
|
44
|
+
"@wordpress/deprecated": "^3.3.1",
|
|
45
|
+
"@wordpress/element": "^4.1.1",
|
|
46
|
+
"@wordpress/hooks": "^3.3.1",
|
|
47
|
+
"@wordpress/html-entities": "^3.3.1",
|
|
48
|
+
"@wordpress/i18n": "^4.3.1",
|
|
49
|
+
"@wordpress/icons": "^6.3.0",
|
|
50
|
+
"@wordpress/keyboard-shortcuts": "^3.1.1",
|
|
51
|
+
"@wordpress/keycodes": "^3.3.1",
|
|
52
|
+
"@wordpress/media-utils": "^3.1.1",
|
|
53
|
+
"@wordpress/notices": "^3.3.1",
|
|
54
|
+
"@wordpress/reusable-blocks": "^3.1.1",
|
|
55
|
+
"@wordpress/rich-text": "^5.1.1",
|
|
56
|
+
"@wordpress/server-side-render": "^3.1.1",
|
|
57
|
+
"@wordpress/url": "^3.4.1",
|
|
58
|
+
"@wordpress/wordcount": "^3.3.1",
|
|
62
59
|
"classnames": "^2.3.1",
|
|
63
60
|
"lodash": "^4.17.21",
|
|
64
61
|
"memize": "^1.1.0",
|
|
65
62
|
"react-autosize-textarea": "^7.1.0",
|
|
66
63
|
"rememo": "^3.0.0"
|
|
67
64
|
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"react": "^17.0.0",
|
|
67
|
+
"react-dom": "^17.0.0"
|
|
68
|
+
},
|
|
68
69
|
"publishConfig": {
|
|
69
70
|
"access": "public"
|
|
70
71
|
},
|
|
71
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "2e4922861e49f5a090f9dc52056165092cfba163"
|
|
72
73
|
}
|
|
@@ -48,7 +48,6 @@ import {
|
|
|
48
48
|
MultiSelectScrollIntoView as RootMultiSelectScrollIntoView,
|
|
49
49
|
NavigableToolbar as RootNavigableToolbar,
|
|
50
50
|
ObserveTyping as RootObserveTyping,
|
|
51
|
-
PreserveScrollInReorder as RootPreserveScrollInReorder,
|
|
52
51
|
SkipToSelectedBlock as RootSkipToSelectedBlock,
|
|
53
52
|
URLInput as RootURLInput,
|
|
54
53
|
URLInputButton as RootURLInputButton,
|
|
@@ -67,6 +66,7 @@ function deprecateComponent( name, Wrapped, staticsToHoist = [] ) {
|
|
|
67
66
|
deprecated( 'wp.editor.' + name, {
|
|
68
67
|
since: '5.3',
|
|
69
68
|
alternative: 'wp.blockEditor.' + name,
|
|
69
|
+
version: '6.2',
|
|
70
70
|
} );
|
|
71
71
|
|
|
72
72
|
return <Wrapped ref={ ref } { ...props } />;
|
|
@@ -87,6 +87,7 @@ function deprecateFunction( name, func ) {
|
|
|
87
87
|
deprecated( 'wp.editor.' + name, {
|
|
88
88
|
since: '5.3',
|
|
89
89
|
alternative: 'wp.blockEditor.' + name,
|
|
90
|
+
version: '6.2',
|
|
90
91
|
} );
|
|
91
92
|
|
|
92
93
|
return func( ...args );
|
|
@@ -222,10 +223,6 @@ export const ObserveTyping = deprecateComponent(
|
|
|
222
223
|
'ObserveTyping',
|
|
223
224
|
RootObserveTyping
|
|
224
225
|
);
|
|
225
|
-
export const PreserveScrollInReorder = deprecateComponent(
|
|
226
|
-
'PreserveScrollInReorder',
|
|
227
|
-
RootPreserveScrollInReorder
|
|
228
|
-
);
|
|
229
226
|
export const SkipToSelectedBlock = deprecateComponent(
|
|
230
227
|
'SkipToSelectedBlock',
|
|
231
228
|
RootSkipToSelectedBlock
|
|
@@ -24,7 +24,7 @@ const AddBlocks = () => {
|
|
|
24
24
|
<View style={ styles.helpDetailContainer }>
|
|
25
25
|
<HelpDetailBodyText
|
|
26
26
|
text={ __(
|
|
27
|
-
'Add a new block at any time by tapping on the + icon in the toolbar on the bottom left.
|
|
27
|
+
'Add a new block at any time by tapping on the + icon in the toolbar on the bottom left.'
|
|
28
28
|
) }
|
|
29
29
|
/>
|
|
30
30
|
<HelpDetailBodyText
|
|
@@ -6,13 +6,13 @@ import { some, groupBy } from 'lodash';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { Button } from '@wordpress/components';
|
|
9
|
+
import { Button, Flex, FlexItem } from '@wordpress/components';
|
|
10
10
|
import { __ } from '@wordpress/i18n';
|
|
11
11
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
12
12
|
import { useState, useCallback, useRef } from '@wordpress/element';
|
|
13
13
|
import { store as coreStore } from '@wordpress/core-data';
|
|
14
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
14
15
|
import { __experimentalUseDialog as useDialog } from '@wordpress/compose';
|
|
15
|
-
import { close as closeIcon } from '@wordpress/icons';
|
|
16
16
|
import { store as noticesStore } from '@wordpress/notices';
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -77,6 +77,10 @@ export default function EntitiesSavedStates( { close } ) {
|
|
|
77
77
|
__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,
|
|
78
78
|
} = useDispatch( coreStore );
|
|
79
79
|
|
|
80
|
+
const { __unstableMarkLastChangeAsPersistent } = useDispatch(
|
|
81
|
+
blockEditorStore
|
|
82
|
+
);
|
|
83
|
+
|
|
80
84
|
const { createSuccessNotice, createErrorNotice } = useDispatch(
|
|
81
85
|
noticesStore
|
|
82
86
|
);
|
|
@@ -171,6 +175,8 @@ export default function EntitiesSavedStates( { close } ) {
|
|
|
171
175
|
);
|
|
172
176
|
}
|
|
173
177
|
|
|
178
|
+
__unstableMarkLastChangeAsPersistent();
|
|
179
|
+
|
|
174
180
|
Promise.all( pendingSavedRecords )
|
|
175
181
|
.then( ( values ) => {
|
|
176
182
|
if (
|
|
@@ -202,8 +208,10 @@ export default function EntitiesSavedStates( { close } ) {
|
|
|
202
208
|
{ ...saveDialogProps }
|
|
203
209
|
className="entities-saved-states__panel"
|
|
204
210
|
>
|
|
205
|
-
<
|
|
206
|
-
<
|
|
211
|
+
<Flex className="entities-saved-states__panel-header" gap={ 2 }>
|
|
212
|
+
<FlexItem
|
|
213
|
+
isBlock
|
|
214
|
+
as={ Button }
|
|
207
215
|
ref={ saveButtonRef }
|
|
208
216
|
variant="primary"
|
|
209
217
|
disabled={
|
|
@@ -215,13 +223,16 @@ export default function EntitiesSavedStates( { close } ) {
|
|
|
215
223
|
className="editor-entities-saved-states__save-button"
|
|
216
224
|
>
|
|
217
225
|
{ __( 'Save' ) }
|
|
218
|
-
</
|
|
219
|
-
<
|
|
220
|
-
|
|
226
|
+
</FlexItem>
|
|
227
|
+
<FlexItem
|
|
228
|
+
isBlock
|
|
229
|
+
as={ Button }
|
|
230
|
+
variant="secondary"
|
|
221
231
|
onClick={ dismissPanel }
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
232
|
+
>
|
|
233
|
+
{ __( 'Cancel' ) }
|
|
234
|
+
</FlexItem>
|
|
235
|
+
</Flex>
|
|
225
236
|
|
|
226
237
|
<div className="entities-saved-states__text-prompt">
|
|
227
238
|
<strong>{ __( 'Are you ready to save?' ) }</strong>
|
|
@@ -41,18 +41,6 @@
|
|
|
41
41
|
padding-right: $grid-unit-10;
|
|
42
42
|
height: $header-height + $border-width;
|
|
43
43
|
border-bottom: $border-width solid $gray-300;
|
|
44
|
-
display: flex;
|
|
45
|
-
align-items: center;
|
|
46
|
-
align-content: space-between;
|
|
47
|
-
|
|
48
|
-
.editor-entities-saved-states__save-button {
|
|
49
|
-
margin: auto;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.components-button.has-icon {
|
|
53
|
-
position: absolute;
|
|
54
|
-
right: $grid-unit-10;
|
|
55
|
-
}
|
|
56
44
|
}
|
|
57
45
|
|
|
58
46
|
.entities-saved-states__text-prompt {
|
package/src/components/index.js
CHANGED
|
@@ -48,6 +48,8 @@ export { default as PostSticky } from './post-sticky';
|
|
|
48
48
|
export { default as PostStickyCheck } from './post-sticky/check';
|
|
49
49
|
export { default as PostSwitchToDraftButton } from './post-switch-to-draft-button';
|
|
50
50
|
export { default as PostTaxonomies } from './post-taxonomies';
|
|
51
|
+
export { default as PostTaxonomiesFlatTermSelector } from './post-taxonomies/flat-term-selector';
|
|
52
|
+
export { default as PostTaxonomiesHierarchicalTermSelector } from './post-taxonomies/hierarchical-term-selector';
|
|
51
53
|
export { default as PostTaxonomiesCheck } from './post-taxonomies/check';
|
|
52
54
|
export { default as PostTextEditor } from './post-text-editor';
|
|
53
55
|
export { default as PostTitle } from './post-title';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { find,
|
|
4
|
+
import { find, includes } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -57,20 +57,19 @@ export default function PostFormat() {
|
|
|
57
57
|
return {
|
|
58
58
|
postFormat: _postFormat ?? 'standard',
|
|
59
59
|
suggestedFormat: getSuggestedPostFormat(),
|
|
60
|
-
|
|
61
|
-
// The current format may not be a format supported by the theme.
|
|
62
|
-
supportedFormats: union(
|
|
63
|
-
[ _postFormat ],
|
|
64
|
-
get( themeSupports, [ 'formats' ], [] )
|
|
65
|
-
),
|
|
60
|
+
supportedFormats: themeSupports.formats,
|
|
66
61
|
};
|
|
67
62
|
},
|
|
68
63
|
[]
|
|
69
64
|
);
|
|
70
65
|
|
|
71
|
-
const formats = POST_FORMATS.filter( ( format ) =>
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
const formats = POST_FORMATS.filter( ( format ) => {
|
|
67
|
+
// Ensure current format is always in the set.
|
|
68
|
+
// The current format may not be a format supported by the theme.
|
|
69
|
+
return (
|
|
70
|
+
includes( supportedFormats, format.id ) || postFormat === format.id
|
|
71
|
+
);
|
|
72
|
+
} );
|
|
74
73
|
const suggestion = find(
|
|
75
74
|
formats,
|
|
76
75
|
( format ) => format.id === suggestedFormat
|
|
@@ -7,10 +7,16 @@ import { get } from 'lodash';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { __, sprintf } from '@wordpress/i18n';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
Modal,
|
|
12
|
+
Button,
|
|
13
|
+
ExternalLink,
|
|
14
|
+
Flex,
|
|
15
|
+
FlexItem,
|
|
16
|
+
} from '@wordpress/components';
|
|
11
17
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
12
18
|
import { addQueryArgs } from '@wordpress/url';
|
|
13
|
-
import { useEffect } from '@wordpress/element';
|
|
19
|
+
import { useEffect, createInterpolateElement } from '@wordpress/element';
|
|
14
20
|
import { addAction, removeAction } from '@wordpress/hooks';
|
|
15
21
|
import { useInstanceId } from '@wordpress/compose';
|
|
16
22
|
import { store as coreStore } from '@wordpress/core-data';
|
|
@@ -19,7 +25,6 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
19
25
|
* Internal dependencies
|
|
20
26
|
*/
|
|
21
27
|
import { getWPAdminURL } from '../../utils/url';
|
|
22
|
-
import PostPreviewButton from '../post-preview-button';
|
|
23
28
|
import { store as editorStore } from '../../store';
|
|
24
29
|
|
|
25
30
|
export default function PostLockedModal() {
|
|
@@ -34,6 +39,7 @@ export default function PostLockedModal() {
|
|
|
34
39
|
postLockUtils,
|
|
35
40
|
activePostLock,
|
|
36
41
|
postType,
|
|
42
|
+
previewLink,
|
|
37
43
|
} = useSelect( ( select ) => {
|
|
38
44
|
const {
|
|
39
45
|
isPostLocked,
|
|
@@ -42,6 +48,7 @@ export default function PostLockedModal() {
|
|
|
42
48
|
getCurrentPostId,
|
|
43
49
|
getActivePostLock,
|
|
44
50
|
getEditedPostAttribute,
|
|
51
|
+
getEditedPostPreviewLink,
|
|
45
52
|
getEditorSettings,
|
|
46
53
|
} = select( editorStore );
|
|
47
54
|
const { getPostType } = select( coreStore );
|
|
@@ -53,6 +60,7 @@ export default function PostLockedModal() {
|
|
|
53
60
|
postLockUtils: getEditorSettings().postLockUtils,
|
|
54
61
|
activePostLock: getActivePostLock(),
|
|
55
62
|
postType: getPostType( getEditedPostAttribute( 'type' ) ),
|
|
63
|
+
previewLink: getEditedPostPreviewLink(),
|
|
56
64
|
};
|
|
57
65
|
}, [] );
|
|
58
66
|
|
|
@@ -94,7 +102,8 @@ export default function PostLockedModal() {
|
|
|
94
102
|
isLocked: true,
|
|
95
103
|
isTakeover: true,
|
|
96
104
|
user: {
|
|
97
|
-
|
|
105
|
+
name: received.lock_error.name,
|
|
106
|
+
avatar: received.lock_error.avatar_src_2x,
|
|
98
107
|
},
|
|
99
108
|
} );
|
|
100
109
|
} else if ( received.new_lock ) {
|
|
@@ -158,13 +167,13 @@ export default function PostLockedModal() {
|
|
|
158
167
|
const allPostsUrl = getWPAdminURL( 'edit.php', {
|
|
159
168
|
post_type: get( postType, [ 'slug' ] ),
|
|
160
169
|
} );
|
|
161
|
-
const allPostsLabel = __( 'Exit
|
|
170
|
+
const allPostsLabel = __( 'Exit editor' );
|
|
162
171
|
return (
|
|
163
172
|
<Modal
|
|
164
173
|
title={
|
|
165
174
|
isTakeover
|
|
166
|
-
? __( 'Someone else has taken over this post
|
|
167
|
-
: __( 'This post is already being edited
|
|
175
|
+
? __( 'Someone else has taken over this post' )
|
|
176
|
+
: __( 'This post is already being edited' )
|
|
168
177
|
}
|
|
169
178
|
focusOnMount={ true }
|
|
170
179
|
shouldCloseOnClickOutside={ false }
|
|
@@ -177,58 +186,88 @@ export default function PostLockedModal() {
|
|
|
177
186
|
src={ userAvatar }
|
|
178
187
|
alt={ __( 'Avatar' ) }
|
|
179
188
|
className="editor-post-locked-modal__avatar"
|
|
189
|
+
width={ 64 }
|
|
190
|
+
height={ 64 }
|
|
180
191
|
/>
|
|
181
192
|
) }
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
<
|
|
185
|
-
{
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
193
|
+
<div>
|
|
194
|
+
{ !! isTakeover && (
|
|
195
|
+
<p>
|
|
196
|
+
{ createInterpolateElement(
|
|
197
|
+
userDisplayName
|
|
198
|
+
? sprintf(
|
|
199
|
+
/* translators: %s: user's display name */
|
|
200
|
+
__(
|
|
201
|
+
'<strong>%s</strong> now has editing control of this posts (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'
|
|
202
|
+
),
|
|
203
|
+
userDisplayName
|
|
204
|
+
)
|
|
205
|
+
: __(
|
|
206
|
+
'Another user now has editing control of this post (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'
|
|
207
|
+
),
|
|
208
|
+
{
|
|
209
|
+
strong: <strong />,
|
|
210
|
+
PreviewLink: (
|
|
211
|
+
<ExternalLink href={ previewLink }>
|
|
212
|
+
{ __( 'preview' ) }
|
|
213
|
+
</ExternalLink>
|
|
214
|
+
),
|
|
215
|
+
}
|
|
216
|
+
) }
|
|
217
|
+
</p>
|
|
218
|
+
) }
|
|
219
|
+
{ ! isTakeover && (
|
|
220
|
+
<>
|
|
221
|
+
<p>
|
|
222
|
+
{ createInterpolateElement(
|
|
223
|
+
userDisplayName
|
|
224
|
+
? sprintf(
|
|
225
|
+
/* translators: %s: user's display name */
|
|
226
|
+
__(
|
|
227
|
+
'<strong>%s</strong> is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'
|
|
228
|
+
),
|
|
229
|
+
userDisplayName
|
|
230
|
+
)
|
|
231
|
+
: __(
|
|
232
|
+
'Another user is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'
|
|
233
|
+
),
|
|
234
|
+
{
|
|
235
|
+
strong: <strong />,
|
|
236
|
+
PreviewLink: (
|
|
237
|
+
<ExternalLink href={ previewLink }>
|
|
238
|
+
{ __( 'preview' ) }
|
|
239
|
+
</ExternalLink>
|
|
190
240
|
),
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
241
|
+
}
|
|
242
|
+
) }
|
|
243
|
+
</p>
|
|
244
|
+
<p>
|
|
245
|
+
{ __(
|
|
246
|
+
'If you take over, the other user will lose editing control to the post, but their changes will be saved.'
|
|
247
|
+
) }
|
|
248
|
+
</p>
|
|
249
|
+
</>
|
|
250
|
+
) }
|
|
251
|
+
|
|
252
|
+
<Flex
|
|
253
|
+
className="editor-post-locked-modal__buttons"
|
|
254
|
+
justify="flex-end"
|
|
255
|
+
expanded={ false }
|
|
256
|
+
>
|
|
257
|
+
{ ! isTakeover && (
|
|
258
|
+
<FlexItem>
|
|
259
|
+
<Button variant="tertiary" href={ unlockUrl }>
|
|
260
|
+
{ __( 'Take over' ) }
|
|
261
|
+
</Button>
|
|
262
|
+
</FlexItem>
|
|
263
|
+
) }
|
|
264
|
+
<FlexItem>
|
|
199
265
|
<Button variant="primary" href={ allPostsUrl }>
|
|
200
266
|
{ allPostsLabel }
|
|
201
267
|
</Button>
|
|
202
|
-
</
|
|
203
|
-
</
|
|
204
|
-
|
|
205
|
-
{ ! isTakeover && (
|
|
206
|
-
<div>
|
|
207
|
-
<div>
|
|
208
|
-
{ userDisplayName
|
|
209
|
-
? sprintf(
|
|
210
|
-
/* translators: %s: user's display name */
|
|
211
|
-
__(
|
|
212
|
-
'%s is currently working on this post, which means you cannot make changes, unless you take over.'
|
|
213
|
-
),
|
|
214
|
-
userDisplayName
|
|
215
|
-
)
|
|
216
|
-
: __(
|
|
217
|
-
'Another user is currently working on this post, which means you cannot make changes, unless you take over.'
|
|
218
|
-
) }
|
|
219
|
-
</div>
|
|
220
|
-
|
|
221
|
-
<div className="editor-post-locked-modal__buttons">
|
|
222
|
-
<Button variant="secondary" href={ allPostsUrl }>
|
|
223
|
-
{ allPostsLabel }
|
|
224
|
-
</Button>
|
|
225
|
-
<PostPreviewButton />
|
|
226
|
-
<Button variant="primary" href={ unlockUrl }>
|
|
227
|
-
{ __( 'Take Over' ) }
|
|
228
|
-
</Button>
|
|
229
|
-
</div>
|
|
230
|
-
</div>
|
|
231
|
-
) }
|
|
268
|
+
</FlexItem>
|
|
269
|
+
</Flex>
|
|
270
|
+
</div>
|
|
232
271
|
</Modal>
|
|
233
272
|
);
|
|
234
273
|
}
|
|
@@ -1,29 +1,19 @@
|
|
|
1
1
|
.editor-post-locked-modal {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
padding-left: 10px;
|
|
5
|
-
padding-top: 10px;
|
|
6
|
-
max-width: 480px;
|
|
7
|
-
|
|
8
|
-
.components-modal__header {
|
|
9
|
-
height: 36px;
|
|
2
|
+
@include break-small() {
|
|
3
|
+
max-width: $break-mobile;
|
|
10
4
|
}
|
|
11
5
|
|
|
12
6
|
.components-modal__content {
|
|
13
|
-
|
|
7
|
+
display: flex;
|
|
14
8
|
}
|
|
15
9
|
}
|
|
16
10
|
|
|
17
11
|
.editor-post-locked-modal__buttons {
|
|
18
|
-
margin-top:
|
|
19
|
-
|
|
20
|
-
.components-button {
|
|
21
|
-
margin-right: 5px;
|
|
22
|
-
}
|
|
12
|
+
margin-top: $grid-unit-30;
|
|
23
13
|
}
|
|
24
14
|
|
|
25
15
|
.editor-post-locked-modal__avatar {
|
|
26
|
-
|
|
27
|
-
margin:
|
|
28
|
-
margin-right:
|
|
16
|
+
border-radius: $radius-block-ui;
|
|
17
|
+
margin-top: $grid-unit-20;
|
|
18
|
+
margin-right: $grid-unit-30;
|
|
29
19
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { some } from 'lodash';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { __ } from '@wordpress/i18n';
|
|
10
|
+
import { useSelect } from '@wordpress/data';
|
|
11
|
+
import { PanelBody } from '@wordpress/components';
|
|
12
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
13
|
+
import { useState, useEffect } from '@wordpress/element';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
import HierarchicalTermSelector from '../post-taxonomies/hierarchical-term-selector';
|
|
19
|
+
import { store as editorStore } from '../../store';
|
|
20
|
+
|
|
21
|
+
function MaybeCategoryPanel() {
|
|
22
|
+
const hasNoCategory = useSelect( ( select ) => {
|
|
23
|
+
const postType = select( editorStore ).getCurrentPostType();
|
|
24
|
+
const categoriesTaxonomy = select( coreStore ).getTaxonomy(
|
|
25
|
+
'category'
|
|
26
|
+
);
|
|
27
|
+
const defaultCategorySlug = 'uncategorized';
|
|
28
|
+
const defaultCategory = select( coreStore ).getEntityRecords(
|
|
29
|
+
'taxonomy',
|
|
30
|
+
'category',
|
|
31
|
+
{
|
|
32
|
+
slug: defaultCategorySlug,
|
|
33
|
+
}
|
|
34
|
+
)?.[ 0 ];
|
|
35
|
+
const postTypeSupportsCategories =
|
|
36
|
+
categoriesTaxonomy &&
|
|
37
|
+
some( categoriesTaxonomy.types, ( type ) => type === postType );
|
|
38
|
+
const categories =
|
|
39
|
+
categoriesTaxonomy &&
|
|
40
|
+
select( editorStore ).getEditedPostAttribute(
|
|
41
|
+
categoriesTaxonomy.rest_base
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// This boolean should return true if everything is loaded
|
|
45
|
+
// ( categoriesTaxonomy, defaultCategory )
|
|
46
|
+
// and the post has not been assigned a category different than "uncategorized".
|
|
47
|
+
return (
|
|
48
|
+
!! categoriesTaxonomy &&
|
|
49
|
+
!! defaultCategory &&
|
|
50
|
+
postTypeSupportsCategories &&
|
|
51
|
+
( categories?.length === 0 ||
|
|
52
|
+
( categories?.length === 1 &&
|
|
53
|
+
defaultCategory.id === categories[ 0 ] ) )
|
|
54
|
+
);
|
|
55
|
+
}, [] );
|
|
56
|
+
const [ shouldShowPanel, setShouldShowPanel ] = useState( false );
|
|
57
|
+
useEffect( () => {
|
|
58
|
+
// We use state to avoid hiding the panel if the user edits the categories
|
|
59
|
+
// and adds one within the panel itself (while visible).
|
|
60
|
+
if ( hasNoCategory ) {
|
|
61
|
+
setShouldShowPanel( true );
|
|
62
|
+
}
|
|
63
|
+
}, [ hasNoCategory ] );
|
|
64
|
+
|
|
65
|
+
if ( ! shouldShowPanel ) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const panelBodyTitle = [
|
|
70
|
+
__( 'Suggestion:' ),
|
|
71
|
+
<span className="editor-post-publish-panel__link" key="label">
|
|
72
|
+
{ __( 'Assign a category' ) }
|
|
73
|
+
</span>,
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<PanelBody initialOpen={ false } title={ panelBodyTitle }>
|
|
78
|
+
<p>
|
|
79
|
+
{ __(
|
|
80
|
+
'Categories provide a helpful way to group related posts together and to quickly tell readers what a post is about.'
|
|
81
|
+
) }
|
|
82
|
+
</p>
|
|
83
|
+
<HierarchicalTermSelector slug="category" />
|
|
84
|
+
</PanelBody>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default MaybeCategoryPanel;
|
|
@@ -24,6 +24,7 @@ import PostScheduleLabel from '../post-schedule/label';
|
|
|
24
24
|
import MaybeTagsPanel from './maybe-tags-panel';
|
|
25
25
|
import MaybePostFormatPanel from './maybe-post-format-panel';
|
|
26
26
|
import { store as editorStore } from '../../store';
|
|
27
|
+
import MaybeCategoryPanel from './maybe-category-panel';
|
|
27
28
|
|
|
28
29
|
function PostPublishPanelPrepublish( { children } ) {
|
|
29
30
|
const {
|
|
@@ -145,6 +146,7 @@ function PostPublishPanelPrepublish( { children } ) {
|
|
|
145
146
|
) }
|
|
146
147
|
<MaybePostFormatPanel />
|
|
147
148
|
<MaybeTagsPanel />
|
|
149
|
+
<MaybeCategoryPanel />
|
|
148
150
|
{ children }
|
|
149
151
|
</div>
|
|
150
152
|
);
|
|
@@ -33,7 +33,31 @@ function customizeProductTypeSelector( OriginalComponent ) {
|
|
|
33
33
|
|
|
34
34
|
wp.hooks.addFilter(
|
|
35
35
|
'editor.PostTaxonomyType',
|
|
36
|
-
'my-custom-
|
|
36
|
+
'my-plugin/set-custom-term-selector',
|
|
37
37
|
customizeProductTypeSelector
|
|
38
38
|
);
|
|
39
39
|
```
|
|
40
|
+
|
|
41
|
+
Or, to use the hierarchical term selector with a non-hierarchical taxonomy `track`,
|
|
42
|
+
you can set the `HierarchicalTermSelector` component as shown below.
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
const el = wp.element.createElement;
|
|
46
|
+
const HierarchicalTermSelector = wp.editor.PostTaxonomiesHierarchicalTermSelector;
|
|
47
|
+
|
|
48
|
+
function customizeTrackSelector( OriginalComponent ) {
|
|
49
|
+
return function ( props ) {
|
|
50
|
+
if ( props.slug === 'track' ) {
|
|
51
|
+
return el( HierarchicalTermSelector, props );
|
|
52
|
+
} else {
|
|
53
|
+
return el( OriginalComponent, props );
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
wp.hooks.addFilter(
|
|
59
|
+
'editor.PostTaxonomyType',
|
|
60
|
+
'my-plugin/set-hierarchical-term-selector',
|
|
61
|
+
customizeTrackSelector
|
|
62
|
+
);
|
|
63
|
+
```
|