-
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.
Merge branch 'master' into feature/heartbeat-autosaving
# Conflicts: # editor/components/provider/index.js
- Loading branch information
Showing
154 changed files
with
2,842 additions
and
2,015 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
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,13 +1,25 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Toolbar, Fill } from '@wordpress/components'; | ||
|
||
export default function BlockControls( { controls, children } ) { | ||
return ( | ||
<Fill name="Block.Toolbar"> | ||
<Toolbar controls={ controls } /> | ||
{ children } | ||
</Fill> | ||
); | ||
} | ||
import { createSlotFill, Toolbar } from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { ifBlockEditSelected } from '../block-edit/context'; | ||
|
||
const Fill = createSlotFill( 'BlockControls' ); | ||
const { Slot } = Fill; | ||
|
||
const BlockControlsFill = ( { controls, children } ) => ( | ||
<Fill> | ||
<Toolbar controls={ controls } /> | ||
{ children } | ||
</Fill> | ||
); | ||
|
||
const BlockControls = ifBlockEditSelected( BlockControlsFill ); | ||
|
||
BlockControls.Slot = Slot; | ||
|
||
export default BlockControls; |
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { createContext, createHigherOrderComponent } from '@wordpress/element'; | ||
|
||
const { Consumer, Provider } = createContext( { | ||
isSelected: true, | ||
} ); | ||
|
||
export { Provider as BlockEditContextProvider }; | ||
|
||
/** | ||
* A Higher Order Component used to inject BlockEdit context to the | ||
* wrapped component. | ||
* | ||
* @param {Component} OriginalComponent Component to wrap. | ||
* | ||
* @return {Component} Component which has BlockEdit context injected. | ||
*/ | ||
export const withBlockEditContext = createHigherOrderComponent( ( OriginalComponent ) => { | ||
return ( props ) => ( | ||
<Consumer> | ||
{ ( context ) => ( | ||
<OriginalComponent | ||
{ ...props } | ||
blockEditContext={ context } | ||
/> | ||
) } | ||
</Consumer> | ||
); | ||
}, 'withBlockEditContext' ); | ||
|
||
/** | ||
* A Higher Order Component used to render conditionally the wrapped | ||
* component only when the BlockEdit has selected state set. | ||
* | ||
* @param {Component} OriginalComponent Component to wrap. | ||
* | ||
* @return {Component} Component which renders only when the BlockEdit is selected. | ||
*/ | ||
export const ifBlockEditSelected = createHigherOrderComponent( ( OriginalComponent ) => { | ||
return ( props ) => ( | ||
<Consumer> | ||
{ ( { isSelected } ) => isSelected && ( | ||
<OriginalComponent { ...props } /> | ||
) } | ||
</Consumer> | ||
); | ||
}, 'ifBlockEditSelected' ); |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { createSlotFill } from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { ifBlockEditSelected } from '../block-edit/context'; | ||
|
||
const Fill = createSlotFill( 'BlockFormatControls' ); | ||
const { Slot } = Fill; | ||
|
||
const BlockFormatControls = ifBlockEditSelected( Fill ); | ||
|
||
BlockFormatControls.Slot = Slot; | ||
|
||
export default BlockFormatControls; |
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.