@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
|
@@ -58,10 +58,7 @@ export default function useSyncCanvasModeWithURL() {
|
|
|
58
58
|
|
|
59
59
|
useEffect( () => {
|
|
60
60
|
currentCanvasInUrl.current = canvasInUrl;
|
|
61
|
-
if (
|
|
62
|
-
canvasInUrl === undefined &&
|
|
63
|
-
currentCanvasMode.current !== 'view'
|
|
64
|
-
) {
|
|
61
|
+
if ( canvasInUrl !== 'edit' && currentCanvasMode.current !== 'view' ) {
|
|
65
62
|
setCanvasMode( 'view' );
|
|
66
63
|
} else if (
|
|
67
64
|
canvasInUrl === 'edit' &&
|
|
@@ -114,13 +114,68 @@ function useGlobalStylesOpenCssCommands() {
|
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
function useGlobalStylesOpenRevisionsCommands() {
|
|
118
118
|
const { openGeneralSidebar, setEditorCanvasContainerView, setCanvasMode } =
|
|
119
119
|
unlock( useDispatch( editSiteStore ) );
|
|
120
|
+
const { getCanvasMode } = unlock( useSelect( editSiteStore ) );
|
|
120
121
|
const { params } = useLocation();
|
|
121
122
|
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
122
|
-
const
|
|
123
|
-
const
|
|
123
|
+
const isEditorPage = ! getIsListPage( params, isMobileViewport );
|
|
124
|
+
const history = useHistory();
|
|
125
|
+
const hasRevisions = useSelect(
|
|
126
|
+
( select ) =>
|
|
127
|
+
select( coreStore ).getCurrentThemeGlobalStylesRevisions()?.length,
|
|
128
|
+
[]
|
|
129
|
+
);
|
|
130
|
+
const commands = useMemo( () => {
|
|
131
|
+
if ( ! hasRevisions ) {
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return [
|
|
136
|
+
{
|
|
137
|
+
name: 'core/edit-site/open-global-styles-revisions',
|
|
138
|
+
label: __( 'Open styles revisions' ),
|
|
139
|
+
icon: backup,
|
|
140
|
+
callback: ( { close } ) => {
|
|
141
|
+
close();
|
|
142
|
+
if ( ! isEditorPage ) {
|
|
143
|
+
history.push( {
|
|
144
|
+
path: '/wp_global_styles',
|
|
145
|
+
canvas: 'edit',
|
|
146
|
+
} );
|
|
147
|
+
}
|
|
148
|
+
if ( isEditorPage && getCanvasMode() !== 'edit' ) {
|
|
149
|
+
setCanvasMode( 'edit' );
|
|
150
|
+
}
|
|
151
|
+
openGeneralSidebar( 'edit-site/global-styles' );
|
|
152
|
+
setEditorCanvasContainerView( 'global-styles-revisions' );
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
];
|
|
156
|
+
}, [
|
|
157
|
+
hasRevisions,
|
|
158
|
+
history,
|
|
159
|
+
openGeneralSidebar,
|
|
160
|
+
setEditorCanvasContainerView,
|
|
161
|
+
isEditorPage,
|
|
162
|
+
getCanvasMode,
|
|
163
|
+
setCanvasMode,
|
|
164
|
+
] );
|
|
165
|
+
|
|
166
|
+
return {
|
|
167
|
+
isLoading: false,
|
|
168
|
+
commands,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function useCommonCommands() {
|
|
173
|
+
const { openGeneralSidebar, setCanvasMode } = unlock(
|
|
174
|
+
useDispatch( editSiteStore )
|
|
175
|
+
);
|
|
176
|
+
const { params } = useLocation();
|
|
177
|
+
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
178
|
+
const isEditorPage = ! getIsListPage( params, isMobileViewport );
|
|
124
179
|
const { getCanvasMode } = unlock( useSelect( editSiteStore ) );
|
|
125
180
|
const { set } = useDispatch( preferencesStore );
|
|
126
181
|
const { createInfoNotice } = useDispatch( noticesStore );
|
|
@@ -139,26 +194,6 @@ export function useCommonCommands() {
|
|
|
139
194
|
};
|
|
140
195
|
}, [] );
|
|
141
196
|
|
|
142
|
-
useCommand( {
|
|
143
|
-
name: 'core/edit-site/open-global-styles-revisions',
|
|
144
|
-
label: __( 'Open styles revisions' ),
|
|
145
|
-
icon: backup,
|
|
146
|
-
callback: ( { close } ) => {
|
|
147
|
-
close();
|
|
148
|
-
if ( ! isEditorPage ) {
|
|
149
|
-
history.push( {
|
|
150
|
-
path: '/wp_global_styles',
|
|
151
|
-
canvas: 'edit',
|
|
152
|
-
} );
|
|
153
|
-
}
|
|
154
|
-
if ( isEditorPage && getCanvasMode() !== 'edit' ) {
|
|
155
|
-
setCanvasMode( 'edit' );
|
|
156
|
-
}
|
|
157
|
-
openGeneralSidebar( 'edit-site/global-styles' );
|
|
158
|
-
setEditorCanvasContainerView( 'global-styles-revisions' );
|
|
159
|
-
},
|
|
160
|
-
} );
|
|
161
|
-
|
|
162
197
|
useCommand( {
|
|
163
198
|
name: 'core/edit-site/open-styles',
|
|
164
199
|
label: __( 'Open styles' ),
|
|
@@ -228,4 +263,9 @@ export function useCommonCommands() {
|
|
|
228
263
|
name: 'core/edit-site/open-styles-css',
|
|
229
264
|
hook: useGlobalStylesOpenCssCommands,
|
|
230
265
|
} );
|
|
266
|
+
|
|
267
|
+
useCommandLoader( {
|
|
268
|
+
name: 'core/edit-site/open-styles-revisions',
|
|
269
|
+
hook: useGlobalStylesOpenRevisionsCommands,
|
|
270
|
+
} );
|
|
231
271
|
}
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
-
import { __, isRTL } from '@wordpress/i18n';
|
|
5
|
+
import { __, sprintf, isRTL } from '@wordpress/i18n';
|
|
6
6
|
import {
|
|
7
7
|
trash,
|
|
8
|
-
|
|
8
|
+
rotateLeft,
|
|
9
|
+
rotateRight,
|
|
9
10
|
layout,
|
|
10
11
|
page,
|
|
11
12
|
drawerLeft,
|
|
@@ -13,12 +14,14 @@ import {
|
|
|
13
14
|
blockDefault,
|
|
14
15
|
cog,
|
|
15
16
|
code,
|
|
16
|
-
|
|
17
|
+
keyboard,
|
|
17
18
|
} from '@wordpress/icons';
|
|
18
19
|
import { useCommandLoader } from '@wordpress/commands';
|
|
20
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
19
21
|
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
20
22
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
21
23
|
import { store as interfaceStore } from '@wordpress/interface';
|
|
24
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
22
25
|
|
|
23
26
|
/**
|
|
24
27
|
* Internal dependencies
|
|
@@ -34,6 +37,7 @@ import { unlock } from '../../lock-unlock';
|
|
|
34
37
|
const { useHistory } = unlock( routerPrivateApis );
|
|
35
38
|
|
|
36
39
|
function usePageContentFocusCommands() {
|
|
40
|
+
const { record: template } = useEditedEntityRecord();
|
|
37
41
|
const { isPage, canvasMode, hasPageContentFocus } = useSelect(
|
|
38
42
|
( select ) => ( {
|
|
39
43
|
isPage: select( editSiteStore ).isPage(),
|
|
@@ -53,7 +57,11 @@ function usePageContentFocusCommands() {
|
|
|
53
57
|
if ( hasPageContentFocus ) {
|
|
54
58
|
commands.push( {
|
|
55
59
|
name: 'core/switch-to-template-focus',
|
|
56
|
-
|
|
60
|
+
/* translators: %1$s: template title */
|
|
61
|
+
label: sprintf(
|
|
62
|
+
'Edit template: %s',
|
|
63
|
+
decodeEntities( template.title )
|
|
64
|
+
),
|
|
57
65
|
icon: layout,
|
|
58
66
|
callback: ( { close } ) => {
|
|
59
67
|
setHasPageContentFocus( false );
|
|
@@ -93,12 +101,20 @@ function useManipulateDocumentCommands() {
|
|
|
93
101
|
if ( isTemplateRevertable( template ) && ! hasPageContentFocus ) {
|
|
94
102
|
const label =
|
|
95
103
|
template.type === 'wp_template'
|
|
96
|
-
?
|
|
97
|
-
|
|
104
|
+
? /* translators: %1$s: template title */
|
|
105
|
+
sprintf(
|
|
106
|
+
'Reset template: %s',
|
|
107
|
+
decodeEntities( template.title )
|
|
108
|
+
)
|
|
109
|
+
: /* translators: %1$s: template part title */
|
|
110
|
+
sprintf(
|
|
111
|
+
'Reset template part: %s',
|
|
112
|
+
decodeEntities( template.title )
|
|
113
|
+
);
|
|
98
114
|
commands.push( {
|
|
99
115
|
name: 'core/reset-template',
|
|
100
116
|
label,
|
|
101
|
-
icon:
|
|
117
|
+
icon: isRTL() ? rotateRight : rotateLeft,
|
|
102
118
|
callback: ( { close } ) => {
|
|
103
119
|
revertTemplate( template );
|
|
104
120
|
close();
|
|
@@ -109,8 +125,16 @@ function useManipulateDocumentCommands() {
|
|
|
109
125
|
if ( isTemplateRemovable( template ) && ! hasPageContentFocus ) {
|
|
110
126
|
const label =
|
|
111
127
|
template.type === 'wp_template'
|
|
112
|
-
?
|
|
113
|
-
|
|
128
|
+
? /* translators: %1$s: template title */
|
|
129
|
+
sprintf(
|
|
130
|
+
'Delete template: %s',
|
|
131
|
+
decodeEntities( template.title )
|
|
132
|
+
)
|
|
133
|
+
: /* translators: %1$s: template part title */
|
|
134
|
+
sprintf(
|
|
135
|
+
'Delete template part: %s',
|
|
136
|
+
decodeEntities( template.title )
|
|
137
|
+
);
|
|
114
138
|
const path =
|
|
115
139
|
template.type === 'wp_template'
|
|
116
140
|
? '/wp_template'
|
|
@@ -137,20 +161,32 @@ function useManipulateDocumentCommands() {
|
|
|
137
161
|
}
|
|
138
162
|
|
|
139
163
|
function useEditUICommands() {
|
|
140
|
-
const {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
164
|
+
const {
|
|
165
|
+
openGeneralSidebar,
|
|
166
|
+
closeGeneralSidebar,
|
|
167
|
+
setIsInserterOpened,
|
|
168
|
+
setIsListViewOpened,
|
|
169
|
+
switchEditorMode,
|
|
170
|
+
} = useDispatch( editSiteStore );
|
|
171
|
+
const { canvasMode, editorMode, activeSidebar, showBlockBreadcrumbs } =
|
|
172
|
+
useSelect(
|
|
173
|
+
( select ) => ( {
|
|
174
|
+
canvasMode: unlock( select( editSiteStore ) ).getCanvasMode(),
|
|
175
|
+
editorMode: select( editSiteStore ).getEditorMode(),
|
|
176
|
+
activeSidebar: select(
|
|
177
|
+
interfaceStore
|
|
178
|
+
).getActiveComplementaryArea( editSiteStore.name ),
|
|
179
|
+
showBlockBreadcrumbs: select( preferencesStore ).get(
|
|
180
|
+
'core/edit-site',
|
|
181
|
+
'showBlockBreadcrumbs'
|
|
182
|
+
),
|
|
183
|
+
} ),
|
|
184
|
+
[]
|
|
185
|
+
);
|
|
152
186
|
const { openModal } = useDispatch( interfaceStore );
|
|
153
|
-
const {
|
|
187
|
+
const { get: getPreference } = useSelect( preferencesStore );
|
|
188
|
+
const { set: setPreference, toggle } = useDispatch( preferencesStore );
|
|
189
|
+
const { createInfoNotice } = useDispatch( noticesStore );
|
|
154
190
|
|
|
155
191
|
if ( canvasMode !== 'edit' ) {
|
|
156
192
|
return { isLoading: false, commands: [] };
|
|
@@ -196,6 +232,29 @@ function useEditUICommands() {
|
|
|
196
232
|
},
|
|
197
233
|
} );
|
|
198
234
|
|
|
235
|
+
commands.push( {
|
|
236
|
+
name: 'core/toggle-distraction-free',
|
|
237
|
+
label: __( 'Toggle distraction free' ),
|
|
238
|
+
icon: cog,
|
|
239
|
+
callback: ( { close } ) => {
|
|
240
|
+
setPreference( 'core/edit-site', 'fixedToolbar', false );
|
|
241
|
+
setIsInserterOpened( false );
|
|
242
|
+
setIsListViewOpened( false );
|
|
243
|
+
closeGeneralSidebar();
|
|
244
|
+
toggle( 'core/edit-site', 'distractionFree' );
|
|
245
|
+
createInfoNotice(
|
|
246
|
+
getPreference( 'core/edit-site', 'distractionFree' )
|
|
247
|
+
? __( 'Distraction free mode turned on.' )
|
|
248
|
+
: __( 'Distraction free mode turned off.' ),
|
|
249
|
+
{
|
|
250
|
+
id: 'core/edit-site/distraction-free-mode/notice',
|
|
251
|
+
type: 'snackbar',
|
|
252
|
+
}
|
|
253
|
+
);
|
|
254
|
+
close();
|
|
255
|
+
},
|
|
256
|
+
} );
|
|
257
|
+
|
|
199
258
|
commands.push( {
|
|
200
259
|
name: 'core/toggle-top-toolbar',
|
|
201
260
|
label: __( 'Toggle top toolbar' ),
|
|
@@ -228,12 +287,24 @@ function useEditUICommands() {
|
|
|
228
287
|
commands.push( {
|
|
229
288
|
name: 'core/open-shortcut-help',
|
|
230
289
|
label: __( 'Open keyboard shortcuts' ),
|
|
231
|
-
icon:
|
|
290
|
+
icon: keyboard,
|
|
232
291
|
callback: () => {
|
|
233
292
|
openModal( KEYBOARD_SHORTCUT_HELP_MODAL_NAME );
|
|
234
293
|
},
|
|
235
294
|
} );
|
|
236
295
|
|
|
296
|
+
commands.push( {
|
|
297
|
+
name: 'core/toggle-breadcrumbs',
|
|
298
|
+
label: showBlockBreadcrumbs
|
|
299
|
+
? __( 'Hide block breadcrumbs' )
|
|
300
|
+
: __( 'Show block breadcrumbs' ),
|
|
301
|
+
icon: cog,
|
|
302
|
+
callback: ( { close } ) => {
|
|
303
|
+
toggle( 'core/edit-site', 'showBlockBreadcrumbs' );
|
|
304
|
+
close();
|
|
305
|
+
},
|
|
306
|
+
} );
|
|
307
|
+
|
|
237
308
|
return {
|
|
238
309
|
isLoading: false,
|
|
239
310
|
commands,
|
|
@@ -25,9 +25,12 @@ import { store as noticesStore } from '@wordpress/notices';
|
|
|
25
25
|
import { useSupportedStyles } from '../../components/global-styles/hooks';
|
|
26
26
|
import { unlock } from '../../lock-unlock';
|
|
27
27
|
|
|
28
|
-
const {
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const {
|
|
29
|
+
GlobalStylesContext,
|
|
30
|
+
useBlockEditingMode,
|
|
31
|
+
__experimentalUseGlobalBehaviors: useGlobalBehaviors,
|
|
32
|
+
__experimentalUseHasBehaviorsPanel: useHasBehaviorsPanel,
|
|
33
|
+
} = unlock( blockEditorPrivateApis );
|
|
31
34
|
|
|
32
35
|
// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be
|
|
33
36
|
// removed by moving PushChangesToGlobalStylesControl to
|
|
@@ -121,7 +124,7 @@ function useChangesToPush( name, attributes ) {
|
|
|
121
124
|
: getValueFromObjectPath( attributes.style, path );
|
|
122
125
|
return value ? [ { path, value } ] : [];
|
|
123
126
|
} ),
|
|
124
|
-
[ supports,
|
|
127
|
+
[ supports, attributes ]
|
|
125
128
|
);
|
|
126
129
|
}
|
|
127
130
|
|
|
@@ -176,6 +179,9 @@ function PushChangesToGlobalStylesControl( {
|
|
|
176
179
|
} ) {
|
|
177
180
|
const changes = useChangesToPush( name, attributes );
|
|
178
181
|
|
|
182
|
+
const hasBehaviorsPanel = useHasBehaviorsPanel( attributes, name, {
|
|
183
|
+
blockSupportOnly: true,
|
|
184
|
+
} );
|
|
179
185
|
const { user: userConfig, setUserConfig } =
|
|
180
186
|
useContext( GlobalStylesContext );
|
|
181
187
|
|
|
@@ -183,55 +189,86 @@ function PushChangesToGlobalStylesControl( {
|
|
|
183
189
|
useDispatch( blockEditorStore );
|
|
184
190
|
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
185
191
|
|
|
192
|
+
const { inheritedBehaviors, setBehavior } = useGlobalBehaviors( name );
|
|
193
|
+
|
|
194
|
+
const userHasEditedBehaviors =
|
|
195
|
+
attributes.hasOwnProperty( 'behaviors' ) && hasBehaviorsPanel;
|
|
196
|
+
|
|
186
197
|
const pushChanges = useCallback( () => {
|
|
187
|
-
if ( changes.length === 0 ) {
|
|
198
|
+
if ( changes.length === 0 && ! userHasEditedBehaviors ) {
|
|
188
199
|
return;
|
|
189
200
|
}
|
|
201
|
+
if ( changes.length > 0 ) {
|
|
202
|
+
const { style: blockStyles } = attributes;
|
|
190
203
|
|
|
191
|
-
|
|
204
|
+
const newBlockStyles = cloneDeep( blockStyles );
|
|
205
|
+
const newUserConfig = cloneDeep( userConfig );
|
|
192
206
|
|
|
193
|
-
|
|
194
|
-
|
|
207
|
+
for ( const { path, value } of changes ) {
|
|
208
|
+
setNestedValue( newBlockStyles, path, undefined );
|
|
209
|
+
setNestedValue(
|
|
210
|
+
newUserConfig,
|
|
211
|
+
[ 'styles', 'blocks', name, ...path ],
|
|
212
|
+
value
|
|
213
|
+
);
|
|
214
|
+
}
|
|
195
215
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
216
|
+
// @wordpress/core-data doesn't support editing multiple entity types in
|
|
217
|
+
// a single undo level. So for now, we disable @wordpress/core-data undo
|
|
218
|
+
// tracking and implement our own Undo button in the snackbar
|
|
219
|
+
// notification.
|
|
220
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
221
|
+
setAttributes( { style: newBlockStyles } );
|
|
222
|
+
setUserConfig( () => newUserConfig, { undoIgnore: true } );
|
|
223
|
+
createSuccessNotice(
|
|
224
|
+
sprintf(
|
|
225
|
+
// translators: %s: Title of the block e.g. 'Heading'.
|
|
226
|
+
__( '%s styles applied.' ),
|
|
227
|
+
getBlockType( name ).title
|
|
228
|
+
),
|
|
229
|
+
{
|
|
230
|
+
type: 'snackbar',
|
|
231
|
+
actions: [
|
|
232
|
+
{
|
|
233
|
+
label: __( 'Undo' ),
|
|
234
|
+
onClick() {
|
|
235
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
236
|
+
setAttributes( { style: blockStyles } );
|
|
237
|
+
setUserConfig( () => userConfig, {
|
|
238
|
+
undoIgnore: true,
|
|
239
|
+
} );
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
}
|
|
202
244
|
);
|
|
203
245
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
__unstableMarkNextChangeAsNotPersistent();
|
|
226
|
-
setAttributes( { style: blockStyles } );
|
|
227
|
-
setUserConfig( () => userConfig, {
|
|
228
|
-
undoIgnore: true,
|
|
229
|
-
} );
|
|
246
|
+
if ( userHasEditedBehaviors ) {
|
|
247
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
248
|
+
setBehavior( attributes.behaviors );
|
|
249
|
+
createSuccessNotice(
|
|
250
|
+
sprintf(
|
|
251
|
+
// translators: %s: Title of the block e.g. 'Heading'.
|
|
252
|
+
__( '%s behaviors applied.' ),
|
|
253
|
+
getBlockType( name ).title
|
|
254
|
+
),
|
|
255
|
+
{
|
|
256
|
+
type: 'snackbar',
|
|
257
|
+
actions: [
|
|
258
|
+
{
|
|
259
|
+
label: __( 'Undo' ),
|
|
260
|
+
onClick() {
|
|
261
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
262
|
+
setBehavior( inheritedBehaviors );
|
|
263
|
+
setUserConfig( () => userConfig, {
|
|
264
|
+
undoIgnore: true,
|
|
265
|
+
} );
|
|
266
|
+
},
|
|
230
267
|
},
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
268
|
+
],
|
|
269
|
+
}
|
|
270
|
+
);
|
|
271
|
+
}
|
|
235
272
|
}, [ changes, attributes, userConfig, name ] );
|
|
236
273
|
|
|
237
274
|
return (
|
|
@@ -240,7 +277,7 @@ function PushChangesToGlobalStylesControl( {
|
|
|
240
277
|
help={ sprintf(
|
|
241
278
|
// translators: %s: Title of the block e.g. 'Heading'.
|
|
242
279
|
__(
|
|
243
|
-
'Apply this block’s typography, spacing, dimensions,
|
|
280
|
+
'Apply this block’s typography, spacing, dimensions, color styles, and behaviors to all %s blocks.'
|
|
244
281
|
),
|
|
245
282
|
getBlockType( name ).title
|
|
246
283
|
) }
|
|
@@ -250,7 +287,7 @@ function PushChangesToGlobalStylesControl( {
|
|
|
250
287
|
</BaseControl.VisualLabel>
|
|
251
288
|
<Button
|
|
252
289
|
variant="primary"
|
|
253
|
-
disabled={ changes.length === 0 }
|
|
290
|
+
disabled={ changes.length === 0 && ! userHasEditedBehaviors }
|
|
254
291
|
onClick={ pushChanges }
|
|
255
292
|
>
|
|
256
293
|
{ __( 'Apply globally' ) }
|
|
@@ -18,11 +18,15 @@ export const setCanvasMode =
|
|
|
18
18
|
mode,
|
|
19
19
|
} );
|
|
20
20
|
// Check if the block list view should be open by default.
|
|
21
|
+
// If `distractionFree` mode is enabled, the block list view should not be open.
|
|
21
22
|
if (
|
|
22
23
|
mode === 'edit' &&
|
|
23
24
|
registry
|
|
24
25
|
.select( preferencesStore )
|
|
25
|
-
.get( 'core/edit-site', 'showListViewByDefault' )
|
|
26
|
+
.get( 'core/edit-site', 'showListViewByDefault' ) &&
|
|
27
|
+
! registry
|
|
28
|
+
.select( preferencesStore )
|
|
29
|
+
.get( 'core/edit-site', 'distractionFree' )
|
|
26
30
|
) {
|
|
27
31
|
dispatch.setIsListViewOpened( true );
|
|
28
32
|
}
|
|
@@ -6,12 +6,13 @@ import { useDebounce } from '@wordpress/compose';
|
|
|
6
6
|
|
|
7
7
|
export default function useDebouncedInput( defaultValue = '' ) {
|
|
8
8
|
const [ input, setInput ] = useState( defaultValue );
|
|
9
|
-
const [
|
|
10
|
-
|
|
9
|
+
const [ debouncedInput, setDebouncedState ] = useState( defaultValue );
|
|
10
|
+
|
|
11
|
+
const setDebouncedInput = useDebounce( setDebouncedState, 250 );
|
|
12
|
+
|
|
11
13
|
useEffect( () => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return [ input, setInput, debounced ];
|
|
14
|
+
setDebouncedInput( input );
|
|
15
|
+
}, [ input ] );
|
|
16
|
+
|
|
17
|
+
return [ input, setInput, debouncedInput ];
|
|
17
18
|
}
|