-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
270 additions
and
429 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
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
31 changes: 31 additions & 0 deletions
31
packages/block-editor/src/components/block-tools/back-compat.js
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,31 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useContext } from '@wordpress/element'; | ||
import deprecated from '@wordpress/deprecated'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import InsertionPoint, { InsertionPointOpenRef } from './insertion-point'; | ||
import BlockPopover from './block-popover'; | ||
|
||
export default function BlockToolsBackCompat( { children } ) { | ||
const openRef = useContext( InsertionPointOpenRef ); | ||
|
||
// If context is set, `BlockTools` is a parent component. | ||
if ( openRef ) { | ||
return children; | ||
} | ||
|
||
deprecated( 'wp.components.Popover.Slot name="block-toolbar"', { | ||
alternative: 'wp.blockEditor.BlockTools', | ||
} ); | ||
|
||
return ( | ||
<InsertionPoint __unstablePopoverSlot="block-toolbar"> | ||
<BlockPopover __unstablePopoverSlot="block-toolbar" /> | ||
{ children } | ||
</InsertionPoint> | ||
); | ||
} |
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
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 |
---|---|---|
@@ -1,14 +1,46 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useSelect } from '@wordpress/data'; | ||
import { useViewportMatch } from '@wordpress/compose'; | ||
import { Popover } from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import InsertionPoint from './insertion-point'; | ||
import BlockPopover from './block-popover'; | ||
import { store as blockEditorStore } from '../../store'; | ||
import BlockContextualToolbar from './block-contextual-toolbar'; | ||
|
||
/** | ||
* Renders block tools (the block toolbar, select/navigation mode toolbar, the | ||
* insertion point and a slot for the inline rich text toolbar). Must be wrapped | ||
* around the block content and editor styles wrapper or iframe. | ||
* | ||
* @param {Object} $0 Props. | ||
* @param {Object} $0.children The block content and style container. | ||
*/ | ||
export default function BlockTools( { children } ) { | ||
const isLargeViewport = useViewportMatch( 'medium' ); | ||
const hasFixedToolbar = useSelect( | ||
( select ) => select( blockEditorStore ).getSettings().hasFixedToolbar, | ||
[] | ||
); | ||
|
||
return ( | ||
<InsertionPoint> | ||
{ ( hasFixedToolbar || ! isLargeViewport ) && ( | ||
<BlockContextualToolbar isFixed /> | ||
) } | ||
{ /* Even if the toolbar is fixed, the block popover is still | ||
needed for navigation mode. */ } | ||
<BlockPopover /> | ||
{ /* Used for the inline rich text toolbar. */ } | ||
<Popover.Slot name="block-toolbar" /> | ||
{ children } | ||
{ /* Forward compatibility: a place to render block tools behind the | ||
content so it can be tabbed to properly. */ } | ||
</InsertionPoint> | ||
); | ||
} |
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
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
Oops, something went wrong.