diff --git a/packages/block-library/src/index.js b/packages/block-library/src/index.js index d92cde6ca38d5a..cb63676f540d36 100644 --- a/packages/block-library/src/index.js +++ b/packages/block-library/src/index.js @@ -54,6 +54,7 @@ import * as shortcode from './shortcode'; import * as spacer from './spacer'; import * as subhead from './subhead'; import * as table from './table'; +import * as tableOfContents from './table-of-contents'; import * as textColumns from './text-columns'; import * as verse from './verse'; import * as video from './video'; @@ -159,6 +160,7 @@ export const registerCoreBlocks = () => { spacer, subhead, table, + tableOfContents, tagCloud, textColumns, verse, diff --git a/packages/block-library/src/table-of-contents/ListItem.js b/packages/block-library/src/table-of-contents/ListItem.js new file mode 100644 index 00000000000000..e25b6d2ee806a8 --- /dev/null +++ b/packages/block-library/src/table-of-contents/ListItem.js @@ -0,0 +1,36 @@ +export default function ListItem( { children, noWrapList = false } ) { + if ( children ) { + const childNodes = children.map( function( childNode, index ) { + const { content, anchor, level } = childNode.block; + + const entry = anchor ? ( + + { content } + + ) : ( + + { content } + + ); + + return ( +
  • + { entry } + { childNode.children ? ( + { childNode.children } + ) : null } +
  • + ); + } ); + + // Don't wrap the list elements in