@wordpress/block-library
Version:
Block library for the WordPress editor.
138 lines (137 loc) • 2.83 kB
JavaScript
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { tableOfContents as icon } from '@wordpress/icons';
/**
* Internal dependencies
*/
import initBlock from '../utils/init-block';
const metadata = {
$schema: "https://schemas.wp.org/trunk/block.json",
apiVersion: 3,
__experimental: true,
name: "core/table-of-contents",
title: "Table of Contents",
category: "design",
description: "Summarize your post with a list of headings. Add HTML anchors to Heading blocks to link them here.",
keywords: ["document outline", "summary"],
textdomain: "default",
attributes: {
headings: {
type: "array",
items: {
type: "object"
},
"default": []
},
onlyIncludeCurrentPage: {
type: "boolean",
"default": false
},
maxLevel: {
type: "number"
}
},
supports: {
html: false,
color: {
text: true,
background: true,
gradients: true,
link: true
},
spacing: {
margin: true,
padding: true
},
typography: {
fontSize: true,
lineHeight: true,
__experimentalFontFamily: true,
__experimentalFontWeight: true,
__experimentalFontStyle: true,
__experimentalTextTransform: true,
__experimentalTextDecoration: true,
__experimentalLetterSpacing: true,
__experimentalDefaultControls: {
fontSize: true
}
},
interactivity: {
clientNavigation: true
},
__experimentalBorder: {
radius: true,
color: true,
width: true,
style: true,
__experimentalDefaultControls: {
radius: true,
color: true,
width: true,
style: true
}
}
},
style: "wp-block-table-of-contents"
};
import edit from './edit';
import save from './save';
const {
name
} = metadata;
export { metadata, name };
export const settings = {
icon,
edit,
save,
example: {
innerBlocks: [{
name: 'core/heading',
attributes: {
level: 2,
content: __('Heading')
}
}, {
name: 'core/heading',
attributes: {
level: 3,
content: __('Subheading')
}
}, {
name: 'core/heading',
attributes: {
level: 2,
content: __('Heading')
}
}, {
name: 'core/heading',
attributes: {
level: 3,
content: __('Subheading')
}
}],
attributes: {
headings: [{
content: __('Heading'),
level: 2
}, {
content: __('Subheading'),
level: 3
}, {
content: __('Heading'),
level: 2
}, {
content: __('Subheading'),
level: 3
}]
}
}
};
export const init = () => initBlock({
name,
metadata,
settings
});
//# sourceMappingURL=index.js.map