-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Move the reusable blocks buttons to the editor module #14387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
youknowriad
merged 5 commits into
master
from
update/move-reusable-block-buttons-to-editor
Mar 26, 2019
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d6cc405
This PR moves the reusable blocks buttons to the editor module
youknowriad a342b85
Fix unit tests
youknowriad c6854a0
Tweaks to the selectors based on the reviews
youknowriad 4501bad
rename experimental slots using our code convention
youknowriad 1ffcefc
Add unit tests for getSelectedBlockClientIds
youknowriad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -560,26 +560,29 @@ export function getSelectedBlocksInitialCaretPosition( state ) { | |
| } | ||
|
|
||
| /** | ||
| * Returns the current multi-selection set of block client IDs, or an empty | ||
| * array if there is no multi-selection. | ||
| * Returns the current selection set of block client IDs (multiselection or single selection). | ||
| * | ||
| * @param {Object} state Editor state. | ||
| * | ||
| * @return {Array} Multi-selected block client IDs. | ||
| */ | ||
| export const getMultiSelectedBlockClientIds = createSelector( | ||
| export const getSelectedBlockClientIds = createSelector( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could do for some separate unit tests to distinguish the two functions. Aside: This selector function confuses me as to what its doing with the slices and root traversal below. |
||
| ( state ) => { | ||
| const { start, end } = state.blockSelection; | ||
| if ( start === null || end === null ) { | ||
| return EMPTY_ARRAY; | ||
| } | ||
|
|
||
| if ( start === end ) { | ||
| return []; | ||
| return [ start ]; | ||
| } | ||
|
|
||
| // Retrieve root client ID to aid in retrieving relevant nested block | ||
| // order, being careful to allow the falsey empty string top-level root | ||
| // by explicitly testing against null. | ||
| const rootClientId = getBlockRootClientId( state, start ); | ||
| if ( rootClientId === null ) { | ||
| return []; | ||
| return EMPTY_ARRAY; | ||
| } | ||
|
|
||
| const blockOrder = getBlockOrder( state, rootClientId ); | ||
|
|
@@ -599,6 +602,23 @@ export const getMultiSelectedBlockClientIds = createSelector( | |
| ], | ||
| ); | ||
|
|
||
| /** | ||
| * Returns the current multi-selection set of block client IDs, or an empty | ||
| * array if there is no multi-selection. | ||
| * | ||
| * @param {Object} state Editor state. | ||
| * | ||
| * @return {Array} Multi-selected block client IDs. | ||
| */ | ||
| export function getMultiSelectedBlockClientIds( state ) { | ||
| const { start, end } = state.blockSelection; | ||
| if ( start === end ) { | ||
| return EMPTY_ARRAY; | ||
| } | ||
|
|
||
| return getSelectedBlockClientIds( state ); | ||
youknowriad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /** | ||
| * Returns the current multi-selection set of blocks, or an empty array if | ||
| * there is no multi-selection. | ||
|
|
@@ -617,7 +637,7 @@ export const getMultiSelectedBlocks = createSelector( | |
| return multiSelectedBlockClientIds.map( ( clientId ) => getBlock( state, clientId ) ); | ||
| }, | ||
| ( state ) => [ | ||
| ...getMultiSelectedBlockClientIds.getDependants( state ), | ||
| ...getSelectedBlockClientIds.getDependants( state ), | ||
youknowriad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| state.blocks.byClientId, | ||
| state.blocks.order, | ||
| state.blocks.attributes, | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess with this change, "Remove from Reusable Blocks" is moved to before the horizontal line in the menu, ungrouped from Remove Block. I don't see it being much an issue (grouped with reusable convert button vs. grouped with remove block button), but worth pointing out.