diff --git a/packages/block-library/src/index.js b/packages/block-library/src/index.js index 643730e17c93c..37cafb85f8410 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'; @@ -162,6 +163,7 @@ export const __experimentalGetCoreBlocks = () => [ 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 0000000000000..22de0088c3a92 --- /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