Skip to content

Commit

Permalink
Issue #27 - display block count in both style batch lists. Show if bl…
Browse files Browse the repository at this point in the history
…ock is ' (Not insertable)'
  • Loading branch information
bobbingwide committed Oct 26, 2020
1 parent bff2b62 commit 8c3f840
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions blocks/oik-blocklist/blocklist.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
*/

const { getBlockType, getBlockTypes, getBlockContent, serialize } = wp.blocks;
const { getBlockType, getBlockTypes, getBlockContent, serialize, hasBlockSupport } = wp.blocks;
const { BlockIcon } = wp.blockEditor;
const { Fragment, renderToString } = wp.element;
// Get just the __() localization function from wp.i18n
Expand Down Expand Up @@ -41,6 +41,8 @@ function BlockListStyled( prefix, showBlockLink, showCreateBlockLink, showDescri
if ( showBatch ) {
if ( showCreateBlockLink ) {
var blocklist = <pre>
rem Blocks {count_blocks}
<br />
{block_types.map((block ) => BlockCreateBlockLink( block, component )) }

</pre>
Expand Down Expand Up @@ -95,13 +97,16 @@ function namespaceFilter( element, index, array ) {

function BlockListItem( block, showBlockLink ) {
/* { block.icon */
/* console.log( block ); */
console.log( block );
var blockLink = null;

if ( showBlockLink ) {
blockLink = getBlockLink( block );
}

var blockSupportsInserter = null;
blockSupportsInserter = BlockSupportsInserter( block) ;

return( <Fragment key={block.name}>
<dt >
<BlockIcon icon={block.icon.src} />
Expand All @@ -116,18 +121,28 @@ function BlockListItem( block, showBlockLink ) {

{block.title } - {block.name }
</a> ) }


{!showBlockLink && (
<span>
{block.title} - {block.name} </span>)
}
{blockSupportsInserter}
<br />
{block.description}<br />



</dd>
</Fragment>
);
}

function BlockSupportsInserter( block ) {

return hasBlockSupport( block, 'inserter', true) ? '' : ' ( Not insertable )';
}

function BlockCreateItem( block, component ) {
//console.log( block );
var url = window.location.hostname;
Expand Down

0 comments on commit 8c3f840

Please sign in to comment.