forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Editor: Move editor toggle commands to the editor package (WordPress#…
…62093) Co-authored-by: youknowriad <youknowriad@git.wordpress.org> Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
- Loading branch information
1 parent
45659c9
commit 8a4f14c
Showing
5 changed files
with
114 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useSelect, useDispatch } from '@wordpress/data'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { fullscreen } from '@wordpress/icons'; | ||
import { useCommand } from '@wordpress/commands'; | ||
import { store as preferencesStore } from '@wordpress/preferences'; | ||
import { store as noticesStore } from '@wordpress/notices'; | ||
|
||
export default function useCommands() { | ||
const { isFullscreen } = useSelect( ( select ) => { | ||
const { get } = select( preferencesStore ); | ||
|
||
return { | ||
isFullscreen: get( 'core/edit-post', 'fullscreenMode' ), | ||
}; | ||
}, [] ); | ||
const { toggle } = useDispatch( preferencesStore ); | ||
const { createInfoNotice } = useDispatch( noticesStore ); | ||
|
||
useCommand( { | ||
name: 'core/toggle-fullscreen-mode', | ||
label: isFullscreen | ||
? __( 'Exit fullscreen' ) | ||
: __( 'Enter fullscreen' ), | ||
icon: fullscreen, | ||
callback: ( { close } ) => { | ||
toggle( 'core/edit-post', 'fullscreenMode' ); | ||
close(); | ||
createInfoNotice( | ||
isFullscreen ? __( 'Fullscreen off.' ) : __( 'Fullscreen on.' ), | ||
{ | ||
id: 'core/edit-post/toggle-fullscreen-mode/notice', | ||
type: 'snackbar', | ||
actions: [ | ||
{ | ||
label: __( 'Undo' ), | ||
onClick: () => { | ||
toggle( 'core/edit-post', 'fullscreenMode' ); | ||
}, | ||
}, | ||
], | ||
} | ||
); | ||
}, | ||
} ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 0 additions & 126 deletions
126
packages/edit-post/src/hooks/commands/use-common-commands.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters