@wordpress/edit-site 5.15.0 → 5.16.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-pattern/index.js +2 -1
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/block-editor/use-site-editor-settings.js +29 -2
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/editor/index.js +4 -4
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +12 -7
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/screen-block.js +16 -0
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-revisions/index.js +12 -5
- package/build/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js +10 -22
- 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 +32 -25
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build/components/global-styles/style-variations-container.js +5 -3
- package/build/components/global-styles/style-variations-container.js.map +1 -1
- package/build/components/header-edit-mode/document-actions/index.js +4 -2
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/edit-mode.js +7 -5
- package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -1
- package/build/components/layout/index.js +9 -2
- package/build/components/layout/index.js.map +1 -1
- package/build/components/page/index.js +3 -3
- package/build/components/page/index.js.map +1 -1
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js +1 -1
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/page-patterns/patterns-list.js +18 -4
- package/build/components/page-patterns/patterns-list.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +20 -3
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-template-parts/index.js +1 -2
- package/build/components/page-template-parts/index.js.map +1 -1
- package/build/components/page-templates/index.js +1 -16
- package/build/components/page-templates/index.js.map +1 -1
- package/build/components/resizable-frame/index.js +11 -19
- package/build/components/resizable-frame/index.js.map +1 -1
- package/build/components/save-button/index.js +4 -2
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/save-hub/index.js +10 -4
- package/build/components/save-hub/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-panel/index.js +15 -8
- package/build/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +24 -14
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +34 -40
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +4 -4
- 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 +8 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pages/index.js +2 -0
- package/build/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +8 -1
- package/build/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js +50 -26
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/category-item.js +0 -5
- package/build/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js +0 -9
- package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +1 -10
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +9 -0
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/site-hub/index.js +5 -2
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -1
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +57 -27
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/hooks/commands/use-edit-mode-commands.js +65 -7
- package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +84 -49
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/store/private-actions.js +2 -1
- package/build/store/private-actions.js.map +1 -1
- package/build/utils/use-debounced-input.js +5 -7
- package/build/utils/use-debounced-input.js.map +1 -1
- package/build-module/components/add-new-pattern/index.js +2 -1
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +29 -2
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/editor/index.js +4 -4
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +12 -7
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/screen-block.js +16 -0
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/index.js +13 -6
- package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +10 -22
- 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 +28 -21
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build-module/components/global-styles/style-variations-container.js +5 -3
- package/build-module/components/global-styles/style-variations-container.js.map +1 -1
- package/build-module/components/header-edit-mode/document-actions/index.js +6 -4
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/edit-mode.js +7 -5
- package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -1
- package/build-module/components/layout/index.js +9 -2
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/page/index.js +3 -3
- package/build-module/components/page/index.js.map +1 -1
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js +1 -1
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/page-patterns/patterns-list.js +19 -5
- package/build-module/components/page-patterns/patterns-list.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +19 -3
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-template-parts/index.js +1 -2
- package/build-module/components/page-template-parts/index.js.map +1 -1
- package/build-module/components/page-templates/index.js +2 -15
- package/build-module/components/page-templates/index.js.map +1 -1
- package/build-module/components/resizable-frame/index.js +12 -20
- package/build-module/components/resizable-frame/index.js.map +1 -1
- package/build-module/components/save-button/index.js +4 -2
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/save-hub/index.js +10 -4
- package/build-module/components/save-hub/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-panel/index.js +15 -9
- package/build-module/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +21 -14
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +34 -40
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +4 -4
- 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 +7 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +2 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pages/index.js +2 -0
- package/build-module/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +7 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js +49 -26
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/category-item.js +0 -5
- package/build-module/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.js +0 -7
- package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +1 -8
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +7 -0
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +4 -2
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +57 -27
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +65 -9
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +84 -49
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/store/private-actions.js +2 -1
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/utils/use-debounced-input.js +5 -7
- package/build-module/utils/use-debounced-input.js.map +1 -1
- package/build-style/style-rtl.css +67 -47
- package/build-style/style.css +67 -47
- package/package.json +39 -39
- package/src/components/add-new-pattern/index.js +2 -0
- package/src/components/block-editor/use-site-editor-settings.js +22 -2
- package/src/components/editor/index.js +3 -3
- package/src/components/global-styles/global-styles-provider.js +7 -2
- package/src/components/global-styles/screen-block.js +15 -0
- package/src/components/global-styles/screen-revisions/index.js +64 -58
- package/src/components/global-styles/screen-revisions/revisions-buttons.js +17 -31
- package/src/components/global-styles/screen-revisions/test/use-global-styles-revisions.js +14 -1
- package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +64 -48
- package/src/components/global-styles/style-variations-container.js +2 -0
- package/src/components/header-edit-mode/document-actions/index.js +8 -4
- package/src/components/header-edit-mode/document-actions/style.scss +41 -28
- package/src/components/keyboard-shortcuts/edit-mode.js +4 -5
- package/src/components/layout/index.js +33 -20
- package/src/components/layout/style.scss +2 -2
- package/src/components/page/index.js +8 -8
- package/src/components/page/style.scss +8 -5
- package/src/components/page-content-focus-manager/disable-non-page-content-blocks.js +1 -1
- package/src/components/page-patterns/patterns-list.js +25 -12
- package/src/components/page-patterns/style.scss +9 -8
- package/src/components/page-patterns/use-patterns.js +19 -3
- package/src/components/page-template-parts/index.js +0 -1
- package/src/components/page-templates/index.js +6 -19
- package/src/components/resizable-frame/index.js +10 -25
- package/src/components/save-button/index.js +2 -0
- package/src/components/save-hub/index.js +6 -1
- package/src/components/save-hub/style.scss +1 -1
- package/src/components/sidebar-edit-mode/template-panel/index.js +15 -11
- package/src/components/sidebar-navigation-screen/index.js +24 -16
- package/src/components/sidebar-navigation-screen/style.scss +4 -0
- package/src/components/sidebar-navigation-screen-details-panel/style.scss +1 -0
- package/src/components/sidebar-navigation-screen-global-styles/index.js +48 -44
- package/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +1 -2
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +4 -4
- package/src/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +27 -15
- package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +1 -4
- package/src/components/sidebar-navigation-screen-pages/index.js +9 -4
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +1 -1
- package/src/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +11 -1
- package/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js +69 -41
- package/src/components/sidebar-navigation-screen-patterns/category-item.js +5 -13
- package/src/components/sidebar-navigation-screen-patterns/index.js +0 -8
- package/src/components/sidebar-navigation-screen-templates/index.js +1 -9
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +10 -0
- package/src/components/site-hub/index.js +3 -1
- package/src/components/site-hub/style.scss +1 -2
- package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -4
- package/src/components/table/style.scss +1 -0
- package/src/hooks/commands/use-common-commands.js +63 -23
- package/src/hooks/commands/use-edit-mode-commands.js +94 -23
- package/src/hooks/push-changes-to-global-styles/index.js +83 -46
- package/src/store/private-actions.js +5 -1
- package/src/utils/use-debounced-input.js +8 -7
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
__experimentalUseNavigator as useNavigator,
|
|
8
8
|
__experimentalConfirmDialog as ConfirmDialog,
|
|
9
9
|
Spinner,
|
|
10
|
+
__experimentalSpacer as Spacer,
|
|
10
11
|
} from '@wordpress/components';
|
|
11
12
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
12
13
|
import { useContext, useState, useEffect } from '@wordpress/element';
|
|
@@ -70,6 +71,7 @@ function ScreenRevisions() {
|
|
|
70
71
|
setUserConfig( () => ( {
|
|
71
72
|
styles: revision?.styles,
|
|
72
73
|
settings: revision?.settings,
|
|
74
|
+
behaviors: revision?.behaviors,
|
|
73
75
|
} ) );
|
|
74
76
|
setIsLoadingRevisionWithUnsavedChanges( false );
|
|
75
77
|
onCloseRevisions();
|
|
@@ -79,6 +81,7 @@ function ScreenRevisions() {
|
|
|
79
81
|
setGlobalStylesRevision( {
|
|
80
82
|
styles: revision?.styles,
|
|
81
83
|
settings: revision?.settings,
|
|
84
|
+
behaviors: revision?.behaviors,
|
|
82
85
|
id: revision?.id,
|
|
83
86
|
} );
|
|
84
87
|
setSelectedRevisionId( revision?.id );
|
|
@@ -87,6 +90,7 @@ function ScreenRevisions() {
|
|
|
87
90
|
const isLoadButtonEnabled =
|
|
88
91
|
!! globalStylesRevision?.id &&
|
|
89
92
|
! areGlobalStyleConfigsEqual( globalStylesRevision, userConfig );
|
|
93
|
+
const shouldShowRevisions = ! isLoading && revisions.length;
|
|
90
94
|
|
|
91
95
|
return (
|
|
92
96
|
<>
|
|
@@ -99,68 +103,70 @@ function ScreenRevisions() {
|
|
|
99
103
|
{ isLoading && (
|
|
100
104
|
<Spinner className="edit-site-global-styles-screen-revisions__loading" />
|
|
101
105
|
) }
|
|
102
|
-
{
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
106
|
+
{ shouldShowRevisions ? (
|
|
107
|
+
<>
|
|
108
|
+
<Revisions
|
|
109
|
+
blocks={ blocks }
|
|
110
|
+
userConfig={ globalStylesRevision }
|
|
111
|
+
onClose={ onCloseRevisions }
|
|
112
|
+
/>
|
|
113
|
+
<div className="edit-site-global-styles-screen-revisions">
|
|
114
|
+
<RevisionsButtons
|
|
115
|
+
onChange={ selectRevision }
|
|
116
|
+
selectedRevisionId={ selectedRevisionId }
|
|
117
|
+
userRevisions={ revisions }
|
|
118
|
+
/>
|
|
119
|
+
{ isLoadButtonEnabled && (
|
|
120
|
+
<SidebarFixedBottom>
|
|
121
|
+
<Button
|
|
122
|
+
variant="primary"
|
|
123
|
+
className="edit-site-global-styles-screen-revisions__button"
|
|
124
|
+
disabled={
|
|
125
|
+
! globalStylesRevision?.id ||
|
|
126
|
+
globalStylesRevision?.id === 'unsaved'
|
|
127
|
+
}
|
|
128
|
+
onClick={ () => {
|
|
129
|
+
if ( hasUnsavedChanges ) {
|
|
130
|
+
setIsLoadingRevisionWithUnsavedChanges(
|
|
131
|
+
true
|
|
132
|
+
);
|
|
133
|
+
} else {
|
|
134
|
+
restoreRevision(
|
|
135
|
+
globalStylesRevision
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
} }
|
|
139
|
+
>
|
|
140
|
+
{ __( 'Apply' ) }
|
|
141
|
+
</Button>
|
|
142
|
+
</SidebarFixedBottom>
|
|
143
|
+
) }
|
|
144
|
+
</div>
|
|
145
|
+
{ isLoadingRevisionWithUnsavedChanges && (
|
|
146
|
+
<ConfirmDialog
|
|
147
|
+
isOpen={ isLoadingRevisionWithUnsavedChanges }
|
|
148
|
+
confirmButtonText={ __( 'Apply' ) }
|
|
149
|
+
onConfirm={ () =>
|
|
150
|
+
restoreRevision( globalStylesRevision )
|
|
151
|
+
}
|
|
152
|
+
onCancel={ () =>
|
|
153
|
+
setIsLoadingRevisionWithUnsavedChanges( false )
|
|
123
154
|
}
|
|
124
|
-
onClick={ () => {
|
|
125
|
-
if ( hasUnsavedChanges ) {
|
|
126
|
-
setIsLoadingRevisionWithUnsavedChanges(
|
|
127
|
-
true
|
|
128
|
-
);
|
|
129
|
-
} else {
|
|
130
|
-
restoreRevision( globalStylesRevision );
|
|
131
|
-
}
|
|
132
|
-
} }
|
|
133
155
|
>
|
|
134
|
-
{ __( 'Apply' ) }
|
|
135
|
-
</Button>
|
|
136
|
-
</SidebarFixedBottom>
|
|
137
|
-
) }
|
|
138
|
-
</div>
|
|
139
|
-
{ isLoadingRevisionWithUnsavedChanges && (
|
|
140
|
-
<ConfirmDialog
|
|
141
|
-
title={ __(
|
|
142
|
-
'Loading this revision will discard all unsaved changes.'
|
|
143
|
-
) }
|
|
144
|
-
isOpen={ isLoadingRevisionWithUnsavedChanges }
|
|
145
|
-
confirmButtonText={ __( ' Discard unsaved changes' ) }
|
|
146
|
-
onConfirm={ () => restoreRevision( globalStylesRevision ) }
|
|
147
|
-
onCancel={ () =>
|
|
148
|
-
setIsLoadingRevisionWithUnsavedChanges( false )
|
|
149
|
-
}
|
|
150
|
-
>
|
|
151
|
-
<>
|
|
152
|
-
<h2>
|
|
153
156
|
{ __(
|
|
154
|
-
'
|
|
157
|
+
'Any unsaved changes will be lost when you apply this revision.'
|
|
155
158
|
) }
|
|
156
|
-
</
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
159
|
+
</ConfirmDialog>
|
|
160
|
+
) }
|
|
161
|
+
</>
|
|
162
|
+
) : (
|
|
163
|
+
<Spacer marginX={ 4 } data-testid="global-styles-no-revisions">
|
|
164
|
+
{
|
|
165
|
+
// Adding an existing translation here in case these changes are shipped to WordPress 6.3.
|
|
166
|
+
// Later we could update to something better, e.g., "There are currently no style revisions.".
|
|
167
|
+
__( 'No results found.' )
|
|
168
|
+
}
|
|
169
|
+
</Spacer>
|
|
164
170
|
) }
|
|
165
171
|
</>
|
|
166
172
|
);
|
|
@@ -21,11 +21,9 @@ function getRevisionLabel( revision ) {
|
|
|
21
21
|
|
|
22
22
|
if ( 'unsaved' === revision?.id ) {
|
|
23
23
|
return sprintf(
|
|
24
|
-
/* translators: %
|
|
25
|
-
__( 'Unsaved changes by %
|
|
26
|
-
|
|
27
|
-
name: authorDisplayName,
|
|
28
|
-
}
|
|
24
|
+
/* translators: %s author display name */
|
|
25
|
+
__( 'Unsaved changes by %s' ),
|
|
26
|
+
authorDisplayName
|
|
29
27
|
);
|
|
30
28
|
}
|
|
31
29
|
const formattedDate = dateI18n(
|
|
@@ -35,20 +33,16 @@ function getRevisionLabel( revision ) {
|
|
|
35
33
|
|
|
36
34
|
return revision?.isLatest
|
|
37
35
|
? sprintf(
|
|
38
|
-
/* translators: %
|
|
39
|
-
__( 'Changes saved by %
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
date: formattedDate,
|
|
43
|
-
}
|
|
36
|
+
/* translators: %1$s author display name, %2$s: revision creation date */
|
|
37
|
+
__( 'Changes saved by %1$s on %2$s (current)' ),
|
|
38
|
+
authorDisplayName,
|
|
39
|
+
formattedDate
|
|
44
40
|
)
|
|
45
41
|
: sprintf(
|
|
46
|
-
/* translators: %
|
|
47
|
-
__( 'Changes saved by %
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
date: formattedDate,
|
|
51
|
-
}
|
|
42
|
+
/* translators: %1$s author display name, %2$s: revision creation date */
|
|
43
|
+
__( 'Changes saved by %1$s on %2$s' ),
|
|
44
|
+
authorDisplayName,
|
|
45
|
+
formattedDate
|
|
52
46
|
);
|
|
53
47
|
}
|
|
54
48
|
|
|
@@ -104,22 +98,14 @@ function RevisionsButtons( { userRevisions, selectedRevisionId, onChange } ) {
|
|
|
104
98
|
<span className="edit-site-global-styles-screen-revisions__meta">
|
|
105
99
|
{ isUnsaved
|
|
106
100
|
? sprintf(
|
|
107
|
-
/* translators: %
|
|
108
|
-
__(
|
|
109
|
-
|
|
110
|
-
),
|
|
111
|
-
{
|
|
112
|
-
name: authorDisplayName,
|
|
113
|
-
}
|
|
101
|
+
/* translators: %s author display name */
|
|
102
|
+
__( 'Unsaved changes by %s' ),
|
|
103
|
+
authorDisplayName
|
|
114
104
|
)
|
|
115
105
|
: sprintf(
|
|
116
|
-
/* translators: %
|
|
117
|
-
__(
|
|
118
|
-
|
|
119
|
-
),
|
|
120
|
-
{
|
|
121
|
-
name: authorDisplayName,
|
|
122
|
-
}
|
|
106
|
+
/* translators: %s author display name */
|
|
107
|
+
__( 'Changes saved by %s' ),
|
|
108
|
+
authorDisplayName
|
|
123
109
|
) }
|
|
124
110
|
|
|
125
111
|
<img
|
|
@@ -49,6 +49,7 @@ describe( 'useGlobalStylesRevisions', () => {
|
|
|
49
49
|
styles: {},
|
|
50
50
|
},
|
|
51
51
|
],
|
|
52
|
+
isLoadingGlobalStylesRevisions: false,
|
|
52
53
|
};
|
|
53
54
|
|
|
54
55
|
it( 'returns loaded revisions with no unsaved changes', () => {
|
|
@@ -117,11 +118,23 @@ describe( 'useGlobalStylesRevisions', () => {
|
|
|
117
118
|
const { result } = renderHook( () => useGlobalStylesRevisions() );
|
|
118
119
|
const { revisions, isLoading, hasUnsavedChanges } = result.current;
|
|
119
120
|
|
|
120
|
-
expect( isLoading ).toBe(
|
|
121
|
+
expect( isLoading ).toBe( false );
|
|
121
122
|
expect( hasUnsavedChanges ).toBe( false );
|
|
122
123
|
expect( revisions ).toEqual( [] );
|
|
123
124
|
} );
|
|
124
125
|
|
|
126
|
+
it( 'returns loading status when resolving global revisions', () => {
|
|
127
|
+
useSelect.mockImplementation( () => ( {
|
|
128
|
+
...selectValue,
|
|
129
|
+
isLoadingGlobalStylesRevisions: true,
|
|
130
|
+
} ) );
|
|
131
|
+
|
|
132
|
+
const { result } = renderHook( () => useGlobalStylesRevisions() );
|
|
133
|
+
const { isLoading } = result.current;
|
|
134
|
+
|
|
135
|
+
expect( isLoading ).toBe( true );
|
|
136
|
+
} );
|
|
137
|
+
|
|
125
138
|
it( 'returns empty revisions when authors are not yet available', () => {
|
|
126
139
|
useSelect.mockImplementation( () => ( {
|
|
127
140
|
...selectValue,
|
|
@@ -21,34 +21,40 @@ const EMPTY_ARRAY = [];
|
|
|
21
21
|
const { GlobalStylesContext } = unlock( blockEditorPrivateApis );
|
|
22
22
|
export default function useGlobalStylesRevisions() {
|
|
23
23
|
const { user: userConfig } = useContext( GlobalStylesContext );
|
|
24
|
-
const {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
const {
|
|
25
|
+
authors,
|
|
26
|
+
currentUser,
|
|
27
|
+
isDirty,
|
|
28
|
+
revisions,
|
|
29
|
+
isLoadingGlobalStylesRevisions,
|
|
30
|
+
} = useSelect( ( select ) => {
|
|
31
|
+
const {
|
|
32
|
+
__experimentalGetDirtyEntityRecords,
|
|
33
|
+
getCurrentUser,
|
|
34
|
+
getUsers,
|
|
35
|
+
getCurrentThemeGlobalStylesRevisions,
|
|
36
|
+
isResolving,
|
|
37
|
+
} = select( coreStore );
|
|
38
|
+
const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
|
|
39
|
+
const _currentUser = getCurrentUser();
|
|
40
|
+
const _isDirty = dirtyEntityRecords.length > 0;
|
|
41
|
+
const globalStylesRevisions =
|
|
42
|
+
getCurrentThemeGlobalStylesRevisions() || EMPTY_ARRAY;
|
|
43
|
+
const _authors = getUsers( SITE_EDITOR_AUTHORS_QUERY ) || EMPTY_ARRAY;
|
|
39
44
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
return {
|
|
46
|
+
authors: _authors,
|
|
47
|
+
currentUser: _currentUser,
|
|
48
|
+
isDirty: _isDirty,
|
|
49
|
+
revisions: globalStylesRevisions,
|
|
50
|
+
isLoadingGlobalStylesRevisions: isResolving(
|
|
51
|
+
'getCurrentThemeGlobalStylesRevisions'
|
|
52
|
+
),
|
|
53
|
+
};
|
|
54
|
+
}, [] );
|
|
49
55
|
return useMemo( () => {
|
|
50
56
|
let _modifiedRevisions = [];
|
|
51
|
-
if ( ! authors.length ||
|
|
57
|
+
if ( ! authors.length || isLoadingGlobalStylesRevisions ) {
|
|
52
58
|
return {
|
|
53
59
|
revisions: _modifiedRevisions,
|
|
54
60
|
hasUnsavedChanges: isDirty,
|
|
@@ -66,30 +72,33 @@ export default function useGlobalStylesRevisions() {
|
|
|
66
72
|
};
|
|
67
73
|
} );
|
|
68
74
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
_modifiedRevisions[ 0 ].
|
|
72
|
-
|
|
75
|
+
if ( _modifiedRevisions.length ) {
|
|
76
|
+
// Flags the most current saved revision.
|
|
77
|
+
if ( _modifiedRevisions[ 0 ].id !== 'unsaved' ) {
|
|
78
|
+
_modifiedRevisions[ 0 ].isLatest = true;
|
|
79
|
+
}
|
|
73
80
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
81
|
+
// Adds an item for unsaved changes.
|
|
82
|
+
if (
|
|
83
|
+
isDirty &&
|
|
84
|
+
userConfig &&
|
|
85
|
+
Object.keys( userConfig ).length > 0 &&
|
|
86
|
+
currentUser
|
|
87
|
+
) {
|
|
88
|
+
const unsavedRevision = {
|
|
89
|
+
id: 'unsaved',
|
|
90
|
+
styles: userConfig?.styles,
|
|
91
|
+
settings: userConfig?.settings,
|
|
92
|
+
behaviors: userConfig?.behaviors,
|
|
93
|
+
author: {
|
|
94
|
+
name: currentUser?.name,
|
|
95
|
+
avatar_urls: currentUser?.avatar_urls,
|
|
96
|
+
},
|
|
97
|
+
modified: new Date(),
|
|
98
|
+
};
|
|
91
99
|
|
|
92
|
-
|
|
100
|
+
_modifiedRevisions.unshift( unsavedRevision );
|
|
101
|
+
}
|
|
93
102
|
}
|
|
94
103
|
|
|
95
104
|
return {
|
|
@@ -97,5 +106,12 @@ export default function useGlobalStylesRevisions() {
|
|
|
97
106
|
hasUnsavedChanges: isDirty,
|
|
98
107
|
isLoading: false,
|
|
99
108
|
};
|
|
100
|
-
}, [
|
|
109
|
+
}, [
|
|
110
|
+
isDirty,
|
|
111
|
+
revisions,
|
|
112
|
+
currentUser,
|
|
113
|
+
authors,
|
|
114
|
+
userConfig,
|
|
115
|
+
isLoadingGlobalStylesRevisions,
|
|
116
|
+
] );
|
|
101
117
|
}
|
|
@@ -113,11 +113,13 @@ export default function StyleVariationsContainer() {
|
|
|
113
113
|
title: __( 'Default' ),
|
|
114
114
|
settings: {},
|
|
115
115
|
styles: {},
|
|
116
|
+
behaviors: {},
|
|
116
117
|
},
|
|
117
118
|
...( variations ?? [] ).map( ( variation ) => ( {
|
|
118
119
|
...variation,
|
|
119
120
|
settings: variation.settings ?? {},
|
|
120
121
|
styles: variation.styles ?? {},
|
|
122
|
+
behaviors: variation.behaviors ?? {},
|
|
121
123
|
} ) ),
|
|
122
124
|
];
|
|
123
125
|
}, [ variations ] );
|
|
@@ -6,7 +6,7 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { sprintf, __ } from '@wordpress/i18n';
|
|
9
|
+
import { sprintf, __, isRTL } from '@wordpress/i18n';
|
|
10
10
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
11
11
|
import {
|
|
12
12
|
Button,
|
|
@@ -17,7 +17,8 @@ import {
|
|
|
17
17
|
import { BlockIcon } from '@wordpress/block-editor';
|
|
18
18
|
import { store as commandsStore } from '@wordpress/commands';
|
|
19
19
|
import {
|
|
20
|
-
chevronLeftSmall
|
|
20
|
+
chevronLeftSmall,
|
|
21
|
+
chevronRightSmall,
|
|
21
22
|
page as pageIcon,
|
|
22
23
|
navigation as navigationIcon,
|
|
23
24
|
symbol,
|
|
@@ -128,7 +129,10 @@ function TemplateDocumentActions( { className, onBack } ) {
|
|
|
128
129
|
|
|
129
130
|
return (
|
|
130
131
|
<BaseDocumentActions
|
|
131
|
-
className={ className
|
|
132
|
+
className={ classnames( className, {
|
|
133
|
+
'is-synced-entity':
|
|
134
|
+
record.wp_pattern_sync_status !== 'unsynced',
|
|
135
|
+
} ) }
|
|
132
136
|
icon={ typeIcon }
|
|
133
137
|
onBack={ onBack }
|
|
134
138
|
>
|
|
@@ -153,7 +157,7 @@ function BaseDocumentActions( { className, icon, children, onBack } ) {
|
|
|
153
157
|
{ onBack && (
|
|
154
158
|
<Button
|
|
155
159
|
className="edit-site-document-actions__back"
|
|
156
|
-
icon={
|
|
160
|
+
icon={ isRTL() ? chevronRightSmall : chevronLeftSmall }
|
|
157
161
|
onClick={ ( event ) => {
|
|
158
162
|
event.stopPropagation();
|
|
159
163
|
onBack();
|
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
.edit-site-document-actions {
|
|
2
|
-
display:
|
|
3
|
-
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
4
|
height: $button-size;
|
|
5
|
+
justify-content: space-between;
|
|
5
6
|
// Flex items will, by default, refuse to shrink below a minimum
|
|
6
7
|
// intrinsic width. In order to shrink this flexbox item, and
|
|
7
8
|
// subsequently truncate child text, we set an explicit min-width.
|
|
8
9
|
// See https://dev.w3.org/csswg/css-flexbox/#min-size-auto
|
|
9
10
|
min-width: 0;
|
|
10
11
|
background: $gray-100;
|
|
11
|
-
border-radius:
|
|
12
|
+
border-radius: $grid-unit-05;
|
|
12
13
|
width: min(100%, 450px);
|
|
13
|
-
overflow: hidden;
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
// Make the document title shorter in top-toolbar mode, as it has to be covered.
|
|
16
|
+
.has-fixed-toolbar & {
|
|
17
|
+
width: min(100%, 380px);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.components-button {
|
|
21
|
+
border-radius: $grid-unit-05;
|
|
22
|
+
|
|
23
|
+
&:hover {
|
|
24
|
+
color: var(--wp-block-synced-color);
|
|
25
|
+
background: $gray-200;
|
|
26
|
+
}
|
|
18
27
|
}
|
|
19
28
|
|
|
20
29
|
@include break-medium() {
|
|
@@ -24,31 +33,40 @@
|
|
|
24
33
|
@include break-large() {
|
|
25
34
|
width: min(100%, 450px);
|
|
26
35
|
}
|
|
36
|
+
|
|
37
|
+
&.is-synced-entity {
|
|
38
|
+
.edit-site-document-actions__title {
|
|
39
|
+
color: var(--wp-block-synced-color);
|
|
40
|
+
h1 {
|
|
41
|
+
color: var(--wp-block-synced-color);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
27
45
|
}
|
|
28
46
|
|
|
29
47
|
.edit-site-document-actions__command {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
grid-row: 1;
|
|
48
|
+
flex-grow: 1;
|
|
49
|
+
color: var(--wp-block-synced-color);
|
|
50
|
+
overflow: hidden;
|
|
34
51
|
}
|
|
35
52
|
|
|
36
|
-
|
|
37
53
|
.edit-site-document-actions__title {
|
|
38
54
|
flex-grow: 1;
|
|
39
|
-
color: var(--wp-block-synced-color);
|
|
40
55
|
overflow: hidden;
|
|
41
|
-
|
|
56
|
+
|
|
57
|
+
&:hover {
|
|
58
|
+
color: var(--wp-block-synced-color);
|
|
59
|
+
}
|
|
42
60
|
|
|
43
61
|
.block-editor-block-icon {
|
|
44
62
|
min-width: $grid-unit-30;
|
|
63
|
+
flex-shrink: 0;
|
|
45
64
|
}
|
|
46
65
|
|
|
47
66
|
h1 {
|
|
48
67
|
white-space: nowrap;
|
|
49
68
|
overflow: hidden;
|
|
50
69
|
text-overflow: ellipsis;
|
|
51
|
-
color: var(--wp-block-synced-color);
|
|
52
70
|
}
|
|
53
71
|
|
|
54
72
|
.edit-site-document-actions.is-page & {
|
|
@@ -70,26 +88,21 @@
|
|
|
70
88
|
}
|
|
71
89
|
}
|
|
72
90
|
|
|
73
|
-
.edit-site-document-actions__shortcut,
|
|
74
|
-
.edit-site-document-actions__back {
|
|
75
|
-
color: $gray-800;
|
|
76
|
-
|
|
77
|
-
.edit-site-document-actions:hover & {
|
|
78
|
-
color: $gray-900;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
91
|
.edit-site-document-actions__shortcut {
|
|
83
|
-
|
|
92
|
+
color: $gray-800;
|
|
84
93
|
}
|
|
85
94
|
|
|
86
|
-
.edit-site-document-actions__back {
|
|
95
|
+
.edit-site-document-actions__back.components-button.has-icon.has-text {
|
|
87
96
|
min-width: $button-size;
|
|
88
97
|
flex-shrink: 0;
|
|
89
|
-
|
|
90
|
-
|
|
98
|
+
color: $gray-700;
|
|
99
|
+
gap: 0;
|
|
91
100
|
z-index: 1;
|
|
92
101
|
|
|
102
|
+
&:hover {
|
|
103
|
+
color: currentColor;
|
|
104
|
+
}
|
|
105
|
+
|
|
93
106
|
.edit-site-document-actions.is-animated & {
|
|
94
107
|
animation: edit-site-document-actions__slide-in-left 0.3s;
|
|
95
108
|
@include reduce-motion("animation");
|
|
@@ -33,10 +33,8 @@ function KeyboardShortcutsEditMode() {
|
|
|
33
33
|
);
|
|
34
34
|
const { redo, undo } = useDispatch( coreStore );
|
|
35
35
|
const {
|
|
36
|
-
isFeatureActive,
|
|
37
36
|
setIsListViewOpened,
|
|
38
37
|
switchEditorMode,
|
|
39
|
-
toggleFeature,
|
|
40
38
|
setIsInserterOpened,
|
|
41
39
|
closeGeneralSidebar,
|
|
42
40
|
} = useDispatch( editSiteStore );
|
|
@@ -47,7 +45,8 @@ function KeyboardShortcutsEditMode() {
|
|
|
47
45
|
const { getBlockName, getSelectedBlockClientId, getBlockAttributes } =
|
|
48
46
|
useSelect( blockEditorStore );
|
|
49
47
|
|
|
50
|
-
const {
|
|
48
|
+
const { get: getPreference } = useSelect( preferencesStore );
|
|
49
|
+
const { set: setPreference, toggle } = useDispatch( preferencesStore );
|
|
51
50
|
const { createInfoNotice } = useDispatch( noticesStore );
|
|
52
51
|
|
|
53
52
|
const toggleDistractionFree = () => {
|
|
@@ -135,9 +134,9 @@ function KeyboardShortcutsEditMode() {
|
|
|
135
134
|
|
|
136
135
|
useShortcut( 'core/edit-site/toggle-distraction-free', () => {
|
|
137
136
|
toggleDistractionFree();
|
|
138
|
-
|
|
137
|
+
toggle( 'core/edit-site', 'distractionFree' );
|
|
139
138
|
createInfoNotice(
|
|
140
|
-
|
|
139
|
+
getPreference( 'core/edit-site', 'distractionFree' )
|
|
141
140
|
? __( 'Distraction free mode turned on.' )
|
|
142
141
|
: __( 'Distraction free mode turned off.' ),
|
|
143
142
|
{
|
|
@@ -260,28 +260,35 @@ export default function Layout() {
|
|
|
260
260
|
</motion.div>
|
|
261
261
|
|
|
262
262
|
<div className="edit-site-layout__content">
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
transition={ {
|
|
271
|
-
type: 'tween',
|
|
272
|
-
duration:
|
|
273
|
-
// Disable transition in mobile to emulate a full page transition.
|
|
274
|
-
disableMotion || isMobileViewport
|
|
275
|
-
? 0
|
|
276
|
-
: ANIMATION_DURATION,
|
|
277
|
-
ease: 'easeOut',
|
|
278
|
-
} }
|
|
279
|
-
className="edit-site-layout__sidebar"
|
|
263
|
+
{ /*
|
|
264
|
+
The NavigableRegion must always be rendered and not use
|
|
265
|
+
`inert` otherwise `useNavigateRegions` will fail.
|
|
266
|
+
*/ }
|
|
267
|
+
<NavigableRegion
|
|
268
|
+
ariaLabel={ __( 'Navigation' ) }
|
|
269
|
+
className="edit-site-layout__sidebar-region"
|
|
280
270
|
>
|
|
281
|
-
<
|
|
271
|
+
<motion.div
|
|
272
|
+
// The sidebar is needed for routing on mobile
|
|
273
|
+
// (https://github.com/WordPress/gutenberg/pull/51558/files#r1231763003),
|
|
274
|
+
// so we can't remove the element entirely. Using `inert` will make
|
|
275
|
+
// it inaccessible to screen readers and keyboard navigation.
|
|
276
|
+
inert={ showSidebar ? undefined : 'inert' }
|
|
277
|
+
animate={ { opacity: showSidebar ? 1 : 0 } }
|
|
278
|
+
transition={ {
|
|
279
|
+
type: 'tween',
|
|
280
|
+
duration:
|
|
281
|
+
// Disable transition in mobile to emulate a full page transition.
|
|
282
|
+
disableMotion || isMobileViewport
|
|
283
|
+
? 0
|
|
284
|
+
: ANIMATION_DURATION,
|
|
285
|
+
ease: 'easeOut',
|
|
286
|
+
} }
|
|
287
|
+
className="edit-site-layout__sidebar"
|
|
288
|
+
>
|
|
282
289
|
<Sidebar />
|
|
283
|
-
</
|
|
284
|
-
</
|
|
290
|
+
</motion.div>
|
|
291
|
+
</NavigableRegion>
|
|
285
292
|
|
|
286
293
|
<SavePanel />
|
|
287
294
|
|
|
@@ -340,6 +347,12 @@ export default function Layout() {
|
|
|
340
347
|
! isEditorLoading
|
|
341
348
|
}
|
|
342
349
|
isFullWidth={ isEditing }
|
|
350
|
+
defaultSize={ {
|
|
351
|
+
width:
|
|
352
|
+
canvasSize.width -
|
|
353
|
+
24 /* $canvas-padding */,
|
|
354
|
+
height: canvasSize.height,
|
|
355
|
+
} }
|
|
343
356
|
isOversized={
|
|
344
357
|
isResizableFrameOversized
|
|
345
358
|
}
|