@wordpress/edit-site 5.10.0 → 5.11.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/add-new-template/{add-custom-generic-template-modal.js → add-custom-generic-template-modal-content.js} +7 -22
- package/build/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -0
- package/build/components/add-new-template/{add-custom-template-modal.js → add-custom-template-modal-content.js} +11 -21
- package/build/components/add-new-template/add-custom-template-modal-content.js.map +1 -0
- package/build/components/add-new-template/new-template.js +98 -65
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/block-editor/index.js +1 -3
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/create-template-part-modal/index.js +6 -7
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/editor/index.js +15 -40
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor-canvas-container/index.js +10 -3
- package/build/components/editor-canvas-container/index.js.map +1 -1
- package/build/components/global-styles/screen-block.js +80 -3
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-revisions/index.js +3 -10
- package/build/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js +16 -18
- package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js +15 -24
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build/components/global-styles/screen-root.js +4 -4
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/style-variations-container.js +6 -10
- package/build/components/global-styles/style-variations-container.js.map +1 -1
- package/build/components/global-styles/ui.js +9 -9
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/header-edit-mode/document-actions/index.js +28 -103
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/header-edit-mode/index.js +14 -1
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/layout/hooks.js +54 -0
- package/build/components/layout/hooks.js.map +1 -0
- package/build/components/layout/index.js +45 -98
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/actions/index.js +5 -2
- package/build/components/list/actions/index.js.map +1 -1
- package/build/components/resizable-frame/index.js +242 -0
- package/build/components/resizable-frame/index.js.map +1 -0
- package/build/components/revisions/index.js +2 -1
- package/build/components/revisions/index.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +4 -3
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/index.js +4 -4
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-revisions/index.js +1 -1
- package/build/components/sidebar-edit-mode/template-revisions/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +75 -11
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +24 -33
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/index.js +162 -0
- package/build/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/constants.js +17 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/constants.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +53 -103
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +87 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +14 -71
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/navigator-button.js +53 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/navigator-button.js.map +1 -0
- package/build/components/sidebar-navigation-screen-templates/index.js +36 -11
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/site-hub/index.js +1 -3
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/style-book/index.js +93 -19
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/use-edited-entity-record/index.js +8 -4
- package/build/components/use-edited-entity-record/index.js.map +1 -1
- package/build/hooks/commands/use-edit-mode-commands.js +105 -0
- package/build/hooks/commands/use-edit-mode-commands.js.map +1 -0
- package/build/store/actions.js +5 -3
- package/build/store/actions.js.map +1 -1
- package/build-module/components/add-new-template/{add-custom-generic-template-modal.js → add-custom-generic-template-modal-content.js} +8 -20
- package/build-module/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -0
- package/build-module/components/add-new-template/{add-custom-template-modal.js → add-custom-template-modal-content.js} +13 -22
- package/build-module/components/add-new-template/add-custom-template-modal-content.js.map +1 -0
- package/build-module/components/add-new-template/new-template.js +98 -67
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/block-editor/index.js +1 -3
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/create-template-part-modal/index.js +7 -8
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/editor/index.js +16 -43
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor-canvas-container/index.js +7 -3
- package/build-module/components/editor-canvas-container/index.js.map +1 -1
- package/build-module/components/global-styles/screen-block.js +82 -4
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/index.js +3 -10
- package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +16 -19
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js +15 -24
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +4 -4
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/style-variations-container.js +7 -11
- package/build-module/components/global-styles/style-variations-container.js.map +1 -1
- package/build-module/components/global-styles/ui.js +10 -10
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/header-edit-mode/document-actions/index.js +31 -107
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +14 -2
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/layout/hooks.js +41 -0
- package/build-module/components/layout/hooks.js.map +1 -0
- package/build-module/components/layout/index.js +46 -101
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/actions/index.js +6 -3
- package/build-module/components/list/actions/index.js.map +1 -1
- package/build-module/components/resizable-frame/index.js +228 -0
- package/build-module/components/resizable-frame/index.js.map +1 -0
- package/build-module/components/revisions/index.js +2 -1
- package/build-module/components/revisions/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +3 -3
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/index.js +3 -3
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-revisions/index.js +1 -1
- package/build-module/components/sidebar-edit-mode/template-revisions/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +70 -14
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +21 -32
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js +141 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js +10 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +52 -103
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +71 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +12 -71
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigator-button.js +40 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigator-button.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-templates/index.js +35 -11
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +1 -3
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/style-book/index.js +93 -20
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/use-edited-entity-record/index.js +8 -4
- package/build-module/components/use-edited-entity-record/index.js.map +1 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +86 -0
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -0
- package/build-module/store/actions.js +5 -3
- package/build-module/store/actions.js.map +1 -1
- package/build-style/style-rtl.css +233 -210
- package/build-style/style.css +234 -210
- package/package.json +37 -37
- package/src/components/add-new-template/add-custom-generic-template-modal-content.js +82 -0
- package/src/components/add-new-template/{add-custom-template-modal.js → add-custom-template-modal-content.js} +13 -26
- package/src/components/add-new-template/new-template.js +139 -153
- package/src/components/add-new-template/style.scss +79 -66
- package/src/components/block-editor/index.js +2 -3
- package/src/components/create-template-part-modal/index.js +19 -25
- package/src/components/editor/index.js +16 -45
- package/src/components/editor/style.scss +21 -6
- package/src/components/editor-canvas-container/index.js +28 -19
- package/src/components/global-styles/screen-block.js +74 -3
- package/src/components/global-styles/screen-revisions/index.js +3 -11
- package/src/components/global-styles/screen-revisions/revisions-buttons.js +33 -25
- package/src/components/global-styles/screen-revisions/style.scss +3 -2
- package/src/components/global-styles/screen-revisions/test/use-global-styles-revisions.js +16 -3
- package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +15 -19
- package/src/components/global-styles/screen-root.js +5 -3
- package/src/components/global-styles/style-variations-container.js +13 -18
- package/src/components/global-styles/style.scss +3 -0
- package/src/components/global-styles/ui.js +11 -9
- package/src/components/header-edit-mode/document-actions/index.js +26 -129
- package/src/components/header-edit-mode/document-actions/style.scss +28 -59
- package/src/components/header-edit-mode/index.js +18 -0
- package/src/components/header-edit-mode/style.scss +1 -0
- package/src/components/layout/hooks.js +46 -0
- package/src/components/layout/index.js +56 -125
- package/src/components/layout/style.scss +8 -2
- package/src/components/list/actions/index.js +12 -5
- package/src/components/list/style.scss +1 -0
- package/src/components/resizable-frame/index.js +253 -0
- package/src/components/resizable-frame/style.scss +69 -0
- package/src/components/revisions/index.js +1 -0
- package/src/components/secondary-sidebar/list-view-sidebar.js +2 -1
- package/src/components/sidebar/index.js +4 -4
- package/src/components/sidebar-edit-mode/template-revisions/index.js +1 -2
- package/src/components/sidebar-navigation-item/style.scss +9 -0
- package/src/components/sidebar-navigation-screen/style.scss +1 -2
- package/src/components/sidebar-navigation-screen-global-styles/index.js +106 -21
- package/src/components/sidebar-navigation-screen-main/index.js +35 -52
- package/src/components/sidebar-navigation-screen-navigation-menu/index.js +157 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/constants.js +9 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +63 -117
- package/src/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +83 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +6 -72
- package/src/components/sidebar-navigation-screen-navigation-menus/navigator-button.js +47 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +6 -20
- package/src/components/sidebar-navigation-screen-templates/index.js +53 -14
- package/src/components/site-hub/index.js +8 -9
- package/src/components/start-template-options/style.scss +20 -21
- package/src/components/style-book/index.js +132 -43
- package/src/components/style-book/style.scss +19 -0
- package/src/components/use-edited-entity-record/index.js +12 -3
- package/src/hooks/commands/use-edit-mode-commands.js +79 -0
- package/src/store/actions.js +4 -5
- package/src/store/test/utils.js +15 -5
- package/src/style.scss +1 -1
- package/build/components/add-new-template/add-custom-generic-template-modal.js.map +0 -1
- package/build/components/add-new-template/add-custom-template-modal.js.map +0 -1
- package/build/components/global-styles/border-panel.js +0 -135
- package/build/components/global-styles/border-panel.js.map +0 -1
- package/build/components/navigate-to-link/index.js +0 -51
- package/build/components/navigate-to-link/index.js.map +0 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/loader.js +0 -19
- package/build/components/sidebar-navigation-screen-navigation-menus/loader.js.map +0 -1
- package/build/components/template-details/edit-template-title.js +0 -42
- package/build/components/template-details/edit-template-title.js.map +0 -1
- package/build/components/template-details/index.js +0 -103
- package/build/components/template-details/index.js.map +0 -1
- package/build/components/template-details/template-areas.js +0 -166
- package/build/components/template-details/template-areas.js.map +0 -1
- package/build/components/template-details/template-part-area-selector.js +0 -48
- package/build/components/template-details/template-part-area-selector.js.map +0 -1
- package/build-module/components/add-new-template/add-custom-generic-template-modal.js.map +0 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +0 -1
- package/build-module/components/global-styles/border-panel.js +0 -125
- package/build-module/components/global-styles/border-panel.js.map +0 -1
- package/build-module/components/navigate-to-link/index.js +0 -39
- package/build-module/components/navigate-to-link/index.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js +0 -11
- package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js.map +0 -1
- package/build-module/components/template-details/edit-template-title.js +0 -33
- package/build-module/components/template-details/edit-template-title.js.map +0 -1
- package/build-module/components/template-details/index.js +0 -83
- package/build-module/components/template-details/index.js.map +0 -1
- package/build-module/components/template-details/template-areas.js +0 -145
- package/build-module/components/template-details/template-areas.js.map +0 -1
- package/build-module/components/template-details/template-part-area-selector.js +0 -36
- package/build-module/components/template-details/template-part-area-selector.js.map +0 -1
- package/src/components/add-new-template/add-custom-generic-template-modal.js +0 -101
- package/src/components/global-styles/border-panel.js +0 -114
- package/src/components/navigate-to-link/index.js +0 -46
- package/src/components/sidebar-navigation-screen-navigation-menus/loader.js +0 -9
- package/src/components/template-details/edit-template-title.js +0 -41
- package/src/components/template-details/index.js +0 -113
- package/src/components/template-details/style.scss +0 -72
- package/src/components/template-details/template-areas.js +0 -167
- package/src/components/template-details/template-part-area-selector.js +0 -39
|
@@ -18,9 +18,8 @@ import { dateI18n, getDate, humanTimeDiff, getSettings } from '@wordpress/date';
|
|
|
18
18
|
*/
|
|
19
19
|
function getRevisionLabel( revision ) {
|
|
20
20
|
const authorDisplayName = revision?.author?.name || __( 'User' );
|
|
21
|
-
const isUnsaved = 'unsaved' === revision?.id;
|
|
22
21
|
|
|
23
|
-
if (
|
|
22
|
+
if ( 'unsaved' === revision?.id ) {
|
|
24
23
|
return sprintf(
|
|
25
24
|
/* translators: %(name)s author display name */
|
|
26
25
|
__( 'Unsaved changes by %(name)s' ),
|
|
@@ -57,45 +56,42 @@ function getRevisionLabel( revision ) {
|
|
|
57
56
|
* Returns a rendered list of revisions buttons.
|
|
58
57
|
*
|
|
59
58
|
* @typedef {Object} props
|
|
60
|
-
* @property {Array<Object>} userRevisions
|
|
61
|
-
* @property {number}
|
|
62
|
-
* @property {Function} onChange
|
|
59
|
+
* @property {Array<Object>} userRevisions A collection of user revisions.
|
|
60
|
+
* @property {number} selectedRevisionId The id of the currently-selected revision.
|
|
61
|
+
* @property {Function} onChange Callback fired when a revision is selected.
|
|
63
62
|
*
|
|
64
|
-
* @param {props} Component
|
|
63
|
+
* @param {props} Component props.
|
|
65
64
|
* @return {JSX.Element} The modal component.
|
|
66
65
|
*/
|
|
67
|
-
function RevisionsButtons( { userRevisions,
|
|
66
|
+
function RevisionsButtons( { userRevisions, selectedRevisionId, onChange } ) {
|
|
68
67
|
return (
|
|
69
68
|
<ol
|
|
70
69
|
className="edit-site-global-styles-screen-revisions__revisions-list"
|
|
71
70
|
aria-label={ __( 'Global styles revisions' ) }
|
|
72
71
|
role="group"
|
|
73
72
|
>
|
|
74
|
-
{ userRevisions.map( ( revision ) => {
|
|
75
|
-
const { id, author,
|
|
73
|
+
{ userRevisions.map( ( revision, index ) => {
|
|
74
|
+
const { id, author, modified } = revision;
|
|
76
75
|
const authorDisplayName = author?.name || __( 'User' );
|
|
77
76
|
const authorAvatar = author?.avatar_urls?.[ '48' ];
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const isActive = !! currentRevisionId
|
|
83
|
-
? id === currentRevisionId
|
|
84
|
-
: isLatest;
|
|
77
|
+
const isUnsaved = 'unsaved' === revision?.id;
|
|
78
|
+
const isSelected = selectedRevisionId
|
|
79
|
+
? selectedRevisionId === revision?.id
|
|
80
|
+
: index === 0;
|
|
85
81
|
|
|
86
82
|
return (
|
|
87
83
|
<li
|
|
88
84
|
className={ classnames(
|
|
89
85
|
'edit-site-global-styles-screen-revisions__revision-item',
|
|
90
86
|
{
|
|
91
|
-
'is-
|
|
87
|
+
'is-selected': isSelected,
|
|
92
88
|
}
|
|
93
89
|
) }
|
|
94
90
|
key={ id }
|
|
95
91
|
>
|
|
96
92
|
<Button
|
|
97
93
|
className="edit-site-global-styles-screen-revisions__revision-button"
|
|
98
|
-
disabled={
|
|
94
|
+
disabled={ isSelected }
|
|
99
95
|
onClick={ () => {
|
|
100
96
|
onChange( revision );
|
|
101
97
|
} }
|
|
@@ -106,13 +102,25 @@ function RevisionsButtons( { userRevisions, currentRevisionId, onChange } ) {
|
|
|
106
102
|
{ humanTimeDiff( modified ) }
|
|
107
103
|
</time>
|
|
108
104
|
<span className="edit-site-global-styles-screen-revisions__meta">
|
|
109
|
-
{
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
105
|
+
{ isUnsaved
|
|
106
|
+
? sprintf(
|
|
107
|
+
/* translators: %(name)s author display name */
|
|
108
|
+
__(
|
|
109
|
+
'Unsaved changes by %(name)s'
|
|
110
|
+
),
|
|
111
|
+
{
|
|
112
|
+
name: authorDisplayName,
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
: sprintf(
|
|
116
|
+
/* translators: %(name)s author display name */
|
|
117
|
+
__(
|
|
118
|
+
'Changes saved by %(name)s'
|
|
119
|
+
),
|
|
120
|
+
{
|
|
121
|
+
name: authorDisplayName,
|
|
122
|
+
}
|
|
123
|
+
) }
|
|
116
124
|
|
|
117
125
|
<img
|
|
118
126
|
alt={ author?.name }
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
left: 0;
|
|
37
37
|
transform: translate(-50%, -50%);
|
|
38
38
|
}
|
|
39
|
-
&.is-
|
|
39
|
+
&.is-selected::before {
|
|
40
40
|
background: var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
.is-
|
|
59
|
+
.is-selected {
|
|
60
60
|
.edit-site-global-styles-screen-revisions__revision-button {
|
|
61
61
|
color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
|
|
62
62
|
opacity: 1;
|
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
justify-content: space-between;
|
|
87
87
|
width: 100%;
|
|
88
88
|
align-items: center;
|
|
89
|
+
text-align: left;
|
|
89
90
|
|
|
90
91
|
img {
|
|
91
92
|
width: $grid-unit-20;
|
|
@@ -49,7 +49,6 @@ describe( 'useGlobalStylesRevisions', () => {
|
|
|
49
49
|
styles: {},
|
|
50
50
|
},
|
|
51
51
|
],
|
|
52
|
-
isLoading: false,
|
|
53
52
|
};
|
|
54
53
|
|
|
55
54
|
it( 'returns loaded revisions with no unsaved changes', () => {
|
|
@@ -109,10 +108,24 @@ describe( 'useGlobalStylesRevisions', () => {
|
|
|
109
108
|
] );
|
|
110
109
|
} );
|
|
111
110
|
|
|
112
|
-
it( 'returns empty revisions
|
|
111
|
+
it( 'returns empty revisions', () => {
|
|
113
112
|
useSelect.mockImplementation( () => ( {
|
|
114
113
|
...selectValue,
|
|
115
|
-
|
|
114
|
+
revisions: [],
|
|
115
|
+
} ) );
|
|
116
|
+
|
|
117
|
+
const { result } = renderHook( () => useGlobalStylesRevisions() );
|
|
118
|
+
const { revisions, isLoading, hasUnsavedChanges } = result.current;
|
|
119
|
+
|
|
120
|
+
expect( isLoading ).toBe( true );
|
|
121
|
+
expect( hasUnsavedChanges ).toBe( false );
|
|
122
|
+
expect( revisions ).toEqual( [] );
|
|
123
|
+
} );
|
|
124
|
+
|
|
125
|
+
it( 'returns empty revisions when authors are not yet available', () => {
|
|
126
|
+
useSelect.mockImplementation( () => ( {
|
|
127
|
+
...selectValue,
|
|
128
|
+
authors: [],
|
|
116
129
|
} ) );
|
|
117
130
|
|
|
118
131
|
const { result } = renderHook( () => useGlobalStylesRevisions() );
|
|
@@ -20,53 +20,46 @@ const SITE_EDITOR_AUTHORS_QUERY = {
|
|
|
20
20
|
context: 'view',
|
|
21
21
|
capabilities: [ 'edit_theme_options' ],
|
|
22
22
|
};
|
|
23
|
-
|
|
23
|
+
const EMPTY_ARRAY = [];
|
|
24
24
|
const { GlobalStylesContext } = unlock( blockEditorPrivateApis );
|
|
25
25
|
export default function useGlobalStylesRevisions() {
|
|
26
26
|
const { user: userConfig } = useContext( GlobalStylesContext );
|
|
27
|
-
const { authors, currentUser, isDirty, revisions
|
|
27
|
+
const { authors, currentUser, isDirty, revisions } = useSelect(
|
|
28
28
|
( select ) => {
|
|
29
29
|
const {
|
|
30
30
|
__experimentalGetDirtyEntityRecords,
|
|
31
31
|
getCurrentUser,
|
|
32
32
|
getUsers,
|
|
33
33
|
getCurrentThemeGlobalStylesRevisions,
|
|
34
|
-
isResolving,
|
|
35
34
|
} = select( coreStore );
|
|
36
35
|
const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
|
|
37
36
|
const _currentUser = getCurrentUser();
|
|
38
37
|
const _isDirty = dirtyEntityRecords.length > 0;
|
|
39
38
|
const globalStylesRevisions =
|
|
40
|
-
getCurrentThemeGlobalStylesRevisions() ||
|
|
41
|
-
const _authors =
|
|
39
|
+
getCurrentThemeGlobalStylesRevisions() || EMPTY_ARRAY;
|
|
40
|
+
const _authors =
|
|
41
|
+
getUsers( SITE_EDITOR_AUTHORS_QUERY ) || EMPTY_ARRAY;
|
|
42
42
|
|
|
43
43
|
return {
|
|
44
44
|
authors: _authors,
|
|
45
45
|
currentUser: _currentUser,
|
|
46
46
|
isDirty: _isDirty,
|
|
47
47
|
revisions: globalStylesRevisions,
|
|
48
|
-
isLoading:
|
|
49
|
-
! globalStylesRevisions.length ||
|
|
50
|
-
isResolving( 'getUsers', [ SITE_EDITOR_AUTHORS_QUERY ] ),
|
|
51
48
|
};
|
|
52
49
|
},
|
|
53
50
|
[]
|
|
54
51
|
);
|
|
55
52
|
return useMemo( () => {
|
|
56
53
|
let _modifiedRevisions = [];
|
|
57
|
-
if (
|
|
54
|
+
if ( ! authors.length || ! revisions.length ) {
|
|
58
55
|
return {
|
|
59
56
|
revisions: _modifiedRevisions,
|
|
60
57
|
hasUnsavedChanges: isDirty,
|
|
61
|
-
isLoading,
|
|
58
|
+
isLoading: true,
|
|
62
59
|
};
|
|
63
60
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
* Also adds author information to the revision.
|
|
67
|
-
* Then, if there are unsaved changes in the editor, create a
|
|
68
|
-
* new "revision" item that represents the unsaved changes.
|
|
69
|
-
*/
|
|
61
|
+
|
|
62
|
+
// Adds author details to each revision.
|
|
70
63
|
_modifiedRevisions = revisions.map( ( revision ) => {
|
|
71
64
|
return {
|
|
72
65
|
...revision,
|
|
@@ -76,10 +69,12 @@ export default function useGlobalStylesRevisions() {
|
|
|
76
69
|
};
|
|
77
70
|
} );
|
|
78
71
|
|
|
79
|
-
|
|
72
|
+
// Flags the most current saved revision.
|
|
73
|
+
if ( _modifiedRevisions[ 0 ].id !== 'unsaved' ) {
|
|
80
74
|
_modifiedRevisions[ 0 ].isLatest = true;
|
|
81
75
|
}
|
|
82
76
|
|
|
77
|
+
// Adds an item for unsaved changes.
|
|
83
78
|
if ( isDirty && ! isEmpty( userConfig ) && currentUser ) {
|
|
84
79
|
const unsavedRevision = {
|
|
85
80
|
id: 'unsaved',
|
|
@@ -94,10 +89,11 @@ export default function useGlobalStylesRevisions() {
|
|
|
94
89
|
|
|
95
90
|
_modifiedRevisions.unshift( unsavedRevision );
|
|
96
91
|
}
|
|
92
|
+
|
|
97
93
|
return {
|
|
98
94
|
revisions: _modifiedRevisions,
|
|
99
95
|
hasUnsavedChanges: isDirty,
|
|
100
|
-
isLoading,
|
|
96
|
+
isLoading: false,
|
|
101
97
|
};
|
|
102
|
-
}, [ revisions
|
|
98
|
+
}, [ isDirty, revisions, currentUser, authors, userConfig ] );
|
|
103
99
|
}
|
|
@@ -31,7 +31,7 @@ function ScreenRoot() {
|
|
|
31
31
|
const { useGlobalStyle } = unlock( blockEditorPrivateApis );
|
|
32
32
|
const [ customCSS ] = useGlobalStyle( 'css' );
|
|
33
33
|
|
|
34
|
-
const {
|
|
34
|
+
const { hasVariations, canEditCSS } = useSelect( ( select ) => {
|
|
35
35
|
const {
|
|
36
36
|
getEntityRecord,
|
|
37
37
|
__experimentalGetCurrentGlobalStylesId,
|
|
@@ -44,7 +44,9 @@ function ScreenRoot() {
|
|
|
44
44
|
: undefined;
|
|
45
45
|
|
|
46
46
|
return {
|
|
47
|
-
|
|
47
|
+
hasVariations:
|
|
48
|
+
!! __experimentalGetCurrentThemeGlobalStylesVariations()
|
|
49
|
+
?.length,
|
|
48
50
|
canEditCSS:
|
|
49
51
|
!! globalStyles?._links?.[ 'wp:action-edit-css' ] ?? false,
|
|
50
52
|
};
|
|
@@ -59,7 +61,7 @@ function ScreenRoot() {
|
|
|
59
61
|
<StylesPreview />
|
|
60
62
|
</CardMedia>
|
|
61
63
|
</Card>
|
|
62
|
-
{
|
|
64
|
+
{ hasVariations && (
|
|
63
65
|
<ItemGroup>
|
|
64
66
|
<NavigationButtonAsItem
|
|
65
67
|
path="/variations"
|
|
@@ -91,13 +91,10 @@ function Variation( { variation } ) {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
export default function StyleVariationsContainer() {
|
|
94
|
-
const
|
|
95
|
-
return
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
coreStore
|
|
99
|
-
).__experimentalGetCurrentThemeGlobalStylesVariations() || [],
|
|
100
|
-
};
|
|
94
|
+
const variations = useSelect( ( select ) => {
|
|
95
|
+
return select(
|
|
96
|
+
coreStore
|
|
97
|
+
).__experimentalGetCurrentThemeGlobalStylesVariations();
|
|
101
98
|
}, [] );
|
|
102
99
|
|
|
103
100
|
const withEmptyVariation = useMemo( () => {
|
|
@@ -107,7 +104,7 @@ export default function StyleVariationsContainer() {
|
|
|
107
104
|
settings: {},
|
|
108
105
|
styles: {},
|
|
109
106
|
},
|
|
110
|
-
...variations.map( ( variation ) => ( {
|
|
107
|
+
...( variations ?? [] ).map( ( variation ) => ( {
|
|
111
108
|
...variation,
|
|
112
109
|
settings: variation.settings ?? {},
|
|
113
110
|
styles: variation.styles ?? {},
|
|
@@ -116,15 +113,13 @@ export default function StyleVariationsContainer() {
|
|
|
116
113
|
}, [ variations ] );
|
|
117
114
|
|
|
118
115
|
return (
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
{
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
</Grid>
|
|
128
|
-
</>
|
|
116
|
+
<Grid
|
|
117
|
+
columns={ 2 }
|
|
118
|
+
className="edit-site-global-styles-style-variations-container"
|
|
119
|
+
>
|
|
120
|
+
{ withEmptyVariation.map( ( variation, index ) => (
|
|
121
|
+
<Variation key={ index } variation={ variation } />
|
|
122
|
+
) ) }
|
|
123
|
+
</Grid>
|
|
129
124
|
);
|
|
130
125
|
}
|
|
@@ -18,7 +18,7 @@ import { __, sprintf, _n } from '@wordpress/i18n';
|
|
|
18
18
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
19
19
|
import { moreVertical } from '@wordpress/icons';
|
|
20
20
|
import { store as coreStore } from '@wordpress/core-data';
|
|
21
|
-
import { useEffect
|
|
21
|
+
import { useEffect } from '@wordpress/element';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Internal dependencies
|
|
@@ -203,7 +203,6 @@ function GlobalStylesStyleBook() {
|
|
|
203
203
|
|
|
204
204
|
function GlobalStylesBlockLink() {
|
|
205
205
|
const navigator = useNavigator();
|
|
206
|
-
const isMounted = useRef();
|
|
207
206
|
const { selectedBlockName, selectedBlockClientId } = useSelect(
|
|
208
207
|
( select ) => {
|
|
209
208
|
const { getSelectedBlockClientId, getBlockName } =
|
|
@@ -217,20 +216,23 @@ function GlobalStylesBlockLink() {
|
|
|
217
216
|
[]
|
|
218
217
|
);
|
|
219
218
|
const blockHasGlobalStyles = useBlockHasGlobalStyles( selectedBlockName );
|
|
219
|
+
// When we're in the `Blocks` screen enable deep linking to the selected block.
|
|
220
220
|
useEffect( () => {
|
|
221
|
-
|
|
222
|
-
if ( ! isMounted.current ) {
|
|
223
|
-
isMounted.current = true;
|
|
221
|
+
if ( ! selectedBlockClientId || ! blockHasGlobalStyles ) {
|
|
224
222
|
return;
|
|
225
223
|
}
|
|
226
|
-
|
|
224
|
+
const currentPath = navigator.location.path;
|
|
225
|
+
if (
|
|
226
|
+
currentPath !== '/blocks' &&
|
|
227
|
+
! currentPath.startsWith( '/blocks/' )
|
|
228
|
+
) {
|
|
227
229
|
return;
|
|
228
230
|
}
|
|
229
|
-
const
|
|
231
|
+
const newPath = '/blocks/' + encodeURIComponent( selectedBlockName );
|
|
230
232
|
// Avoid navigating to the same path. This can happen when selecting
|
|
231
233
|
// a new block of the same type.
|
|
232
|
-
if (
|
|
233
|
-
navigator.goTo(
|
|
234
|
+
if ( newPath !== currentPath ) {
|
|
235
|
+
navigator.goTo( newPath, { skipFocus: true } );
|
|
234
236
|
}
|
|
235
237
|
}, [ selectedBlockClientId, selectedBlockName, blockHasGlobalStyles ] );
|
|
236
238
|
}
|
|
@@ -1,112 +1,40 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import classnames from 'classnames';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
9
4
|
import { sprintf, __ } from '@wordpress/i18n';
|
|
5
|
+
import { useDispatch } from '@wordpress/data';
|
|
10
6
|
import {
|
|
11
|
-
__experimentalGetBlockLabel as getBlockLabel,
|
|
12
|
-
getBlockType,
|
|
13
|
-
} from '@wordpress/blocks';
|
|
14
|
-
import { useSelect } from '@wordpress/data';
|
|
15
|
-
import {
|
|
16
|
-
Dropdown,
|
|
17
7
|
Button,
|
|
18
8
|
VisuallyHidden,
|
|
19
9
|
__experimentalText as Text,
|
|
10
|
+
__experimentalHStack as HStack,
|
|
20
11
|
} from '@wordpress/components';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
store as blockEditorStore,
|
|
25
|
-
useBlockDisplayInformation,
|
|
26
|
-
BlockIcon,
|
|
27
|
-
} from '@wordpress/block-editor';
|
|
28
|
-
import { store as preferencesStore } from '@wordpress/preferences';
|
|
12
|
+
import { BlockIcon } from '@wordpress/block-editor';
|
|
13
|
+
import { privateApis as commandsPrivateApis } from '@wordpress/commands';
|
|
14
|
+
import { displayShortcut } from '@wordpress/keycodes';
|
|
29
15
|
|
|
30
16
|
/**
|
|
31
17
|
* Internal dependencies
|
|
32
18
|
*/
|
|
33
|
-
import TemplateDetails from '../../template-details';
|
|
34
19
|
import useEditedEntityRecord from '../../use-edited-entity-record';
|
|
20
|
+
import { unlock } from '../../../private-apis';
|
|
35
21
|
|
|
36
|
-
|
|
37
|
-
if ( block ) {
|
|
38
|
-
const blockType = getBlockType( block.name );
|
|
39
|
-
return blockType ? getBlockLabel( blockType, block.attributes ) : null;
|
|
40
|
-
}
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function useSecondaryText() {
|
|
45
|
-
const { getBlock } = useSelect( blockEditorStore );
|
|
46
|
-
const activeEntityBlockId = useSelect(
|
|
47
|
-
( select ) =>
|
|
48
|
-
select(
|
|
49
|
-
blockEditorStore
|
|
50
|
-
).__experimentalGetActiveBlockIdByBlockNames( [
|
|
51
|
-
'core/template-part',
|
|
52
|
-
] ),
|
|
53
|
-
[]
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
const blockInformation = useBlockDisplayInformation( activeEntityBlockId );
|
|
57
|
-
|
|
58
|
-
if ( activeEntityBlockId ) {
|
|
59
|
-
return {
|
|
60
|
-
label: getBlockDisplayText( getBlock( activeEntityBlockId ) ),
|
|
61
|
-
isActive: true,
|
|
62
|
-
icon: blockInformation?.icon,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return {};
|
|
67
|
-
}
|
|
22
|
+
const { store: commandsStore } = unlock( commandsPrivateApis );
|
|
68
23
|
|
|
69
24
|
export default function DocumentActions() {
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
select( preferencesStore ).get(
|
|
73
|
-
'core/edit-site',
|
|
74
|
-
'showIconLabels'
|
|
75
|
-
),
|
|
76
|
-
[]
|
|
77
|
-
);
|
|
78
|
-
const { isLoaded, record, getTitle } = useEditedEntityRecord();
|
|
79
|
-
const { label, icon } = useSecondaryText();
|
|
80
|
-
|
|
81
|
-
// Use internal state instead of a ref to make sure that the component
|
|
82
|
-
// re-renders when the popover's anchor updates.
|
|
83
|
-
const [ popoverAnchor, setPopoverAnchor ] = useState( null );
|
|
84
|
-
|
|
85
|
-
// Memoize popoverProps to avoid returning a new object every time.
|
|
86
|
-
const popoverProps = useMemo(
|
|
87
|
-
() => ( {
|
|
88
|
-
// Use the title wrapper as the popover anchor so that the dropdown is
|
|
89
|
-
// centered over the whole title area rather than just one part of it.
|
|
90
|
-
anchor: popoverAnchor,
|
|
91
|
-
placement: 'bottom',
|
|
92
|
-
} ),
|
|
93
|
-
[ popoverAnchor ]
|
|
94
|
-
);
|
|
25
|
+
const { open: openCommandCenter } = useDispatch( commandsStore );
|
|
26
|
+
const { isLoaded, record, getTitle, icon } = useEditedEntityRecord();
|
|
95
27
|
|
|
96
28
|
// Return a simple loading indicator until we have information to show.
|
|
97
29
|
if ( ! isLoaded ) {
|
|
98
|
-
return
|
|
99
|
-
<div className="edit-site-document-actions">
|
|
100
|
-
{ __( 'Loading…' ) }
|
|
101
|
-
</div>
|
|
102
|
-
);
|
|
30
|
+
return null;
|
|
103
31
|
}
|
|
104
32
|
|
|
105
33
|
// Return feedback that the template does not seem to exist.
|
|
106
34
|
if ( ! record ) {
|
|
107
35
|
return (
|
|
108
36
|
<div className="edit-site-document-actions">
|
|
109
|
-
{ __( '
|
|
37
|
+
{ __( 'Document not found' ) }
|
|
110
38
|
</div>
|
|
111
39
|
);
|
|
112
40
|
}
|
|
@@ -117,20 +45,18 @@ export default function DocumentActions() {
|
|
|
117
45
|
: __( 'template' );
|
|
118
46
|
|
|
119
47
|
return (
|
|
120
|
-
<
|
|
121
|
-
className=
|
|
122
|
-
|
|
123
|
-
} ) }
|
|
48
|
+
<Button
|
|
49
|
+
className="edit-site-document-actions"
|
|
50
|
+
onClick={ () => openCommandCenter() }
|
|
124
51
|
>
|
|
125
|
-
<
|
|
126
|
-
|
|
127
|
-
|
|
52
|
+
<span className="edit-site-document-actions__left"></span>
|
|
53
|
+
<HStack
|
|
54
|
+
spacing={ 1 }
|
|
55
|
+
justify="center"
|
|
56
|
+
className="edit-site-document-actions__title"
|
|
128
57
|
>
|
|
129
|
-
<
|
|
130
|
-
|
|
131
|
-
className="edit-site-document-actions__title"
|
|
132
|
-
as="h1"
|
|
133
|
-
>
|
|
58
|
+
<BlockIcon icon={ icon } />
|
|
59
|
+
<Text size="body" as="h1">
|
|
134
60
|
<VisuallyHidden as="span">
|
|
135
61
|
{ sprintf(
|
|
136
62
|
/* translators: %s: the entity being edited, like "template"*/
|
|
@@ -140,39 +66,10 @@ export default function DocumentActions() {
|
|
|
140
66
|
</VisuallyHidden>
|
|
141
67
|
{ getTitle() }
|
|
142
68
|
</Text>
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
<Dropdown
|
|
149
|
-
popoverProps={ popoverProps }
|
|
150
|
-
renderToggle={ ( { isOpen, onToggle } ) => (
|
|
151
|
-
<Button
|
|
152
|
-
className="edit-site-document-actions__get-info"
|
|
153
|
-
icon={ chevronDown }
|
|
154
|
-
aria-expanded={ isOpen }
|
|
155
|
-
aria-haspopup="true"
|
|
156
|
-
onClick={ onToggle }
|
|
157
|
-
variant={ showIconLabels ? 'tertiary' : undefined }
|
|
158
|
-
label={ sprintf(
|
|
159
|
-
/* translators: %s: the entity to see details about, like "template"*/
|
|
160
|
-
__( 'Show %s details' ),
|
|
161
|
-
entityLabel
|
|
162
|
-
) }
|
|
163
|
-
>
|
|
164
|
-
{ showIconLabels && __( 'Details' ) }
|
|
165
|
-
</Button>
|
|
166
|
-
) }
|
|
167
|
-
contentClassName="edit-site-document-actions__info-dropdown"
|
|
168
|
-
renderContent={ ( { onClose } ) => (
|
|
169
|
-
<TemplateDetails
|
|
170
|
-
template={ record }
|
|
171
|
-
onClose={ onClose }
|
|
172
|
-
/>
|
|
173
|
-
) }
|
|
174
|
-
/>
|
|
175
|
-
</div>
|
|
176
|
-
</div>
|
|
69
|
+
</HStack>
|
|
70
|
+
<span className="edit-site-document-actions__shortcut">
|
|
71
|
+
{ displayShortcut.primary( 'k' ) }
|
|
72
|
+
</span>
|
|
73
|
+
</Button>
|
|
177
74
|
);
|
|
178
75
|
}
|