@gechiui/block-editor
Version:
31 lines (27 loc) • 786 B
JavaScript
/**
* GeChiUI dependencies
*/
import { rawHandler, getBlockContent } from '@gechiui/blocks';
import { compose } from '@gechiui/compose';
import { withSelect, withDispatch } from '@gechiui/data';
/**
* Internal dependencies
*/
import BlockConvertButton from './block-convert-button';
import { store as blockEditorStore } from '../../store';
export default compose(
withSelect( ( select, { clientId } ) => {
const block = select( blockEditorStore ).getBlock( clientId );
return {
block,
shouldRender: block && block.name === 'core/html',
};
} ),
withDispatch( ( dispatch, { block } ) => ( {
onClick: () =>
dispatch( blockEditorStore ).replaceBlocks(
block.clientId,
rawHandler( { HTML: getBlockContent( block ) } )
),
} ) )
)( BlockConvertButton );