-
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.
Classic Block: Move the convert to blocks option from menu to own too…
…lbar button (#23704) * Move the convert to blocks option from menu to own toolbar button * Make convert to block buttons a separate component * implement new convert-to-blocks-button component * Add dependency to useSelect hook Co-authored-by: Riad Benguella <benguella@gmail.com> * change button casing * put default export back * Move toolbar component back to edit * Update end-to-end tests. * Remove obsolete title * Add fix for e2e test * Remove space from type check * Change wording of arguments * Revise clickBlockToolbarButton param names again. * Clearer types in JSDoc. * Update test to match changes in helper args Co-authored-by: Glen Davies <glen.davies@a8c.com> Co-authored-by: Ben Dwyer <ben@scruffian.com> Co-authored-by: Riad Benguella <benguella@gmail.com> Co-authored-by: Zebulan Stanphill <zebulanstanphill@protonmail.com>
- Loading branch information
1 parent
5943777
commit 8bb3c97
Showing
7 changed files
with
81 additions
and
67 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
34 changes: 0 additions & 34 deletions
34
packages/block-editor/src/components/block-settings-menu/block-unknown-convert-button.js
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
packages/block-library/src/classic/convert-to-blocks-button.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,32 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { ToolbarButton } from '@wordpress/components'; | ||
import { useDispatch, useSelect } from '@wordpress/data'; | ||
import { rawHandler, serialize } from '@wordpress/blocks'; | ||
|
||
const ConvertToBlocksButton = ( { clientId } ) => { | ||
const { replaceBlocks } = useDispatch( 'core/block-editor' ); | ||
const block = useSelect( | ||
( select ) => { | ||
return select( 'core/block-editor' ).getBlock( clientId ); | ||
}, | ||
[ clientId ] | ||
); | ||
|
||
return ( | ||
<ToolbarButton | ||
onClick={ () => | ||
replaceBlocks( | ||
block.clientId, | ||
rawHandler( { HTML: serialize( block ) } ) | ||
) | ||
} | ||
> | ||
{ __( 'Convert to blocks' ) } | ||
</ToolbarButton> | ||
); | ||
}; | ||
|
||
export default ConvertToBlocksButton; |
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