@wordpress/editor 14.0.0 → 14.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/block-settings-menu/content-only-settings-menu.js +14 -5
- package/build/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
- package/build/components/document-tools/index.js +12 -3
- package/build/components/document-tools/index.js.map +1 -1
- package/build/components/editor/index.js +83 -0
- package/build/components/editor/index.js.map +1 -0
- package/build/components/editor-interface/index.js +6 -8
- package/build/components/editor-interface/index.js.map +1 -1
- package/build/components/entities-saved-states/entity-record-item.js +4 -12
- package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build/components/global-styles-provider/index.js +9 -2
- package/build/components/global-styles-provider/index.js.map +1 -1
- package/build/components/header/back-button.js +4 -1
- package/build/components/header/back-button.js.map +1 -1
- package/build/components/header/index.js +1 -5
- package/build/components/header/index.js.map +1 -1
- package/build/components/media-categories/index.js +1 -1
- package/build/components/media-categories/index.js.map +1 -1
- package/build/components/post-actions/actions.js +4 -3
- package/build/components/post-actions/actions.js.map +1 -1
- package/build/components/post-last-revision/index.js +35 -9
- package/build/components/post-last-revision/index.js.map +1 -1
- package/build/components/post-preview-button/index.js +1 -0
- package/build/components/post-preview-button/index.js.map +1 -1
- package/build/components/post-publish-panel/index.js +1 -0
- package/build/components/post-publish-panel/index.js.map +1 -1
- package/build/components/post-sync-status/index.js +1 -1
- package/build/components/post-sync-status/index.js.map +1 -1
- package/build/components/post-trash/index.js +1 -0
- package/build/components/post-trash/index.js.map +1 -1
- package/build/components/post-url/panel.js +25 -3
- package/build/components/post-url/panel.js.map +1 -1
- package/build/components/post-visibility/index.js +1 -0
- package/build/components/post-visibility/index.js.map +1 -1
- package/build/components/provider/disable-non-page-content-blocks.js +5 -3
- package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/sidebar/post-summary.js +2 -1
- package/build/components/sidebar/post-summary.js.map +1 -1
- package/build/components/template-validation-notice/index.js +1 -0
- package/build/components/template-validation-notice/index.js.map +1 -1
- package/build/components/visual-editor/edit-template-blocks-notification.js +1 -0
- package/build/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
- package/build/hooks/pattern-overrides.js +2 -1
- package/build/hooks/pattern-overrides.js.map +1 -1
- package/build/lock-unlock.js +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/private-apis.js +3 -1
- package/build/private-apis.js.map +1 -1
- package/build-module/components/block-settings-menu/content-only-settings-menu.js +14 -5
- package/build-module/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
- package/build-module/components/document-tools/index.js +12 -3
- package/build-module/components/document-tools/index.js.map +1 -1
- package/build-module/components/editor/index.js +76 -0
- package/build-module/components/editor/index.js.map +1 -0
- package/build-module/components/editor-interface/index.js +6 -8
- package/build-module/components/editor-interface/index.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-record-item.js +6 -14
- package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build-module/components/global-styles-provider/index.js +9 -2
- package/build-module/components/global-styles-provider/index.js.map +1 -1
- package/build-module/components/header/back-button.js +4 -1
- package/build-module/components/header/back-button.js.map +1 -1
- package/build-module/components/header/index.js +1 -5
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/media-categories/index.js +1 -1
- package/build-module/components/media-categories/index.js.map +1 -1
- package/build-module/components/post-actions/actions.js +4 -3
- package/build-module/components/post-actions/actions.js.map +1 -1
- package/build-module/components/post-last-revision/index.js +34 -11
- package/build-module/components/post-last-revision/index.js.map +1 -1
- package/build-module/components/post-preview-button/index.js +1 -0
- package/build-module/components/post-preview-button/index.js.map +1 -1
- package/build-module/components/post-publish-panel/index.js +1 -0
- package/build-module/components/post-publish-panel/index.js.map +1 -1
- package/build-module/components/post-sync-status/index.js +1 -1
- package/build-module/components/post-sync-status/index.js.map +1 -1
- package/build-module/components/post-trash/index.js +1 -0
- package/build-module/components/post-trash/index.js.map +1 -1
- package/build-module/components/post-url/panel.js +26 -3
- package/build-module/components/post-url/panel.js.map +1 -1
- package/build-module/components/post-visibility/index.js +1 -0
- package/build-module/components/post-visibility/index.js.map +1 -1
- package/build-module/components/provider/disable-non-page-content-blocks.js +5 -3
- package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/sidebar/post-summary.js +2 -1
- package/build-module/components/sidebar/post-summary.js.map +1 -1
- package/build-module/components/template-validation-notice/index.js +1 -0
- package/build-module/components/template-validation-notice/index.js.map +1 -1
- package/build-module/components/visual-editor/edit-template-blocks-notification.js +1 -0
- package/build-module/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
- package/build-module/hooks/pattern-overrides.js +2 -1
- package/build-module/hooks/pattern-overrides.js.map +1 -1
- package/build-module/lock-unlock.js +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-style/style-rtl.css +29 -56
- package/build-style/style.css +29 -56
- package/package.json +35 -35
- package/src/components/block-settings-menu/content-only-settings-menu.js +26 -12
- package/src/components/collapsible-block-toolbar/style.scss +3 -1
- package/src/components/document-tools/index.js +13 -4
- package/src/components/editor/index.js +93 -0
- package/src/components/editor-interface/index.js +5 -5
- package/src/components/editor-interface/style.scss +3 -0
- package/src/components/entities-saved-states/entity-record-item.js +4 -14
- package/src/components/entities-saved-states/style.scss +0 -20
- package/src/components/global-styles-provider/index.js +12 -2
- package/src/components/header/back-button.js +6 -1
- package/src/components/header/index.js +1 -8
- package/src/components/header/style.scss +1 -1
- package/src/components/media-categories/index.js +1 -3
- package/src/components/post-actions/actions.js +4 -2
- package/src/components/post-last-revision/index.js +30 -7
- package/src/components/post-last-revision/style.scss +4 -0
- package/src/components/post-panel-row/style.scss +1 -0
- package/src/components/post-preview-button/index.js +1 -0
- package/src/components/post-preview-button/test/index.js +10 -2
- package/src/components/post-publish-panel/index.js +1 -0
- package/src/components/post-publish-panel/style.scss +28 -36
- package/src/components/post-sync-status/index.js +2 -8
- package/src/components/post-trash/index.js +1 -0
- package/src/components/post-url/panel.js +13 -5
- package/src/components/post-visibility/index.js +1 -0
- package/src/components/provider/disable-non-page-content-blocks.js +9 -4
- package/src/components/save-publish-panels/style.scss +0 -8
- package/src/components/sidebar/post-summary.js +2 -0
- package/src/components/template-validation-notice/index.js +1 -0
- package/src/components/visual-editor/edit-template-blocks-notification.js +1 -0
- package/src/hooks/pattern-overrides.js +2 -0
- package/src/lock-unlock.js +1 -1
- package/src/private-apis.js +3 -1
- package/src/style.scss +1 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
6
|
+
import { Notice } from '@wordpress/components';
|
|
7
|
+
import { __ } from '@wordpress/i18n';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { TEMPLATE_POST_TYPE } from '../../store/constants';
|
|
13
|
+
import EditorInterface from '../editor-interface';
|
|
14
|
+
import { ExperimentalEditorProvider } from '../provider';
|
|
15
|
+
import Sidebar from '../sidebar';
|
|
16
|
+
|
|
17
|
+
function Editor( {
|
|
18
|
+
postType,
|
|
19
|
+
postId,
|
|
20
|
+
templateId,
|
|
21
|
+
settings,
|
|
22
|
+
children,
|
|
23
|
+
|
|
24
|
+
// This could be part of the settings.
|
|
25
|
+
onActionPerformed,
|
|
26
|
+
|
|
27
|
+
// The following abstractions are not ideal but necessary
|
|
28
|
+
// to account for site editor and post editor differences for now.
|
|
29
|
+
className,
|
|
30
|
+
styles,
|
|
31
|
+
customSaveButton,
|
|
32
|
+
forceDisableBlockTools,
|
|
33
|
+
title,
|
|
34
|
+
iframeProps,
|
|
35
|
+
extraSidebarPanels,
|
|
36
|
+
enableRegionNavigation = true,
|
|
37
|
+
} ) {
|
|
38
|
+
const { post, template, hasLoadedPost } = useSelect(
|
|
39
|
+
( select ) => {
|
|
40
|
+
const { getEntityRecord, hasFinishedResolution } =
|
|
41
|
+
select( coreStore );
|
|
42
|
+
return {
|
|
43
|
+
post: getEntityRecord( 'postType', postType, postId ),
|
|
44
|
+
template: templateId
|
|
45
|
+
? getEntityRecord(
|
|
46
|
+
'postType',
|
|
47
|
+
TEMPLATE_POST_TYPE,
|
|
48
|
+
templateId
|
|
49
|
+
)
|
|
50
|
+
: undefined,
|
|
51
|
+
hasLoadedPost: hasFinishedResolution( 'getEntityRecord', [
|
|
52
|
+
'postType',
|
|
53
|
+
postType,
|
|
54
|
+
postId,
|
|
55
|
+
] ),
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
[ postType, postId, templateId ]
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<ExperimentalEditorProvider
|
|
63
|
+
post={ post }
|
|
64
|
+
__unstableTemplate={ template }
|
|
65
|
+
settings={ settings }
|
|
66
|
+
useSubRegistry={ false }
|
|
67
|
+
>
|
|
68
|
+
{ hasLoadedPost && ! post && (
|
|
69
|
+
<Notice status="warning" isDismissible={ false }>
|
|
70
|
+
{ __(
|
|
71
|
+
"You attempted to edit an item that doesn't exist. Perhaps it was deleted?"
|
|
72
|
+
) }
|
|
73
|
+
</Notice>
|
|
74
|
+
) }
|
|
75
|
+
<EditorInterface
|
|
76
|
+
className={ className }
|
|
77
|
+
styles={ styles }
|
|
78
|
+
enableRegionNavigation={ enableRegionNavigation }
|
|
79
|
+
customSaveButton={ customSaveButton }
|
|
80
|
+
forceDisableBlockTools={ forceDisableBlockTools }
|
|
81
|
+
title={ title }
|
|
82
|
+
iframeProps={ iframeProps }
|
|
83
|
+
/>
|
|
84
|
+
<Sidebar
|
|
85
|
+
onActionPerformed={ onActionPerformed }
|
|
86
|
+
extraPanels={ extraSidebarPanels }
|
|
87
|
+
/>
|
|
88
|
+
{ children }
|
|
89
|
+
</ExperimentalEditorProvider>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export default Editor;
|
|
@@ -121,8 +121,10 @@ export default function EditorInterface( {
|
|
|
121
121
|
<InterfaceSkeleton
|
|
122
122
|
enableRegionNavigation={ enableRegionNavigation }
|
|
123
123
|
isDistractionFree={ isDistractionFree && isWideViewport }
|
|
124
|
-
className={ clsx( className, {
|
|
124
|
+
className={ clsx( 'editor-editor-interface', className, {
|
|
125
125
|
'is-entity-save-view-open': !! entitiesSavedStatesCallback,
|
|
126
|
+
'is-distraction-free':
|
|
127
|
+
isDistractionFree && isWideViewport && ! isPreviewMode,
|
|
126
128
|
} ) }
|
|
127
129
|
labels={ {
|
|
128
130
|
...interfaceLabels,
|
|
@@ -160,7 +162,7 @@ export default function EditorInterface( {
|
|
|
160
162
|
|
|
161
163
|
<EditorContentSlotFill.Slot>
|
|
162
164
|
{ ( [ editorCanvasView ] ) =>
|
|
163
|
-
|
|
165
|
+
editorCanvasView ? (
|
|
164
166
|
editorCanvasView
|
|
165
167
|
) : (
|
|
166
168
|
<>
|
|
@@ -206,9 +208,7 @@ export default function EditorInterface( {
|
|
|
206
208
|
isRichEditingEnabled &&
|
|
207
209
|
blockEditorMode !== 'zoom-out' &&
|
|
208
210
|
mode === 'visual' && (
|
|
209
|
-
<
|
|
210
|
-
<BlockBreadcrumb rootLabelText={ documentLabel } />
|
|
211
|
-
</div>
|
|
211
|
+
<BlockBreadcrumb rootLabelText={ documentLabel } />
|
|
212
212
|
)
|
|
213
213
|
}
|
|
214
214
|
actions={
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { CheckboxControl, PanelRow } from '@wordpress/components';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
import { useSelect } from '@wordpress/data';
|
|
7
7
|
import { store as coreStore } from '@wordpress/core-data';
|
|
8
8
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
9
|
-
import { connection } from '@wordpress/icons';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Internal dependencies
|
|
@@ -60,18 +59,9 @@ export default function EntityRecordItem( { record, checked, onChange } ) {
|
|
|
60
59
|
/>
|
|
61
60
|
</PanelRow>
|
|
62
61
|
{ hasPostMetaChanges && (
|
|
63
|
-
<
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
className="entities-saved-states__connections-icon"
|
|
67
|
-
icon={ connection }
|
|
68
|
-
size={ 24 }
|
|
69
|
-
/>
|
|
70
|
-
<span className="entities-saved-states__bindings-text">
|
|
71
|
-
{ __( 'Post Meta.' ) }
|
|
72
|
-
</span>
|
|
73
|
-
</Flex>
|
|
74
|
-
</PanelRow>
|
|
62
|
+
<ul className="entities-saved-states__changes">
|
|
63
|
+
<li>{ __( 'Post Meta.' ) }</li>
|
|
64
|
+
</ul>
|
|
75
65
|
) }
|
|
76
66
|
</>
|
|
77
67
|
);
|
|
@@ -30,23 +30,3 @@
|
|
|
30
30
|
margin-bottom: $grid-unit-05;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
.edit-post-layout,
|
|
35
|
-
.edit-site-editor__interface-skeleton {
|
|
36
|
-
.entities-saved-states__panel-header {
|
|
37
|
-
height: $header-height + $border-width;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.entities-saved-states__post-meta {
|
|
42
|
-
margin-left: $grid-unit-30;
|
|
43
|
-
align-items: center;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.entities-saved-states__connections-icon {
|
|
47
|
-
flex-grow: 0;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.entities-saved-states__bindings-text {
|
|
51
|
-
flex-grow: 1;
|
|
52
|
-
}
|
|
@@ -163,7 +163,13 @@ function useGlobalStylesUserConfig() {
|
|
|
163
163
|
}, [ settings, styles, _links ] );
|
|
164
164
|
|
|
165
165
|
const setConfig = useCallback(
|
|
166
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Set the global styles config.
|
|
168
|
+
* @param {Function|Object} callbackOrObject If the callbackOrObject is a function, pass the current config to the callback so the consumer can merge values.
|
|
169
|
+
* Otherwise, overwrite the current config with the incoming object.
|
|
170
|
+
* @param {Object} options Options for editEntityRecord Core selector.
|
|
171
|
+
*/
|
|
172
|
+
( callbackOrObject, options = {} ) => {
|
|
167
173
|
const record = getEditedEntityRecord(
|
|
168
174
|
'root',
|
|
169
175
|
'globalStyles',
|
|
@@ -175,7 +181,11 @@ function useGlobalStylesUserConfig() {
|
|
|
175
181
|
settings: record?.settings ?? {},
|
|
176
182
|
_links: record?._links ?? {},
|
|
177
183
|
};
|
|
178
|
-
|
|
184
|
+
|
|
185
|
+
const updatedConfig =
|
|
186
|
+
typeof callbackOrObject === 'function'
|
|
187
|
+
? callbackOrObject( currentConfig )
|
|
188
|
+
: callbackOrObject;
|
|
179
189
|
|
|
180
190
|
editEntityRecord(
|
|
181
191
|
'root',
|
|
@@ -20,7 +20,12 @@ const BackButtonSlot = ( { children } ) => {
|
|
|
20
20
|
return children;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
return
|
|
23
|
+
return (
|
|
24
|
+
<Slot
|
|
25
|
+
bubblesVirtually
|
|
26
|
+
fillProps={ { length: ! fills ? 0 : fills.length } }
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
24
29
|
};
|
|
25
30
|
BackButton.Slot = BackButtonSlot;
|
|
26
31
|
|
|
@@ -25,7 +25,6 @@ import MoreMenu from '../more-menu';
|
|
|
25
25
|
import PostPreviewButton from '../post-preview-button';
|
|
26
26
|
import PostPublishButtonOrToggle from '../post-publish-button/post-publish-button-or-toggle';
|
|
27
27
|
import PostSavedState from '../post-saved-state';
|
|
28
|
-
import PostTypeSupportCheck from '../post-type-support-check';
|
|
29
28
|
import PostViewLink from '../post-view-link';
|
|
30
29
|
import PreviewDropdown from '../preview-dropdown';
|
|
31
30
|
import { store as editorStore } from '../../store';
|
|
@@ -117,13 +116,7 @@ function Header( {
|
|
|
117
116
|
! isBlockToolsCollapsed && hasTopToolbar,
|
|
118
117
|
} ) }
|
|
119
118
|
>
|
|
120
|
-
{ ! title ?
|
|
121
|
-
<PostTypeSupportCheck supportKeys="title">
|
|
122
|
-
<DocumentBar />
|
|
123
|
-
</PostTypeSupportCheck>
|
|
124
|
-
) : (
|
|
125
|
-
title
|
|
126
|
-
) }
|
|
119
|
+
{ ! title ? <DocumentBar /> : title }
|
|
127
120
|
</div>
|
|
128
121
|
</motion.div>
|
|
129
122
|
<motion.div
|
|
@@ -191,9 +191,7 @@ const inserterMediaCategories = [
|
|
|
191
191
|
per_page: 'page_size',
|
|
192
192
|
search: 'q',
|
|
193
193
|
};
|
|
194
|
-
const url = new URL(
|
|
195
|
-
'https://api.openverse.engineering/v1/images/'
|
|
196
|
-
);
|
|
194
|
+
const url = new URL( 'https://api.openverse.org/v1/images/' );
|
|
197
195
|
Object.entries( finalQuery ).forEach( ( [ key, value ] ) => {
|
|
198
196
|
const queryKey = mapFromInserterMediaRequest[ key ] || key;
|
|
199
197
|
url.searchParams.set( queryKey, value );
|
|
@@ -783,7 +783,7 @@ const duplicatePostAction = {
|
|
|
783
783
|
sprintf(
|
|
784
784
|
// translators: %s: Title of the created template e.g: "Category".
|
|
785
785
|
__( '"%s" successfully created.' ),
|
|
786
|
-
newItem.title?.rendered || title
|
|
786
|
+
decodeEntities( newItem.title?.rendered || title )
|
|
787
787
|
),
|
|
788
788
|
{
|
|
789
789
|
id: 'duplicate-post-action',
|
|
@@ -1049,6 +1049,7 @@ export function usePostActions( postType, onActionPerformed ) {
|
|
|
1049
1049
|
const isPattern = postType === PATTERN_POST_TYPE;
|
|
1050
1050
|
const isLoaded = !! postTypeObject;
|
|
1051
1051
|
const supportsRevisions = !! postTypeObject?.supports?.revisions;
|
|
1052
|
+
const supportsTitle = !! postTypeObject?.supports?.title;
|
|
1052
1053
|
return useMemo( () => {
|
|
1053
1054
|
if ( ! isLoaded ) {
|
|
1054
1055
|
return [];
|
|
@@ -1064,7 +1065,7 @@ export function usePostActions( postType, onActionPerformed ) {
|
|
|
1064
1065
|
: false,
|
|
1065
1066
|
isTemplateOrTemplatePart && duplicateTemplatePartAction,
|
|
1066
1067
|
isPattern && duplicatePatternAction,
|
|
1067
|
-
renamePostAction,
|
|
1068
|
+
supportsTitle && renamePostAction,
|
|
1068
1069
|
isPattern && exportPatternAsJSONAction,
|
|
1069
1070
|
isTemplateOrTemplatePart ? resetTemplateAction : restorePostAction,
|
|
1070
1071
|
isTemplateOrTemplatePart || isPattern
|
|
@@ -1124,5 +1125,6 @@ export function usePostActions( postType, onActionPerformed ) {
|
|
|
1124
1125
|
onActionPerformed,
|
|
1125
1126
|
isLoaded,
|
|
1126
1127
|
supportsRevisions,
|
|
1128
|
+
supportsTitle,
|
|
1127
1129
|
] );
|
|
1128
1130
|
}
|
|
@@ -11,15 +11,11 @@ import { addQueryArgs } from '@wordpress/url';
|
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
13
|
import PostLastRevisionCheck from './check';
|
|
14
|
+
import PostPanelRow from '../post-panel-row';
|
|
14
15
|
import { store as editorStore } from '../../store';
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*
|
|
19
|
-
* @return {Component} The component to be rendered.
|
|
20
|
-
*/
|
|
21
|
-
function PostLastRevision() {
|
|
22
|
-
const { lastRevisionId, revisionsCount } = useSelect( ( select ) => {
|
|
17
|
+
function usePostLastRevisionInfo() {
|
|
18
|
+
return useSelect( ( select ) => {
|
|
23
19
|
const { getCurrentPostLastRevisionId, getCurrentPostRevisionsCount } =
|
|
24
20
|
select( editorStore );
|
|
25
21
|
return {
|
|
@@ -27,6 +23,15 @@ function PostLastRevision() {
|
|
|
27
23
|
revisionsCount: getCurrentPostRevisionsCount(),
|
|
28
24
|
};
|
|
29
25
|
}, [] );
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Renders the component for displaying the last revision of a post.
|
|
30
|
+
*
|
|
31
|
+
* @return {Component} The component to be rendered.
|
|
32
|
+
*/
|
|
33
|
+
function PostLastRevision() {
|
|
34
|
+
const { lastRevisionId, revisionsCount } = usePostLastRevisionInfo();
|
|
30
35
|
|
|
31
36
|
return (
|
|
32
37
|
<PostLastRevisionCheck>
|
|
@@ -47,4 +52,22 @@ function PostLastRevision() {
|
|
|
47
52
|
);
|
|
48
53
|
}
|
|
49
54
|
|
|
55
|
+
export function PrivatePostLastRevision() {
|
|
56
|
+
const { lastRevisionId, revisionsCount } = usePostLastRevisionInfo();
|
|
57
|
+
return (
|
|
58
|
+
<PostLastRevisionCheck>
|
|
59
|
+
<PostPanelRow label={ __( 'Revisions' ) }>
|
|
60
|
+
<Button
|
|
61
|
+
href={ addQueryArgs( 'revision.php', {
|
|
62
|
+
revision: lastRevisionId,
|
|
63
|
+
} ) }
|
|
64
|
+
className="editor-private-post-last-revision__button"
|
|
65
|
+
text={ revisionsCount }
|
|
66
|
+
variant="tertiary"
|
|
67
|
+
/>
|
|
68
|
+
</PostPanelRow>
|
|
69
|
+
</PostLastRevisionCheck>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
50
73
|
export default PostLastRevision;
|
|
@@ -139,12 +139,16 @@ describe( 'PostPreviewButton', () => {
|
|
|
139
139
|
).toBeInTheDocument();
|
|
140
140
|
} );
|
|
141
141
|
|
|
142
|
-
it( 'should be disabled if post is not saveable.', () => {
|
|
142
|
+
it( 'should be accessibly disabled if post is not saveable.', () => {
|
|
143
143
|
mockUseSelect( { isEditedPostSaveable: () => false } );
|
|
144
144
|
|
|
145
145
|
render( <PostPreviewButton /> );
|
|
146
146
|
|
|
147
|
-
expect( screen.getByRole( 'button' ) ).
|
|
147
|
+
expect( screen.getByRole( 'button' ) ).toBeEnabled();
|
|
148
|
+
expect( screen.getByRole( 'button' ) ).toHaveAttribute(
|
|
149
|
+
'aria-disabled',
|
|
150
|
+
'true'
|
|
151
|
+
);
|
|
148
152
|
} );
|
|
149
153
|
|
|
150
154
|
it( 'should not be disabled if post is saveable.', () => {
|
|
@@ -153,6 +157,10 @@ describe( 'PostPreviewButton', () => {
|
|
|
153
157
|
render( <PostPreviewButton /> );
|
|
154
158
|
|
|
155
159
|
expect( screen.getByRole( 'button' ) ).toBeEnabled();
|
|
160
|
+
expect( screen.getByRole( 'button' ) ).not.toHaveAttribute(
|
|
161
|
+
'aria-disabled',
|
|
162
|
+
'true'
|
|
163
|
+
);
|
|
156
164
|
} );
|
|
157
165
|
|
|
158
166
|
it( 'should set `href` to edited post preview link if specified.', () => {
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
.editor-post-publish-panel {
|
|
2
|
-
background: $white;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
1
|
.editor-post-publish-panel__content {
|
|
6
2
|
// Ensure the post-publish panel accounts for the header and footer height.
|
|
7
3
|
min-height: calc(100% - #{$header-height + 84px});
|
|
@@ -71,6 +67,7 @@
|
|
|
71
67
|
|
|
72
68
|
.editor-post-publish-panel__header-publish-button {
|
|
73
69
|
padding-right: $grid-unit-05;
|
|
70
|
+
justify-content: center;
|
|
74
71
|
}
|
|
75
72
|
|
|
76
73
|
.editor-post-publish-panel__header-cancel-button {
|
|
@@ -122,6 +119,7 @@
|
|
|
122
119
|
|
|
123
120
|
.components-panel__body-title .components-button {
|
|
124
121
|
align-items: flex-start;
|
|
122
|
+
text-wrap: balance; // Fallback for Safari.
|
|
125
123
|
text-wrap: pretty;
|
|
126
124
|
}
|
|
127
125
|
}
|
|
@@ -194,40 +192,34 @@
|
|
|
194
192
|
}
|
|
195
193
|
}
|
|
196
194
|
|
|
197
|
-
.
|
|
198
|
-
|
|
199
|
-
.editor-post-publish-panel
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
top: 0;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// Keep it open on focus to avoid conflict with navigate-regions animation.
|
|
223
|
-
[role="region"]:focus & {
|
|
224
|
-
transform: translateX(0%);
|
|
225
|
-
}
|
|
195
|
+
.editor-post-publish-panel {
|
|
196
|
+
position: fixed;
|
|
197
|
+
z-index: z-index(".editor-post-publish-panel");
|
|
198
|
+
background: $white;
|
|
199
|
+
top: 0;
|
|
200
|
+
bottom: 0;
|
|
201
|
+
right: 0;
|
|
202
|
+
left: 0;
|
|
203
|
+
overflow: auto;
|
|
204
|
+
|
|
205
|
+
@include break-medium() {
|
|
206
|
+
z-index: z-index(".editor-post-publish-panel {greater than small}");
|
|
207
|
+
top: $admin-bar-height;
|
|
208
|
+
left: auto;
|
|
209
|
+
width: $sidebar-width + $border-width;
|
|
210
|
+
border-left: $border-width solid $gray-300;
|
|
211
|
+
transform: translateX(+100%);
|
|
212
|
+
animation: editor-post-publish-panel__slide-in-animation 0.1s forwards;
|
|
213
|
+
@include reduce-motion("animation");
|
|
214
|
+
|
|
215
|
+
body.is-fullscreen-mode & {
|
|
216
|
+
top: 0;
|
|
226
217
|
}
|
|
227
|
-
}
|
|
228
218
|
|
|
229
|
-
|
|
230
|
-
|
|
219
|
+
// Keep it open on focus to avoid conflict with navigate-regions animation.
|
|
220
|
+
[role="region"]:focus & {
|
|
221
|
+
transform: translateX(0%);
|
|
222
|
+
}
|
|
231
223
|
}
|
|
232
224
|
}
|
|
233
225
|
|
|
@@ -35,14 +35,8 @@ export default function PostSyncStatus() {
|
|
|
35
35
|
<PostPanelRow label={ __( 'Sync status' ) }>
|
|
36
36
|
<div className="editor-post-sync-status__value">
|
|
37
37
|
{ syncStatus === 'unsynced'
|
|
38
|
-
? _x(
|
|
39
|
-
|
|
40
|
-
'Text that indicates that the pattern is not synchronized'
|
|
41
|
-
)
|
|
42
|
-
: _x(
|
|
43
|
-
'Synced',
|
|
44
|
-
'Text that indicates that the pattern is synchronized'
|
|
45
|
-
) }
|
|
38
|
+
? _x( 'Not synced', 'pattern (singular)' )
|
|
39
|
+
: _x( 'Synced', 'pattern (singular)' ) }
|
|
46
40
|
</div>
|
|
47
41
|
</PostPanelRow>
|
|
48
42
|
);
|
|
@@ -6,6 +6,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
6
6
|
import { Dropdown, Button } from '@wordpress/components';
|
|
7
7
|
import { __, sprintf } from '@wordpress/i18n';
|
|
8
8
|
import { safeDecodeURIComponent } from '@wordpress/url';
|
|
9
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Internal dependencies
|
|
@@ -58,10 +59,17 @@ export default function PostURLPanel() {
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
function PostURLToggle( { isOpen, onClick } ) {
|
|
61
|
-
const slug = useSelect(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
const { slug, isFrontPage, postLink } = useSelect( ( select ) => {
|
|
63
|
+
const { getCurrentPostId, getCurrentPost } = select( editorStore );
|
|
64
|
+
const { getEditedEntityRecord } = select( coreStore );
|
|
65
|
+
const siteSettings = getEditedEntityRecord( 'root', 'site' );
|
|
66
|
+
const _id = getCurrentPostId();
|
|
67
|
+
return {
|
|
68
|
+
slug: select( editorStore ).getEditedPostSlug(),
|
|
69
|
+
isFrontPage: siteSettings?.page_on_front === _id,
|
|
70
|
+
postLink: getCurrentPost()?.link,
|
|
71
|
+
};
|
|
72
|
+
}, [] );
|
|
65
73
|
const decodedSlug = safeDecodeURIComponent( slug );
|
|
66
74
|
return (
|
|
67
75
|
<Button
|
|
@@ -73,7 +81,7 @@ function PostURLToggle( { isOpen, onClick } ) {
|
|
|
73
81
|
aria-label={ sprintf( __( 'Change link: %s' ), decodedSlug ) }
|
|
74
82
|
onClick={ onClick }
|
|
75
83
|
>
|
|
76
|
-
|
|
84
|
+
{ isFrontPage ? postLink : <>/{ decodedSlug }</> }
|
|
77
85
|
</Button>
|
|
78
86
|
);
|
|
79
87
|
}
|
|
@@ -133,6 +133,7 @@ export default function PostVisibility( { onClose } ) {
|
|
|
133
133
|
onConfirm={ confirmPrivate }
|
|
134
134
|
onCancel={ handleDialogCancel }
|
|
135
135
|
confirmButtonText={ __( 'Publish' ) }
|
|
136
|
+
size="medium"
|
|
136
137
|
>
|
|
137
138
|
{ __( 'Would you like to privately publish this post now?' ) }
|
|
138
139
|
</ConfirmDialog>
|
|
@@ -6,31 +6,36 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
|
6
6
|
import { useEffect } from '@wordpress/element';
|
|
7
7
|
import { applyFilters } from '@wordpress/hooks';
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const DEFAULT_CONTENT_ONLY_BLOCKS = [
|
|
10
10
|
'core/post-title',
|
|
11
11
|
'core/post-featured-image',
|
|
12
12
|
'core/post-content',
|
|
13
13
|
'core/template-part',
|
|
14
|
-
]
|
|
14
|
+
];
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Component that when rendered, makes it so that the site editor allows only
|
|
18
18
|
* page content to be edited.
|
|
19
19
|
*/
|
|
20
20
|
export default function DisableNonPageContentBlocks() {
|
|
21
|
+
const contentOnlyBlocks = applyFilters(
|
|
22
|
+
'editor.postContentBlockTypes',
|
|
23
|
+
DEFAULT_CONTENT_ONLY_BLOCKS
|
|
24
|
+
);
|
|
25
|
+
|
|
21
26
|
// Note that there are two separate subscription because the result for each
|
|
22
27
|
// returns a new array.
|
|
23
28
|
const contentOnlyIds = useSelect( ( select ) => {
|
|
24
29
|
const { getBlocksByName, getBlockParents, getBlockName } =
|
|
25
30
|
select( blockEditorStore );
|
|
26
|
-
return getBlocksByName(
|
|
31
|
+
return getBlocksByName( contentOnlyBlocks ).filter( ( clientId ) =>
|
|
27
32
|
getBlockParents( clientId ).every( ( parentClientId ) => {
|
|
28
33
|
const parentBlockName = getBlockName( parentClientId );
|
|
29
34
|
return (
|
|
30
35
|
// Ignore descendents of the query block.
|
|
31
36
|
parentBlockName !== 'core/query' &&
|
|
32
37
|
// Enable only the top-most block.
|
|
33
|
-
!
|
|
38
|
+
! contentOnlyBlocks.includes( parentBlockName )
|
|
34
39
|
);
|
|
35
40
|
} )
|
|
36
41
|
);
|
|
@@ -30,6 +30,7 @@ import PostsPerPage from '../posts-per-page';
|
|
|
30
30
|
import SiteDiscussion from '../site-discussion';
|
|
31
31
|
import { store as editorStore } from '../../store';
|
|
32
32
|
import TemplateAreas from '../template-areas';
|
|
33
|
+
import { PrivatePostLastRevision } from '../post-last-revision';
|
|
33
34
|
|
|
34
35
|
/**
|
|
35
36
|
* Module Constants
|
|
@@ -76,6 +77,7 @@ export default function PostSummary( { onActionPerformed } ) {
|
|
|
76
77
|
<PostAuthorPanel />
|
|
77
78
|
<PostTemplatePanel />
|
|
78
79
|
<PostDiscussionPanel />
|
|
80
|
+
<PrivatePostLastRevision />
|
|
79
81
|
<PageAttributesPanel />
|
|
80
82
|
<PostSyncStatus />
|
|
81
83
|
<BlogTitle />
|