@wordpress/editor 14.38.0 → 14.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/document-bar/useEditedSectionDetails.cjs +0 -3
- package/build/components/document-bar/useEditedSectionDetails.cjs.map +2 -2
- package/build/components/editor-interface/index.cjs +33 -9
- package/build/components/editor-interface/index.cjs.map +2 -2
- package/build/components/header/header-skeleton.cjs +100 -0
- package/build/components/header/header-skeleton.cjs.map +7 -0
- package/build/components/header/index.cjs +63 -106
- package/build/components/header/index.cjs.map +3 -3
- package/build/components/media/index.cjs +44 -0
- package/build/components/media/index.cjs.map +7 -0
- package/build/components/media/metadata-panel.cjs +96 -0
- package/build/components/media/metadata-panel.cjs.map +7 -0
- package/build/components/media/preview.cjs +39 -0
- package/build/components/media/preview.cjs.map +7 -0
- package/build/components/more-menu/index.cjs +3 -2
- package/build/components/more-menu/index.cjs.map +2 -2
- package/build/components/post-card-panel/index.cjs +33 -4
- package/build/components/post-card-panel/index.cjs.map +3 -3
- package/build/components/post-content-information/index.cjs +9 -0
- package/build/components/post-content-information/index.cjs.map +2 -2
- package/build/components/post-last-edited-panel/index.cjs +5 -6
- package/build/components/post-last-edited-panel/index.cjs.map +2 -2
- package/build/components/post-last-revision/index.cjs +5 -7
- package/build/components/post-last-revision/index.cjs.map +2 -2
- package/build/components/post-publish-button/label.cjs +6 -1
- package/build/components/post-publish-button/label.cjs.map +2 -2
- package/build/components/post-publish-button/post-publish-button-or-toggle.cjs +8 -3
- package/build/components/post-publish-button/post-publish-button-or-toggle.cjs.map +2 -2
- package/build/components/post-revisions-preview/index.cjs +44 -0
- package/build/components/post-revisions-preview/index.cjs.map +7 -0
- package/build/components/post-revisions-preview/revisions-canvas.cjs +82 -0
- package/build/components/post-revisions-preview/revisions-canvas.cjs.map +7 -0
- package/build/components/post-revisions-preview/revisions-header.cjs +119 -0
- package/build/components/post-revisions-preview/revisions-header.cjs.map +7 -0
- package/build/components/post-revisions-preview/revisions-slider.cjs +110 -0
- package/build/components/post-revisions-preview/revisions-slider.cjs.map +7 -0
- package/build/components/post-saved-state/index.cjs +8 -2
- package/build/components/post-saved-state/index.cjs.map +2 -2
- package/build/components/post-title/index.cjs +5 -4
- package/build/components/post-title/index.cjs.map +2 -2
- package/build/components/provider/index.cjs +19 -0
- package/build/components/provider/index.cjs.map +3 -3
- package/build/components/provider/use-block-editor-settings.cjs +2 -1
- package/build/components/provider/use-block-editor-settings.cjs.map +2 -2
- package/build/components/revision-author-panel/index.cjs +59 -0
- package/build/components/revision-author-panel/index.cjs.map +7 -0
- package/build/components/revision-created-panel/index.cjs +47 -0
- package/build/components/revision-created-panel/index.cjs.map +7 -0
- package/build/components/sidebar/header.cjs +27 -12
- package/build/components/sidebar/header.cjs.map +3 -3
- package/build/components/sidebar/index.cjs +36 -15
- package/build/components/sidebar/index.cjs.map +3 -3
- package/build/components/sidebar/post-summary.cjs +44 -19
- package/build/components/sidebar/post-summary.cjs.map +3 -3
- package/build/components/start-page-options/index.cjs +1 -1
- package/build/components/start-page-options/index.cjs.map +2 -2
- package/build/dataviews/store/private-actions.cjs +47 -26
- package/build/dataviews/store/private-actions.cjs.map +3 -3
- package/build/store/constants.cjs +3 -0
- package/build/store/constants.cjs.map +2 -2
- package/build/store/private-actions.cjs +40 -0
- package/build/store/private-actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +33 -2
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +10 -0
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +3 -0
- package/build/store/selectors.cjs.map +2 -2
- package/build/store/utils/notice-builder.cjs +4 -0
- package/build/store/utils/notice-builder.cjs.map +2 -2
- package/build-module/components/document-bar/useEditedSectionDetails.mjs +0 -3
- package/build-module/components/document-bar/useEditedSectionDetails.mjs.map +2 -2
- package/build-module/components/editor-interface/index.mjs +33 -9
- package/build-module/components/editor-interface/index.mjs.map +2 -2
- package/build-module/components/header/header-skeleton.mjs +69 -0
- package/build-module/components/header/header-skeleton.mjs.map +7 -0
- package/build-module/components/header/index.mjs +65 -107
- package/build-module/components/header/index.mjs.map +2 -2
- package/build-module/components/media/index.mjs +8 -0
- package/build-module/components/media/index.mjs.map +7 -0
- package/build-module/components/media/metadata-panel.mjs +65 -0
- package/build-module/components/media/metadata-panel.mjs.map +7 -0
- package/build-module/components/media/preview.mjs +21 -0
- package/build-module/components/media/preview.mjs.map +7 -0
- package/build-module/components/more-menu/index.mjs +3 -2
- package/build-module/components/more-menu/index.mjs.map +2 -2
- package/build-module/components/post-card-panel/index.mjs +35 -5
- package/build-module/components/post-card-panel/index.mjs.map +3 -3
- package/build-module/components/post-content-information/index.mjs +9 -0
- package/build-module/components/post-content-information/index.mjs.map +2 -2
- package/build-module/components/post-last-edited-panel/index.mjs +5 -6
- package/build-module/components/post-last-edited-panel/index.mjs.map +2 -2
- package/build-module/components/post-last-revision/index.mjs +6 -8
- package/build-module/components/post-last-revision/index.mjs.map +2 -2
- package/build-module/components/post-publish-button/label.mjs +6 -1
- package/build-module/components/post-publish-button/label.mjs.map +2 -2
- package/build-module/components/post-publish-button/post-publish-button-or-toggle.mjs +8 -3
- package/build-module/components/post-publish-button/post-publish-button-or-toggle.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/index.mjs +8 -0
- package/build-module/components/post-revisions-preview/index.mjs.map +7 -0
- package/build-module/components/post-revisions-preview/revisions-canvas.mjs +54 -0
- package/build-module/components/post-revisions-preview/revisions-canvas.mjs.map +7 -0
- package/build-module/components/post-revisions-preview/revisions-header.mjs +92 -0
- package/build-module/components/post-revisions-preview/revisions-header.mjs.map +7 -0
- package/build-module/components/post-revisions-preview/revisions-slider.mjs +89 -0
- package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +7 -0
- package/build-module/components/post-saved-state/index.mjs +8 -2
- package/build-module/components/post-saved-state/index.mjs.map +2 -2
- package/build-module/components/post-title/index.mjs +5 -4
- package/build-module/components/post-title/index.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +19 -0
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/use-block-editor-settings.mjs +2 -1
- package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
- package/build-module/components/revision-author-panel/index.mjs +28 -0
- package/build-module/components/revision-author-panel/index.mjs.map +7 -0
- package/build-module/components/revision-created-panel/index.mjs +26 -0
- package/build-module/components/revision-created-panel/index.mjs.map +7 -0
- package/build-module/components/sidebar/header.mjs +22 -7
- package/build-module/components/sidebar/header.mjs.map +2 -2
- package/build-module/components/sidebar/index.mjs +38 -16
- package/build-module/components/sidebar/index.mjs.map +2 -2
- package/build-module/components/sidebar/post-summary.mjs +48 -20
- package/build-module/components/sidebar/post-summary.mjs.map +2 -2
- package/build-module/components/start-page-options/index.mjs +2 -1
- package/build-module/components/start-page-options/index.mjs.map +2 -2
- package/build-module/dataviews/store/private-actions.mjs +59 -27
- package/build-module/dataviews/store/private-actions.mjs.map +2 -2
- package/build-module/store/constants.mjs +2 -0
- package/build-module/store/constants.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +38 -0
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +29 -1
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +9 -0
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +4 -0
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/store/utils/notice-builder.mjs +4 -0
- package/build-module/store/utils/notice-builder.mjs.map +2 -2
- package/build-style/style-rtl.css +182 -16
- package/build-style/style.css +182 -16
- package/build-types/components/document-bar/useEditedSectionDetails.d.ts.map +1 -1
- package/build-types/components/editor-interface/index.d.ts.map +1 -1
- package/build-types/components/header/header-skeleton.d.ts +17 -0
- package/build-types/components/header/header-skeleton.d.ts.map +1 -0
- package/build-types/components/header/index.d.ts.map +1 -1
- package/build-types/components/media/index.d.ts +3 -0
- package/build-types/components/media/index.d.ts.map +1 -0
- package/build-types/components/media/metadata-panel.d.ts +12 -0
- package/build-types/components/media/metadata-panel.d.ts.map +1 -0
- package/build-types/components/media/preview.d.ts +9 -0
- package/build-types/components/media/preview.d.ts.map +1 -0
- package/build-types/components/more-menu/index.d.ts +3 -1
- package/build-types/components/more-menu/index.d.ts.map +1 -1
- package/build-types/components/post-card-panel/index.d.ts.map +1 -1
- package/build-types/components/post-content-information/index.d.ts.map +1 -1
- package/build-types/components/post-last-edited-panel/index.d.ts.map +1 -1
- package/build-types/components/post-last-revision/index.d.ts.map +1 -1
- package/build-types/components/post-publish-button/label.d.ts.map +1 -1
- package/build-types/components/post-publish-button/post-publish-button-or-toggle.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/index.d.ts +3 -0
- package/build-types/components/post-revisions-preview/index.d.ts.map +1 -0
- package/build-types/components/post-revisions-preview/revisions-canvas.d.ts +7 -0
- package/build-types/components/post-revisions-preview/revisions-canvas.d.ts.map +1 -0
- package/build-types/components/post-revisions-preview/revisions-header.d.ts +8 -0
- package/build-types/components/post-revisions-preview/revisions-header.d.ts.map +1 -0
- package/build-types/components/post-revisions-preview/revisions-slider.d.ts +8 -0
- package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -0
- package/build-types/components/post-saved-state/index.d.ts.map +1 -1
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
- package/build-types/components/revision-author-panel/index.d.ts +2 -0
- package/build-types/components/revision-author-panel/index.d.ts.map +1 -0
- package/build-types/components/revision-created-panel/index.d.ts +2 -0
- package/build-types/components/revision-created-panel/index.d.ts.map +1 -0
- package/build-types/components/sidebar/index.d.ts.map +1 -1
- package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
- package/build-types/components/start-page-options/index.d.ts.map +1 -1
- package/build-types/dataviews/store/private-actions.d.ts +1 -0
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/build-types/store/constants.d.ts +1 -0
- package/build-types/store/constants.d.ts.map +1 -1
- package/build-types/store/private-actions.d.ts +13 -0
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +25 -0
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +11 -0
- package/build-types/store/reducer.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts.map +1 -1
- package/build-types/store/utils/notice-builder.d.ts.map +1 -1
- package/package.json +42 -40
- package/src/components/document-bar/useEditedSectionDetails.js +0 -5
- package/src/components/editor-interface/index.js +39 -9
- package/src/components/header/header-skeleton.js +90 -0
- package/src/components/header/index.js +69 -102
- package/src/components/header/style.scss +4 -0
- package/src/components/media/index.js +2 -0
- package/src/components/media/metadata-panel.js +77 -0
- package/src/components/media/preview.js +35 -0
- package/src/components/more-menu/index.js +2 -1
- package/src/components/post-card-panel/index.js +43 -7
- package/src/components/post-content-information/index.js +11 -0
- package/src/components/post-last-edited-panel/index.js +8 -9
- package/src/components/post-last-revision/index.js +7 -8
- package/src/components/post-publish-button/label.js +9 -0
- package/src/components/post-publish-button/post-publish-button-or-toggle.js +13 -5
- package/src/components/post-revisions-preview/index.js +2 -0
- package/src/components/post-revisions-preview/revisions-canvas.js +73 -0
- package/src/components/post-revisions-preview/revisions-header.js +108 -0
- package/src/components/post-revisions-preview/revisions-slider.js +123 -0
- package/src/components/post-revisions-preview/style.scss +22 -0
- package/src/components/post-saved-state/index.js +8 -0
- package/src/components/post-title/index.js +4 -3
- package/src/components/provider/index.js +26 -0
- package/src/components/provider/use-block-editor-settings.js +2 -3
- package/src/components/revision-author-panel/index.js +36 -0
- package/src/components/revision-created-panel/index.js +36 -0
- package/src/components/sidebar/header.js +35 -14
- package/src/components/sidebar/index.js +40 -13
- package/src/components/sidebar/post-summary.js +45 -11
- package/src/components/sidebar/style.scss +7 -0
- package/src/components/start-page-options/index.js +2 -0
- package/src/dataviews/store/private-actions.ts +79 -33
- package/src/store/constants.ts +1 -0
- package/src/store/private-actions.js +70 -0
- package/src/store/private-selectors.js +54 -0
- package/src/store/reducer.js +17 -0
- package/src/store/selectors.js +6 -0
- package/src/store/test/selectors.js +7 -0
- package/src/store/utils/notice-builder.js +9 -0
- package/src/style.scss +2 -0
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
5
5
|
import { useSelect } from '@wordpress/data';
|
|
6
6
|
import { useMediaQuery, useViewportMatch } from '@wordpress/compose';
|
|
7
|
-
import { __unstableMotion as motion } from '@wordpress/components';
|
|
8
7
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
9
8
|
import { useState } from '@wordpress/element';
|
|
10
9
|
import { PinnedItems } from '@wordpress/interface';
|
|
@@ -12,10 +11,10 @@ import { PinnedItems } from '@wordpress/interface';
|
|
|
12
11
|
/**
|
|
13
12
|
* Internal dependencies
|
|
14
13
|
*/
|
|
15
|
-
import BackButton, { useHasBackButton } from './back-button';
|
|
16
14
|
import CollapsibleBlockToolbar from '../collapsible-block-toolbar';
|
|
17
15
|
import DocumentBar from '../document-bar';
|
|
18
16
|
import DocumentTools from '../document-tools';
|
|
17
|
+
import HeaderSkeleton from './header-skeleton';
|
|
19
18
|
import MoreMenu from '../more-menu';
|
|
20
19
|
import PostPreviewButton from '../post-preview-button';
|
|
21
20
|
import PostPublishButtonOrToggle from '../post-publish-button/post-publish-button-or-toggle';
|
|
@@ -25,28 +24,13 @@ import PreviewDropdown from '../preview-dropdown';
|
|
|
25
24
|
import ZoomOutToggle from '../zoom-out-toggle';
|
|
26
25
|
import { store as editorStore } from '../../store';
|
|
27
26
|
import {
|
|
27
|
+
ATTACHMENT_POST_TYPE,
|
|
28
28
|
TEMPLATE_PART_POST_TYPE,
|
|
29
29
|
PATTERN_POST_TYPE,
|
|
30
30
|
NAVIGATION_POST_TYPE,
|
|
31
31
|
} from '../../store/constants';
|
|
32
32
|
import { unlock } from '../../lock-unlock';
|
|
33
33
|
|
|
34
|
-
const toolbarVariations = {
|
|
35
|
-
distractionFreeDisabled: { y: '-50px' },
|
|
36
|
-
distractionFreeHover: { y: 0 },
|
|
37
|
-
distractionFreeHidden: { y: '-50px' },
|
|
38
|
-
visible: { y: 0 },
|
|
39
|
-
hidden: { y: 0 },
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const backButtonVariations = {
|
|
43
|
-
distractionFreeDisabled: { x: '-100%' },
|
|
44
|
-
distractionFreeHover: { x: 0 },
|
|
45
|
-
distractionFreeHidden: { x: '-100%' },
|
|
46
|
-
visible: { x: 0 },
|
|
47
|
-
hidden: { x: 0 },
|
|
48
|
-
};
|
|
49
|
-
|
|
50
34
|
function Header( {
|
|
51
35
|
customSaveButton,
|
|
52
36
|
forceIsDirty,
|
|
@@ -64,6 +48,7 @@ function Header( {
|
|
|
64
48
|
hasBlockSelection,
|
|
65
49
|
hasSectionRootClientId,
|
|
66
50
|
isStylesCanvasActive,
|
|
51
|
+
isAttachment,
|
|
67
52
|
} = useSelect( ( select ) => {
|
|
68
53
|
const { get: getPreference } = select( preferencesStore );
|
|
69
54
|
const {
|
|
@@ -89,6 +74,9 @@ function Header( {
|
|
|
89
74
|
isStylesCanvasActive:
|
|
90
75
|
!! getStylesPath()?.startsWith( '/revisions' ) ||
|
|
91
76
|
getShowStylebook(),
|
|
77
|
+
isAttachment:
|
|
78
|
+
getCurrentPostType() === ATTACHMENT_POST_TYPE &&
|
|
79
|
+
window?.__experimentalMediaEditor,
|
|
92
80
|
};
|
|
93
81
|
}, [] );
|
|
94
82
|
|
|
@@ -98,6 +86,7 @@ function Header( {
|
|
|
98
86
|
|
|
99
87
|
const disablePreviewOption =
|
|
100
88
|
[
|
|
89
|
+
ATTACHMENT_POST_TYPE,
|
|
101
90
|
NAVIGATION_POST_TYPE,
|
|
102
91
|
TEMPLATE_PART_POST_TYPE,
|
|
103
92
|
PATTERN_POST_TYPE,
|
|
@@ -111,95 +100,73 @@ function Header( {
|
|
|
111
100
|
( ! hasFixedToolbar ||
|
|
112
101
|
( hasFixedToolbar &&
|
|
113
102
|
( ! hasBlockSelection || isBlockToolsCollapsed ) ) );
|
|
114
|
-
const hasBackButton = useHasBackButton();
|
|
115
103
|
|
|
116
|
-
/*
|
|
117
|
-
* The edit-post-header classname is only kept for backward compatibility
|
|
118
|
-
* as some plugins might be relying on its presence.
|
|
119
|
-
*/
|
|
120
104
|
return (
|
|
121
|
-
<
|
|
122
|
-
{
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
105
|
+
<HeaderSkeleton
|
|
106
|
+
toolbar={
|
|
107
|
+
<>
|
|
108
|
+
{ ! isAttachment && (
|
|
109
|
+
<DocumentTools
|
|
110
|
+
disableBlockTools={
|
|
111
|
+
isStylesCanvasActive || isTextEditor
|
|
112
|
+
}
|
|
113
|
+
/>
|
|
114
|
+
) }
|
|
115
|
+
{ hasFixedToolbar && isLargeViewport && (
|
|
116
|
+
<CollapsibleBlockToolbar
|
|
117
|
+
isCollapsed={ isBlockToolsCollapsed }
|
|
118
|
+
onToggle={ setIsBlockToolsCollapsed }
|
|
119
|
+
/>
|
|
120
|
+
) }
|
|
121
|
+
</>
|
|
122
|
+
}
|
|
123
|
+
center={ hasCenter ? <DocumentBar /> : undefined }
|
|
124
|
+
settings={
|
|
125
|
+
<>
|
|
126
|
+
{ ! customSaveButton && ! isPublishSidebarOpened && (
|
|
127
|
+
/*
|
|
128
|
+
* This button isn't completely hidden by the publish sidebar.
|
|
129
|
+
* We can't hide the whole toolbar when the publish sidebar is open because
|
|
130
|
+
* we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.
|
|
131
|
+
* We track that DOM node to return focus to the PostPublishButtonOrToggle
|
|
132
|
+
* when the publish sidebar has been closed.
|
|
133
|
+
*/
|
|
134
|
+
<PostSavedState forceIsDirty={ forceIsDirty } />
|
|
135
|
+
) }
|
|
136
|
+
|
|
137
|
+
<PostViewLink />
|
|
138
|
+
|
|
139
|
+
<PreviewDropdown
|
|
140
|
+
forceIsAutosaveable={ forceIsDirty }
|
|
141
|
+
disabled={ disablePreviewOption }
|
|
143
142
|
/>
|
|
144
|
-
) }
|
|
145
|
-
</motion.div>
|
|
146
|
-
{ hasCenter && (
|
|
147
|
-
<motion.div
|
|
148
|
-
className="editor-header__center"
|
|
149
|
-
variants={ toolbarVariations }
|
|
150
|
-
transition={ { type: 'tween' } }
|
|
151
|
-
>
|
|
152
|
-
<DocumentBar />
|
|
153
|
-
</motion.div>
|
|
154
|
-
) }
|
|
155
|
-
<motion.div
|
|
156
|
-
variants={ toolbarVariations }
|
|
157
|
-
transition={ { type: 'tween' } }
|
|
158
|
-
className="editor-header__settings"
|
|
159
|
-
>
|
|
160
|
-
{ ! customSaveButton && ! isPublishSidebarOpened && (
|
|
161
|
-
/*
|
|
162
|
-
* This button isn't completely hidden by the publish sidebar.
|
|
163
|
-
* We can't hide the whole toolbar when the publish sidebar is open because
|
|
164
|
-
* we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.
|
|
165
|
-
* We track that DOM node to return focus to the PostPublishButtonOrToggle
|
|
166
|
-
* when the publish sidebar has been closed.
|
|
167
|
-
*/
|
|
168
|
-
<PostSavedState forceIsDirty={ forceIsDirty } />
|
|
169
|
-
) }
|
|
170
|
-
|
|
171
|
-
<PostViewLink />
|
|
172
|
-
|
|
173
|
-
<PreviewDropdown
|
|
174
|
-
forceIsAutosaveable={ forceIsDirty }
|
|
175
|
-
disabled={ disablePreviewOption }
|
|
176
|
-
/>
|
|
177
143
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
/>
|
|
182
|
-
|
|
183
|
-
{ isWideViewport && canBeZoomedOut && (
|
|
184
|
-
<ZoomOutToggle disabled={ isStylesCanvasActive } />
|
|
185
|
-
) }
|
|
186
|
-
|
|
187
|
-
{ ( isWideViewport || ! showIconLabels ) && (
|
|
188
|
-
<PinnedItems.Slot scope="core" />
|
|
189
|
-
) }
|
|
190
|
-
|
|
191
|
-
{ ! customSaveButton && (
|
|
192
|
-
<PostPublishButtonOrToggle
|
|
193
|
-
forceIsDirty={ forceIsDirty }
|
|
194
|
-
setEntitiesSavedStatesCallback={
|
|
195
|
-
setEntitiesSavedStatesCallback
|
|
196
|
-
}
|
|
144
|
+
<PostPreviewButton
|
|
145
|
+
className="editor-header__post-preview-button"
|
|
146
|
+
forceIsAutosaveable={ forceIsDirty }
|
|
197
147
|
/>
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
148
|
+
|
|
149
|
+
{ isWideViewport && canBeZoomedOut && (
|
|
150
|
+
<ZoomOutToggle disabled={ isStylesCanvasActive } />
|
|
151
|
+
) }
|
|
152
|
+
|
|
153
|
+
{ ( isWideViewport || ! showIconLabels ) && (
|
|
154
|
+
<PinnedItems.Slot scope="core" />
|
|
155
|
+
) }
|
|
156
|
+
|
|
157
|
+
{ ! customSaveButton && (
|
|
158
|
+
<PostPublishButtonOrToggle
|
|
159
|
+
forceIsDirty={ forceIsDirty }
|
|
160
|
+
setEntitiesSavedStatesCallback={
|
|
161
|
+
setEntitiesSavedStatesCallback
|
|
162
|
+
}
|
|
163
|
+
/>
|
|
164
|
+
) }
|
|
165
|
+
{ customSaveButton }
|
|
166
|
+
{ ! isAttachment && <MoreMenu /> }
|
|
167
|
+
</>
|
|
168
|
+
}
|
|
169
|
+
/>
|
|
203
170
|
);
|
|
204
171
|
}
|
|
205
172
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { MediaEditorProvider, MediaForm } from '@wordpress/media-editor';
|
|
5
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
|
+
import { useMemo } from '@wordpress/element';
|
|
7
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { store as editorStore } from '../../store';
|
|
13
|
+
import usePostFields from '../post-fields';
|
|
14
|
+
import PostCardPanel from '../post-card-panel';
|
|
15
|
+
import PostPanelSection from '../post-panel-section';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Media metadata panel for the editor sidebar.
|
|
19
|
+
* Displays a form for editing media properties with PostCardPanel header.
|
|
20
|
+
*
|
|
21
|
+
* @param {Object} props - Component props.
|
|
22
|
+
* @param {Function} props.onActionPerformed - Callback when an action is performed.
|
|
23
|
+
* @return {Element} The MediaMetadataPanel component.
|
|
24
|
+
*/
|
|
25
|
+
export default function MediaMetadataPanel( { onActionPerformed } ) {
|
|
26
|
+
const { media, postType, postId } = useSelect( ( select ) => {
|
|
27
|
+
const _postType = select( editorStore ).getCurrentPostType();
|
|
28
|
+
const _postId = select( editorStore ).getCurrentPostId();
|
|
29
|
+
const currentPost = select( coreStore ).getEditedEntityRecord(
|
|
30
|
+
'postType',
|
|
31
|
+
_postType,
|
|
32
|
+
_postId,
|
|
33
|
+
{
|
|
34
|
+
_embed: 'author,wp:attached-to',
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
return {
|
|
38
|
+
media: currentPost,
|
|
39
|
+
postType: _postType,
|
|
40
|
+
postId: _postId,
|
|
41
|
+
};
|
|
42
|
+
}, [] );
|
|
43
|
+
|
|
44
|
+
const { editPost } = useDispatch( editorStore );
|
|
45
|
+
const fields = usePostFields( { postType: 'attachment' } );
|
|
46
|
+
|
|
47
|
+
const settings = useMemo(
|
|
48
|
+
() => ( {
|
|
49
|
+
fields,
|
|
50
|
+
} ),
|
|
51
|
+
[ fields ]
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const handleUpdate = ( updates ) => {
|
|
55
|
+
editPost( updates );
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<PostPanelSection className="editor-media-metadata-panel">
|
|
60
|
+
<MediaEditorProvider
|
|
61
|
+
value={ media }
|
|
62
|
+
settings={ settings }
|
|
63
|
+
onChange={ handleUpdate }
|
|
64
|
+
>
|
|
65
|
+
<MediaForm
|
|
66
|
+
header={
|
|
67
|
+
<PostCardPanel
|
|
68
|
+
postType={ postType }
|
|
69
|
+
postId={ postId }
|
|
70
|
+
onActionPerformed={ onActionPerformed }
|
|
71
|
+
/>
|
|
72
|
+
}
|
|
73
|
+
/>
|
|
74
|
+
</MediaEditorProvider>
|
|
75
|
+
</PostPanelSection>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
MediaEditorProvider,
|
|
6
|
+
MediaPreview as BaseMediaPreview,
|
|
7
|
+
} from '@wordpress/media-editor';
|
|
8
|
+
import { useSelect } from '@wordpress/data';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import { store as editorStore } from '../../store';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Media preview component for the editor.
|
|
17
|
+
* Connects the base MediaPreview component to the editor store.
|
|
18
|
+
*
|
|
19
|
+
* @param {Object} props - Additional props to spread on MediaPreview.
|
|
20
|
+
* @return {Element} The MediaPreview component.
|
|
21
|
+
*/
|
|
22
|
+
export default function MediaPreview( props ) {
|
|
23
|
+
const { media } = useSelect( ( select ) => {
|
|
24
|
+
const currentPost = select( editorStore ).getCurrentPost();
|
|
25
|
+
return {
|
|
26
|
+
media: currentPost,
|
|
27
|
+
};
|
|
28
|
+
}, [] );
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<MediaEditorProvider value={ media }>
|
|
32
|
+
<BaseMediaPreview { ...props } />
|
|
33
|
+
</MediaEditorProvider>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -26,7 +26,7 @@ import ToolsMoreMenuGroup from './tools-more-menu-group';
|
|
|
26
26
|
import ViewMoreMenuGroup from './view-more-menu-group';
|
|
27
27
|
import { store as editorStore } from '../../store';
|
|
28
28
|
|
|
29
|
-
export default function MoreMenu() {
|
|
29
|
+
export default function MoreMenu( { disabled = false } ) {
|
|
30
30
|
const { openModal } = useDispatch( interfaceStore );
|
|
31
31
|
const { set: setPreference } = useDispatch( preferencesStore );
|
|
32
32
|
const { toggleDistractionFree } = useDispatch( editorStore );
|
|
@@ -54,6 +54,7 @@ export default function MoreMenu() {
|
|
|
54
54
|
...( showIconLabels && { variant: 'tertiary' } ),
|
|
55
55
|
tooltipPosition: 'bottom',
|
|
56
56
|
size: 'compact',
|
|
57
|
+
disabled,
|
|
57
58
|
} }
|
|
58
59
|
>
|
|
59
60
|
{ ( { onClose } ) => (
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
5
|
Icon,
|
|
6
|
+
Button,
|
|
6
7
|
__experimentalHStack as HStack,
|
|
7
8
|
__experimentalVStack as VStack,
|
|
8
9
|
__experimentalText as Text,
|
|
9
10
|
privateApis as componentsPrivateApis,
|
|
10
11
|
} from '@wordpress/components';
|
|
12
|
+
import { moreVertical } from '@wordpress/icons';
|
|
11
13
|
import { store as coreStore } from '@wordpress/core-data';
|
|
12
14
|
import { useSelect } from '@wordpress/data';
|
|
13
15
|
import { useMemo } from '@wordpress/element';
|
|
@@ -46,12 +48,33 @@ export default function PostCardPanel( {
|
|
|
46
48
|
() => ( Array.isArray( postId ) ? postId : [ postId ] ),
|
|
47
49
|
[ postId ]
|
|
48
50
|
);
|
|
49
|
-
const { postTitle, icon, labels } = useSelect(
|
|
51
|
+
const { postTitle, icon, labels, isRevision } = useSelect(
|
|
50
52
|
( select ) => {
|
|
51
53
|
const { getEditedEntityRecord, getCurrentTheme, getPostType } =
|
|
52
54
|
select( coreStore );
|
|
53
|
-
const {
|
|
55
|
+
const {
|
|
56
|
+
getPostIcon,
|
|
57
|
+
getCurrentPostType,
|
|
58
|
+
isRevisionsMode,
|
|
59
|
+
getCurrentRevision,
|
|
60
|
+
} = unlock( select( editorStore ) );
|
|
54
61
|
let _title = '';
|
|
62
|
+
|
|
63
|
+
// In revisions mode, use the current revision.
|
|
64
|
+
if ( isRevisionsMode() ) {
|
|
65
|
+
const parentPostType = getCurrentPostType();
|
|
66
|
+
const _record = getCurrentRevision();
|
|
67
|
+
_title = _record?.title?.rendered || _record?.title?.raw || '';
|
|
68
|
+
return {
|
|
69
|
+
postTitle: _title,
|
|
70
|
+
icon: getPostIcon( parentPostType, {
|
|
71
|
+
area: _record?.area,
|
|
72
|
+
} ),
|
|
73
|
+
labels: getPostType( parentPostType )?.labels,
|
|
74
|
+
isRevision: true,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
55
78
|
const _record = getEditedEntityRecord(
|
|
56
79
|
'postType',
|
|
57
80
|
postType,
|
|
@@ -119,11 +142,24 @@ export default function PostCardPanel( {
|
|
|
119
142
|
) }
|
|
120
143
|
</Text>
|
|
121
144
|
{ postIds.length === 1 && (
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
145
|
+
<>
|
|
146
|
+
{ isRevision ? (
|
|
147
|
+
<Button
|
|
148
|
+
size="small"
|
|
149
|
+
icon={ moreVertical }
|
|
150
|
+
label={ __( 'Actions' ) }
|
|
151
|
+
disabled
|
|
152
|
+
accessibleWhenDisabled
|
|
153
|
+
className="editor-all-actions-button"
|
|
154
|
+
/>
|
|
155
|
+
) : (
|
|
156
|
+
<PostActions
|
|
157
|
+
postType={ postType }
|
|
158
|
+
postId={ postIds[ 0 ] }
|
|
159
|
+
onActionPerformed={ onActionPerformed }
|
|
160
|
+
/>
|
|
161
|
+
) }
|
|
162
|
+
</>
|
|
127
163
|
) }
|
|
128
164
|
</HStack>
|
|
129
165
|
{ postIds.length > 1 && (
|
|
@@ -12,6 +12,7 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
14
|
import { store as editorStore } from '../../store';
|
|
15
|
+
import { unlock } from '../../lock-unlock';
|
|
15
16
|
import {
|
|
16
17
|
TEMPLATE_POST_TYPE,
|
|
17
18
|
TEMPLATE_PART_POST_TYPE,
|
|
@@ -25,6 +26,16 @@ export default function PostContentInformation() {
|
|
|
25
26
|
const { postContent } = useSelect( ( select ) => {
|
|
26
27
|
const { getEditedPostAttribute, getCurrentPostType, getCurrentPostId } =
|
|
27
28
|
select( editorStore );
|
|
29
|
+
const { getCurrentRevision, isRevisionsMode } = unlock(
|
|
30
|
+
select( editorStore )
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
if ( isRevisionsMode() ) {
|
|
34
|
+
return {
|
|
35
|
+
postContent: getCurrentRevision()?.content?.raw,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
28
39
|
const { canUser } = select( coreStore );
|
|
29
40
|
const { getEntityRecord } = select( coreStore );
|
|
30
41
|
const siteSettings = canUser( 'read', {
|
|
@@ -17,19 +17,18 @@ export default function PostLastEditedPanel() {
|
|
|
17
17
|
select( editorStore ).getEditedPostAttribute( 'modified' ),
|
|
18
18
|
[]
|
|
19
19
|
);
|
|
20
|
-
|
|
21
|
-
modified &&
|
|
22
|
-
sprintf(
|
|
23
|
-
// translators: %s: Human-readable time difference, e.g. "2 days ago".
|
|
24
|
-
__( 'Last edited %s.' ),
|
|
25
|
-
humanTimeDiff( modified )
|
|
26
|
-
);
|
|
27
|
-
if ( ! lastEditedText ) {
|
|
20
|
+
if ( ! modified ) {
|
|
28
21
|
return null;
|
|
29
22
|
}
|
|
30
23
|
return (
|
|
31
24
|
<div className="editor-post-last-edited-panel">
|
|
32
|
-
<Text>
|
|
25
|
+
<Text>
|
|
26
|
+
{ sprintf(
|
|
27
|
+
// translators: %s: Human-readable time difference, e.g. "2 days ago".
|
|
28
|
+
__( 'Last edited %s.' ),
|
|
29
|
+
humanTimeDiff( modified )
|
|
30
|
+
) }
|
|
31
|
+
</Text>
|
|
33
32
|
</div>
|
|
34
33
|
);
|
|
35
34
|
}
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { sprintf, __ } from '@wordpress/i18n';
|
|
5
5
|
import { Button } from '@wordpress/components';
|
|
6
|
-
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
7
|
import { backup } from '@wordpress/icons';
|
|
8
|
-
import { addQueryArgs } from '@wordpress/url';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Internal dependencies
|
|
@@ -13,6 +12,7 @@ import { addQueryArgs } from '@wordpress/url';
|
|
|
13
12
|
import PostLastRevisionCheck from './check';
|
|
14
13
|
import PostPanelRow from '../post-panel-row';
|
|
15
14
|
import { store as editorStore } from '../../store';
|
|
15
|
+
import { unlock } from '../../lock-unlock';
|
|
16
16
|
|
|
17
17
|
function usePostLastRevisionInfo() {
|
|
18
18
|
return useSelect( ( select ) => {
|
|
@@ -32,14 +32,13 @@ function usePostLastRevisionInfo() {
|
|
|
32
32
|
*/
|
|
33
33
|
function PostLastRevision() {
|
|
34
34
|
const { lastRevisionId, revisionsCount } = usePostLastRevisionInfo();
|
|
35
|
+
const { setCurrentRevisionId } = unlock( useDispatch( editorStore ) );
|
|
35
36
|
|
|
36
37
|
return (
|
|
37
38
|
<PostLastRevisionCheck>
|
|
38
39
|
<Button
|
|
39
40
|
__next40pxDefaultSize
|
|
40
|
-
|
|
41
|
-
revision: lastRevisionId,
|
|
42
|
-
} ) }
|
|
41
|
+
onClick={ () => setCurrentRevisionId( lastRevisionId ) }
|
|
43
42
|
className="editor-post-last-revision__title"
|
|
44
43
|
icon={ backup }
|
|
45
44
|
iconPosition="right"
|
|
@@ -55,13 +54,13 @@ function PostLastRevision() {
|
|
|
55
54
|
|
|
56
55
|
export function PrivatePostLastRevision() {
|
|
57
56
|
const { lastRevisionId, revisionsCount } = usePostLastRevisionInfo();
|
|
57
|
+
const { setCurrentRevisionId } = unlock( useDispatch( editorStore ) );
|
|
58
|
+
|
|
58
59
|
return (
|
|
59
60
|
<PostLastRevisionCheck>
|
|
60
61
|
<PostPanelRow label={ __( 'Revisions' ) }>
|
|
61
62
|
<Button
|
|
62
|
-
|
|
63
|
-
revision: lastRevisionId,
|
|
64
|
-
} ) }
|
|
63
|
+
onClick={ () => setCurrentRevisionId( lastRevisionId ) }
|
|
65
64
|
className="editor-private-post-last-revision__button"
|
|
66
65
|
text={ revisionsCount }
|
|
67
66
|
variant="tertiary"
|
|
@@ -9,6 +9,7 @@ import { useViewportMatch } from '@wordpress/compose';
|
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
11
|
import { store as editorStore } from '../../store';
|
|
12
|
+
import { ATTACHMENT_POST_TYPE } from '../../store/constants';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Renders the label for the publish button.
|
|
@@ -27,6 +28,7 @@ export default function PublishButtonLabel() {
|
|
|
27
28
|
hasNonPostEntityChanges,
|
|
28
29
|
postStatusHasChanged,
|
|
29
30
|
postStatus,
|
|
31
|
+
postType,
|
|
30
32
|
} = useSelect( ( select ) => {
|
|
31
33
|
const {
|
|
32
34
|
isCurrentPostPublished,
|
|
@@ -66,6 +68,13 @@ export default function PublishButtonLabel() {
|
|
|
66
68
|
return __( 'Saving…' );
|
|
67
69
|
}
|
|
68
70
|
if ( ! hasPublishAction ) {
|
|
71
|
+
// For attachments, always show "Save" since they don't have a publish workflow
|
|
72
|
+
if (
|
|
73
|
+
postType === ATTACHMENT_POST_TYPE &&
|
|
74
|
+
window?.__experimentalMediaEditor
|
|
75
|
+
) {
|
|
76
|
+
return __( 'Save' );
|
|
77
|
+
}
|
|
69
78
|
// TODO: this is because "Submit for review" string is too long in some languages.
|
|
70
79
|
// @see https://github.com/WordPress/gutenberg/issues/10475
|
|
71
80
|
return isSmallerThanMediumViewport
|
|
@@ -9,6 +9,7 @@ import { useDispatch, useSelect } from '@wordpress/data';
|
|
|
9
9
|
*/
|
|
10
10
|
import PostPublishButton from './index';
|
|
11
11
|
import { store as editorStore } from '../../store';
|
|
12
|
+
import { ATTACHMENT_POST_TYPE } from '../../store/constants';
|
|
12
13
|
|
|
13
14
|
const IS_TOGGLE = 'toggle';
|
|
14
15
|
const IS_BUTTON = 'button';
|
|
@@ -30,6 +31,7 @@ export default function PostPublishButtonOrToggle( {
|
|
|
30
31
|
isScheduled,
|
|
31
32
|
postStatus,
|
|
32
33
|
postStatusHasChanged,
|
|
34
|
+
postType,
|
|
33
35
|
} = useSelect( ( select ) => {
|
|
34
36
|
return {
|
|
35
37
|
hasPublishAction:
|
|
@@ -48,14 +50,18 @@ export default function PostPublishButtonOrToggle( {
|
|
|
48
50
|
postStatus:
|
|
49
51
|
select( editorStore ).getEditedPostAttribute( 'status' ),
|
|
50
52
|
postStatusHasChanged: select( editorStore ).getPostEdits()?.status,
|
|
53
|
+
postType: select( editorStore ).getCurrentPostType(),
|
|
51
54
|
};
|
|
52
55
|
}, [] );
|
|
53
56
|
|
|
54
57
|
/**
|
|
55
58
|
* Conditions to show a BUTTON (publish directly) or a TOGGLE (open publish sidebar):
|
|
56
59
|
*
|
|
57
|
-
* 1)
|
|
58
|
-
*
|
|
60
|
+
* 1) Attachments always show a BUTTON since they don't have a publish workflow
|
|
61
|
+
* and should save directly without pre-publish checks.
|
|
62
|
+
*
|
|
63
|
+
* 2) We want to show a BUTTON when the post status is at the _final stage_
|
|
64
|
+
* for a particular role (see https://wordpress.org/documentation/article/post-status/):
|
|
59
65
|
*
|
|
60
66
|
* - is published
|
|
61
67
|
* - post status has changed explicitly to something different than 'future' or 'publish'
|
|
@@ -67,14 +73,16 @@ export default function PostPublishButtonOrToggle( {
|
|
|
67
73
|
* we decided to take into account the viewport in that case.
|
|
68
74
|
* See: https://github.com/WordPress/gutenberg/issues/10475
|
|
69
75
|
*
|
|
70
|
-
*
|
|
76
|
+
* 3) Then, in small viewports, we'll show a TOGGLE.
|
|
71
77
|
*
|
|
72
|
-
*
|
|
78
|
+
* 4) Finally, we'll use the publish sidebar status to decide:
|
|
73
79
|
*
|
|
74
80
|
* - if it is enabled, we show a TOGGLE
|
|
75
81
|
* - if it is disabled, we show a BUTTON
|
|
76
82
|
*/
|
|
77
|
-
if (
|
|
83
|
+
if ( postType === ATTACHMENT_POST_TYPE ) {
|
|
84
|
+
component = IS_BUTTON;
|
|
85
|
+
} else if (
|
|
78
86
|
isPublished ||
|
|
79
87
|
( postStatusHasChanged &&
|
|
80
88
|
! [ 'future', 'publish' ].includes( postStatus ) ) ||
|