Skip to content

Commit

Permalink
Issue #27 - Move BlockSupportsInserter to blockinfo and extend usage
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbingwide committed Oct 26, 2020
1 parent 8c3f840 commit 81a9558
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
9 changes: 7 additions & 2 deletions blocks/oik-blockicon/blockicons.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

const { Component } = wp.element;
const{ getBlockTypes, getBlockType } = wp.blocks;
const{ getBlockTypes, getBlockType, hasBlockSupport } = wp.blocks;
const { BlockIcon } = wp.blockEditor;
const { SelectControl } = wp.components;

Expand Down Expand Up @@ -105,5 +105,10 @@ function BlockiconStyled( blockname, ...props ) {
);
}

function BlockSupportsInserter( block ) {

export { BlockiconsSelect, BlockiconStyled };
return hasBlockSupport( block, 'inserter', true) ? '' : ' ( Not insertable )';
}


export { BlockiconsSelect, BlockiconStyled, BlockSupportsInserter };
8 changes: 7 additions & 1 deletion blocks/oik-blockinfo/blockinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*
*/

import {BlockSupportsInserter} from "../oik-blockicon/blockicons";

const { getBlockType } = wp.blocks;

import { BlockiconStyled } from '../oik-blockicon/blockicons.js';
Expand All @@ -23,10 +25,14 @@ function BlockinfoStyled( blockname, showBlockTypeName, showTitle, showDescripti
var keywords = block.keywords ? block.keywords.join() : null;
var blockKeywords = showKeywords ? <div>{keywords}</div> : null;

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



return(
<div className={ props.className }>
{ blockicon }
{ blockicon } <div>{blockSupportsInserter}</div>
{ blockTypeName }
{ blockTitle }
{ blockDescription }
Expand Down
8 changes: 2 additions & 6 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, hasBlockSupport } = wp.blocks;
const { getBlockType, getBlockTypes, getBlockContent, serialize } = wp.blocks;
const { BlockIcon } = wp.blockEditor;
const { Fragment, renderToString } = wp.element;
// Get just the __() localization function from wp.i18n
Expand All @@ -15,7 +15,7 @@ const { __ } = wp.i18n;
const { select } = wp.data;
const { addQueryArgs} = wp.url;

import { BlockiconStyled } from '../oik-blockicon/blockicons.js';
import { BlockiconStyled, BlockSupportsInserter } from '../oik-blockicon/blockicons.js';
import { getNameSpace} from './blockprefix.js';


Expand Down Expand Up @@ -138,10 +138,6 @@ console.log( block );
);
}

function BlockSupportsInserter( block ) {

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

function BlockCreateItem( block, component ) {
//console.log( block );
Expand Down

0 comments on commit 81a9558

Please sign in to comment.